Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bowerfile generator #64

Merged
merged 3 commits into from
Feb 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Edge version

* update initialize generator to create sample Bowerfile

## v0.7.0

* add configuration option for `BowerRails` that invokes `rake bower:install` and `rake bower:resolve` tasks before assets precompilation
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Bower-rails now supports the standard [bower package](https://github.com/bower/b
To install dependencies into both `lib` and `vendor` directories, run the initializer to generate a custom bower.json:

``` Bash
rails g bower_rails:initialize
rails g bower_rails:initialize json
```

This will generate a special bower.json that combines two standard bower packages into one. Simply specify your dependencies under each folder name to install them into the corresponding directories.
Expand All @@ -59,7 +59,13 @@ This will generate a special bower.json that combines two standard bower package

##Ruby DSL configuration

The Ruby DSL configuration is a Bowerfile at the project's root with DSL syntax similar to Bundler.
The Ruby DSL configuration is a Bowerfile at the project's root with DSL syntax similar to Bundler.

Run the initializer to generate a sample Bowerfile inside rails root:

``` Bash
rails g bower_rails:initialize
```

**Example Bowerfile**

Expand Down
10 changes: 8 additions & 2 deletions lib/generators/bower_rails/initialize/initialize_generator.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
module BowerRails
module Generators
class InitializeGenerator < Rails::Generators::Base
desc "Adds a boilerplate component.json file to root of rails project"
desc "Adds a boilerplate bower.json or Bowerfile to root of rails project"

argument :layout, :type => :string, :default => "bowerfile"
def self.source_root
@_bower_rails_source_root ||= File.expand_path("../templates", __FILE__)
end

def create_initializer_file
template "bower.json", 'bower.json'
type = layout.underscore
if type == "json"
template "bower.json", 'bower.json'
elsif type == "bowerfile"
copy_file 'Bowerfile', 'Bowerfile'
end
end
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/bower_rails/initialize/templates/Bowerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# A sample Bowerfile

# asset 'bootstrap'