diff --git a/Changelog.md b/Changelog.md new file mode 100644 index 0000000..9cbc374 --- /dev/null +++ b/Changelog.md @@ -0,0 +1,3 @@ +## v0.5.0 +* Jsfile was renamed to Bowerfile and BowerRails::Dsl#js to BowerRails::Dsl#asset ([discussion][]) +[discussion]: https://github.com/42dev/bower-rails/pull/29 \ No newline at end of file diff --git a/README.md b/README.md index 0351972..ab443d4 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ bower-rails =========== -rake tasks for bower on rails. Dependency file is bower.json in Rails root dir. +Bower support for Rails projects. Dependency file is bower.json in Rails root dir or Bowerfile if you use DSL. +Check out Changelog.md for the latest changes and releases. **Requirements** @@ -61,17 +62,17 @@ The bower.json file is two seperate bower [component.js](https://github.com/twit ##Ruby DSL configuration -The Ruby DSL configuration is a Jsfile with DSL syntax similar to Bundler. +The Ruby DSL configuration is a Bowerfile at the project's root with DSL syntax similar to Bundler. -**Example Jsfile** +**Example Bowerfile** By default assets are put to `./vendor/assets/bower_components` directory: ``` ruby # Puts to ./vendor/assets/bower_components -js "backbone" -js "moment" +asset "backbone" +asset "moment" ``` But the default value can be overridden by `assets_path` method: @@ -80,8 +81,8 @@ But the default value can be overridden by `assets_path` method: assets_path "assets/my_javascripts" # Puts to ./vendor/assets/my_javascripts/bower_components -js "backbone" -js "moment" +asset "backbone" +asset "moment" ``` And finally, the `assets_path` method can be overridden by an option in a `group` call: @@ -91,19 +92,19 @@ assets_path "assets/javascript" # Puts files under ./vendor/assets/js/bower_components group :vendor, :assets_path => "assets/js" do - js "jquery" # Assummes it's latests - js "backbone", "1.2" + asset "jquery" # Assummes it's latests + asset "backbone", "1.2" end # Puts files under ./lib/assets/javascript/bower_components group :lib do - js "jquery" - js "backbone", "1.2" + asset "jquery" + asset "backbone", "1.2" end ``` NOTE: All the assets should be stored in `/assets` subdirectory so putting it under `./vendor/js` directory is unavailable -**Available commands with a Jsfile** +**Available commands with a Bowerfile** ``` bash rake bower:dsl:install #install js components diff --git a/lib/bower-rails/dsl.rb b/lib/bower-rails/dsl.rb index de7602b..93b42c2 100644 --- a/lib/bower-rails/dsl.rb +++ b/lib/bower-rails/dsl.rb @@ -40,7 +40,7 @@ def group(*args, &blk) yield end - def js(name, *args) + def asset(name, *args) version = args.first || "latest" @groups = [[:vendor, { assets_path: @assets_path }]] if @groups.empty? @@ -102,6 +102,5 @@ def assets_path(assets_path) def normalize_location_path(loc, assets_path) File.join(@root_path, loc.to_s, assets_path) end - end end diff --git a/lib/bower-rails/railtie.rb b/lib/bower-rails/railtie.rb index 015db51..26b2926 100644 --- a/lib/bower-rails/railtie.rb +++ b/lib/bower-rails/railtie.rb @@ -6,9 +6,10 @@ module BowerRails class Railtie < Rails::Railtie railtie_name :bower - if File.exist?(File.join("Jsfile")) + bowerfile = File.join("Bowerfile") + if File.exist?(bowerfile) BowerRails::Dsl.config = {:root_path => Rails.root} - dsl = BowerRails::Dsl.evalute(File.join("Jsfile")) + dsl = BowerRails::Dsl.evalute(bowerfile) config.before_initialize do |app| dsl.final_assets_path.map do |assets_root, assets_path| diff --git a/lib/generators/bower_rails/initialize/initialize_generator.rb b/lib/generators/bower_rails/initialize/initialize_generator.rb index e3d0d3c..8c91566 100644 --- a/lib/generators/bower_rails/initialize/initialize_generator.rb +++ b/lib/generators/bower_rails/initialize/initialize_generator.rb @@ -10,7 +10,6 @@ def self.source_root def create_initializer_file template "bower.json", 'bower.json' end - end end end \ No newline at end of file diff --git a/lib/tasks/bower.rake b/lib/tasks/bower.rake index 57e4d9c..b786e72 100644 --- a/lib/tasks/bower.rake +++ b/lib/tasks/bower.rake @@ -87,7 +87,7 @@ end def dsl_perform_command remove_components = true bower_root = get_bower_root_path BowerRails::Dsl.config = {:root_path => bower_root} - dsl = BowerRails::Dsl.evalute(File.join(bower_root, "Jsfile")) + dsl = BowerRails::Dsl.evalute(File.join(bower_root, "Bowerfile")) if remove_components dsl.write_bower_json diff --git a/test/Jsfile.rb b/test/Bowerfile similarity index 54% rename from test/Jsfile.rb rename to test/Bowerfile index b59da36..d9f7350 100644 --- a/test/Jsfile.rb +++ b/test/Bowerfile @@ -1,11 +1,11 @@ assets_path "assets/javascript" group :vendor, :assets_path => "assets/js" do - js "jquery" - js "backbone", "1.2" + asset "jquery" + asset "backbone", "1.2" end group :lib do - js "jquery" - js "backbone", "1.2" + asset "jquery" + asset "backbone", "1.2" end \ No newline at end of file diff --git a/test/dsl_test.rb b/test/dsl_test.rb index 9c5b7ac..b34a29f 100644 --- a/test/dsl_test.rb +++ b/test/dsl_test.rb @@ -2,6 +2,6 @@ BowerRails::Dsl.config = {:root_path => File.expand_path("./out") } -inst = BowerRails::Dsl.evalute(File.expand_path("./Jsfile.rb")) +inst = BowerRails::Dsl.evalute(File.expand_path("./Bowerfile")) inst.write_bower_json