bower-rails 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05faebea58423491bfd583dab2eca0b0ba062724
4
- data.tar.gz: e63b4071d055ccd6b8c68898311c3fa794a02871
3
+ metadata.gz: 6006f079a66a16246b1b202c5937c34c2a10f604
4
+ data.tar.gz: ff977ce0ecd9914b0da8d17035654a3cf68dd82c
5
5
  SHA512:
6
- metadata.gz: 8683a3796762962d9d43030c2af460440b7cc25c45f6ef9b1f380797ba295878975346d6d076e6900d3a44737d2312e92f512e0ed774333057f25585100a0239
7
- data.tar.gz: dece1f7c79ce74a344d30a56d1dd2b1e6e17336e20b07a0b69c6543f4da1e9a57051f39de3b04a2694f79b89cb0cc1040ba72cedbf6805e10ce23f631ebb5f8f
6
+ metadata.gz: 9b0caababbe66adb75d1978c4c2dbb38dd351d48da41fb1a441a273ce1ee3ce157addcc0e780cb3990f44f5e5891c2f1f024f666fbc2aff33b42734fde4263b0
7
+ data.tar.gz: 32912bcc0c5b3c9650446a7751c137d9b9e02ec179ba1853a9ed5b17a6c2004808a6c13216640d0249ee6c61bd887889da606a4c5ef29b2a570273fdb9d67796
File without changes
data/README.md CHANGED
@@ -1,11 +1,10 @@
1
- bower-rails
2
- ===========
1
+ # bower-rails
3
2
 
4
- [![Gem Version](http://img.shields.io/gem/v/bower-rails.svg)][gem]
5
- [![Code Climate](http://img.shields.io/codeclimate/github/42dev/bower-rails.svg)][codeclimate]
6
- [![Dependency Status](http://img.shields.io/gemnasium/SergeyKishenin/bower-rails.svg)][gemnasium]
3
+ [![Gem Version](https://badge.fury.io/rb/bower-rails.svg)](http://badge.fury.io/rb/bower-rails)
4
+ [![Code Climate](https://codeclimate.com/github/rharriso/bower-rails/badges/gpa.svg)](https://codeclimate.com/github/rharriso/bower-rails)
5
+ [![Dependency Status](https://img.shields.io/gemnasium/SergeyKishenin/bower-rails.svg)][gemnasium]
7
6
  [![Build Status](https://travis-ci.org/rharriso/bower-rails.svg?branch=master)][travis]
8
- [![Coverage Status](https://coveralls.io/repos/42dev/bower-rails/badge.png)][coveralls]
7
+ [![Coverage Status](https://coveralls.io/repos/rharriso/bower-rails/badge.svg?branch=master&service=github)](https://coveralls.io/github/rharriso/bower-rails?branch=master)
9
8
 
10
9
  [gem]: https://rubygems.org/gems/bower-rails
11
10
  [travis]: https://travis-ci.org/rharriso/bower-rails
@@ -29,17 +28,17 @@ NOTE: If you install `node` via package manager with `sudo apt-get install nodej
29
28
 
30
29
  in Gemfile
31
30
 
32
- ``` Ruby
31
+ ```ruby
33
32
  gem "bower-rails", "~> 0.10.0"
34
33
  ```
35
34
 
36
- ##JSON configuration
35
+ ## JSON configuration
37
36
 
38
- Bower-rails now supports the standard [bower package](https://github.com/bower/bower#defining-a-package) format out-of-the-box. Simply place your bower.json file the Rails root directory to start. Using the standard format will default all bower components to be installed under the `vendor` directory.
37
+ Bower-rails now supports the standard [bower package](http://bower.io/docs/creating-packages/#specification) format out-of-the-box. Simply place your bower.json file the Rails root directory to start. Using the standard format will default all bower components to be installed under the `vendor` directory.
39
38
 
40
39
  To install dependencies into both `lib` and `vendor` directories, run the initializer to generate a custom bower.json:
41
40
 
42
- ``` Bash
41
+ ```bash
43
42
  rails g bower_rails:initialize json
44
43
  ```
45
44
 
@@ -47,31 +46,40 @@ This will generate a `config/initializers/bower_rails.rb` config file and a spec
47
46
 
48
47
  **example bower.json file**
49
48
 
50
- ``` javascript
49
+ ```json
51
50
  {
52
51
  "lib": {
53
52
  "name": "bower-rails generated lib assets",
54
53
  "dependencies": {
55
- "threex" : "git@github.com:rharriso/threex.git",
56
- "gsvpano.js" : "https://github.com/rharriso/GSVPano.js/blob/master/src/GSVPano.js"
54
+ "threex": "git@github.com:rharriso/threex.git",
55
+ "gsvpano.js": "https://github.com/rharriso/GSVPano.js/blob/master/src/GSVPano.js"
57
56
  }
58
57
  },
59
58
  "vendor": {
60
59
  "name": "bower-rails generated vendor assets",
61
60
  "dependencies": {
62
- "three.js" : "https://raw.github.com/mrdoob/three.js/master/build/three.js"
61
+ "three.js": "https://raw.github.com/mrdoob/three.js/master/build/three.js"
63
62
  }
64
63
  }
65
64
  }
66
65
  ```
67
66
 
68
- ##Ruby DSL configuration
67
+ ## Include in Asset Pipeline
68
+
69
+ ```javascript
70
+ // Bower packages
71
+ //= require d3/d3
72
+ //= require underscore/underscore
73
+ //
74
+ ```
75
+
76
+ ## Ruby DSL configuration
69
77
 
70
78
  The Ruby DSL configuration is a Bowerfile at the project's root with DSL syntax similar to Bundler.
71
79
 
72
80
  Run the initializer to generate a sample Bowerfile inside the Rails root and a `config/initializers/bower_rails.rb` config file:
73
81
 
74
- ``` Bash
82
+ ```bash
75
83
  rails g bower_rails:initialize
76
84
  ```
77
85
 
@@ -79,7 +87,7 @@ Run the initializer to generate a sample Bowerfile inside the Rails root and a `
79
87
 
80
88
  By default assets are put to `./vendor/assets/bower_components` directory:
81
89
 
82
- ``` ruby
90
+ ```ruby
83
91
 
84
92
  # Puts to ./vendor/assets/bower_components
85
93
  asset "backbone"
@@ -101,7 +109,7 @@ asset "three.js", "https://raw.github.com/mrdoob/three.js/master/build/three.js"
101
109
 
102
110
  But the default value can be overridden by `assets_path` method:
103
111
 
104
- ``` ruby
112
+ ```ruby
105
113
  assets_path "assets/my_javascripts"
106
114
 
107
115
  # Puts to ./vendor/assets/my_javascripts/bower_components
@@ -111,7 +119,7 @@ asset "moment"
111
119
 
112
120
  The `assets_path` method can be overridden by an option in a `group` call:
113
121
 
114
- ``` ruby
122
+ ```ruby
115
123
  assets_path "assets/javascript"
116
124
 
117
125
  # Puts files under ./vendor/assets/js/bower_components
@@ -129,10 +137,10 @@ end
129
137
  NOTE: Available groups are `:lib` and `:vendor`. Others are not allowed according to the Rails convention.
130
138
  NOTE: All the assets should be stored in `/assets` subdirectory so putting it under `./vendor/js` directory is unavailable
131
139
 
132
- You can extend `main` directive to include some missing files using `main_files`
140
+ You can extend `main` directive to include some missing files using `main_files`
133
141
  option as parameter or in a block:
134
142
 
135
- ``` ruby
143
+ ```ruby
136
144
  # via argument
137
145
  asset "moment", "2.10.1", main_files: ["./locale/en-gb.js"]
138
146
 
@@ -148,7 +156,7 @@ end
148
156
 
149
157
  And finally, you can specify the assets to be in the devDependencies block:
150
158
 
151
- ``` ruby
159
+ ```ruby
152
160
  asset "backbone", "1.1.1"
153
161
 
154
162
  # Adds jasmine-sinon and jasmine-matchers to devDependencies
@@ -164,11 +172,11 @@ end
164
172
  ```
165
173
  results in the following bower.json file:
166
174
 
167
- ```
175
+ ```json
168
176
  {
169
- "name": "dsl-generated dependencies",
177
+ "name": "dsl-generated-dependencies",
170
178
  "dependencies": {
171
- "backbone": "1.1.1"
179
+ "backbone": "1.1.1",
172
180
  "angular": "1.2.18",
173
181
  },
174
182
  "devDependencies": {
@@ -189,11 +197,11 @@ resolution "angular", "1.2.22"
189
197
 
190
198
  That will produce `bower.json` like:
191
199
 
192
- ``` javascript
200
+ ```json
193
201
  {
194
- "name" : "dsl-generated dependencies",
195
- "dependencies" : {
196
- "angular" : "1.2.22"
202
+ "name" : "dsl-generated-dependencies",
203
+ "dependencies": {
204
+ "angular": "1.2.22"
197
205
  },
198
206
  "resolutions": {
199
207
  "angular": "1.2.22"
@@ -207,7 +215,7 @@ That will produce `bower.json` like:
207
215
 
208
216
  Change options in your `config/initializers/bower_rails.rb`:
209
217
 
210
- ``` ruby
218
+ ```ruby
211
219
  BowerRails.configure do |bower_rails|
212
220
  # Tell bower-rails what path should be considered as root. Defaults to Dir.pwd
213
221
  bower_rails.root_path = Dir.pwd
@@ -221,11 +229,21 @@ BowerRails.configure do |bower_rails|
221
229
  # Invokes rake bower:clean before precompilation. Defaults to false
222
230
  bower_rails.clean_before_precompile = true
223
231
 
224
- # Invokes rake bower:install:deployment instead rake bower:install. Defaults to false
232
+ # Excludes specific bower components from clean. Defaults to nil
233
+ bower_rails.exclude_from_clean = ['moment']
234
+
235
+ # Invokes rake bower:install:deployment instead of rake bower:install. Defaults to false
225
236
  bower_rails.use_bower_install_deployment = true
226
237
 
238
+ # rake bower:install will search for gem dependencies and in each gem it will search for Bowerfile
239
+ # and then concatenate all Bowerfile for evaluation
240
+ bower_rails.use_gem_deps_for_bowerfile = true
241
+
227
242
  # Passes the -F option to rake bower:install or rake bower:install:deployment. Defaults to false.
228
243
  bower_rails.force_install = true
244
+
245
+ # Change the default directory name
246
+ bower_rails.bower_components_directory = 'bower_components'
229
247
  end
230
248
  ```
231
249
 
@@ -242,7 +260,7 @@ end
242
260
 
243
261
  By default this line is added while running the generator.
244
262
 
245
- ##Rake tasks
263
+ ## Rake tasks
246
264
 
247
265
  Once you are done with `bower.json` or `Bowerfile` you can run
248
266
 
@@ -253,7 +271,7 @@ Once you are done with `bower.json` or `Bowerfile` you can run
253
271
  * `rake bower:list` to list all packages
254
272
  * `rake bower:clean` to remove all files not listed as [main files](#bower-main-files) (if specified)
255
273
  * `rake bower:resolve` to resolve [relative asset paths](#relative-asset-paths) in components
256
- * `rake bower:cache:clean` to clear the bower cache. This is useful when you know a component has been updated.
274
+ * `rake bower:cache:clean` to clear the bower cache. This is useful when you know a component has been updated.
257
275
 
258
276
  If you'd like to pass any bower CLI options to a rake task, like `-f`, `-j`, you can simply do:
259
277
 
@@ -261,17 +279,19 @@ If you'd like to pass any bower CLI options to a rake task, like `-f`, `-j`, you
261
279
  rake bower:install['-f']
262
280
  ```
263
281
 
264
- ##Capistrano 3 Configuration
282
+ ## Capistrano 3 Configuration
265
283
 
266
284
  While using Capistrano 3 and Capistrano Rails gem, it's needed to run bower install before assets compile. Add the following code to your deploy.rb, it will run `rake bower:install` before compiling the assets. CI=true flag is used not to ask for the analytics at the first bower install.
267
285
 
268
- ```
286
+ ```ruby
269
287
  namespace :bower do
270
288
  desc 'Install bower'
271
289
  task :install do
272
290
  on roles(:web) do
273
291
  within release_path do
274
- execute :rake, 'bower:install CI=true'
292
+ with rails_env: fetch(:rails_env) do
293
+ execute :rake, 'bower:install CI=true'
294
+ end
275
295
  end
276
296
  end
277
297
  end
@@ -279,29 +299,29 @@ end
279
299
  before 'deploy:compile_assets', 'bower:install'
280
300
  ```
281
301
 
282
- ##Bower Configuration
302
+ ## Bower Configuration
283
303
 
284
304
  If you provide a `.bowerrc` in the rails project root, bower-rails will use it for bower configuration.
285
305
  Some .bowerrc options are not supported: `directory`, `cwd`, and `interactive`. Bower-rails
286
306
  will ignore the `directory` property and instead will use the automatically generated asset path.
287
307
 
288
- ###Bower Installation
308
+ ### Bower Installation
289
309
 
290
310
  [Bower](https://github.com/bower/bower) should be installed using npm. Bower can be installed globally (with `$ npm install -g bower`) or in `node_modules` in the root directory of your project.
291
311
 
292
- ##Relative asset paths
312
+ ## Relative asset paths
293
313
 
294
314
  Some bower components (eg. [Bootstrap](https://github.com/twbs/bootstrap/blob/0016c17f9307bc71fc96d8d4680a9c861f137cae/dist/css/bootstrap.css#L2263)) have relative urls in the CSS files for imports, images, etc. Rails prefers using [helper methods](http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets) for linking to assets within CSS. Relative paths can cause issues when assets are precompiled for production.
295
315
 
296
316
  Remember that you should have [bower installed](#bower-installation) either locally in your project or on a remote server.
297
317
 
298
- ##Bower Main Files
318
+ ## Bower Main Files
299
319
 
300
- Each bower component should follow the [bower.json spec](https://github.com/bower/bower.json-spec)
301
- which designates a recommended `main` directive that lists the primary files of
302
- that component. You may choose to reference these files if you are using the asset
303
- pipeline, in which case other extraneous includes of the bower component are not needed.
304
- The `rake bower:clean` task removes every file that isn't listed in the `main` directive,
320
+ Each bower component should follow the [bower.json spec](https://github.com/bower/bower.json-spec)
321
+ which designates a recommended `main` directive that lists the primary files of
322
+ that component. You may choose to reference these files if you are using the asset
323
+ pipeline, in which case other extraneous includes of the bower component are not needed.
324
+ The `rake bower:clean` task removes every file that isn't listed in the `main` directive,
305
325
  if the component specifies a `main` directive. Remember that you can extend the `main` directive
306
- in [ruby DSL configuration](#ruby-dsl-configuration). Otherwise, the library will remain as bower installed it. It supports wildcards
326
+ in [ruby DSL configuration](#ruby-dsl-configuration). Otherwise, the library will remain as bower installed it. It supports wildcards
307
327
  in files listed in `main` directive.
@@ -22,14 +22,26 @@ module BowerRails
22
22
  # are invoked before assets precompilation
23
23
  attr_accessor :clean_before_precompile
24
24
 
25
+ # If containing a list of bower component names, those components
26
+ # will be excluded from the bower:clean
27
+ attr_accessor :exclude_from_clean
28
+
25
29
  # If set to true then rake bower:install:deployment will be invoked
26
30
  # instead of rake bower:install before assets precompilation
27
31
  attr_accessor :use_bower_install_deployment
28
32
 
33
+ # If set to true then rake bower:install will search for gem dependencies
34
+ # and in each gem it will search for Bowerfile and then concatenate all Bowerfile
35
+ # for evaluation
36
+ attr_accessor :use_gem_deps_for_bowerfile
37
+
29
38
  # If set to true then rake bower:install[-f] will be invoked
30
39
  # instead of rake bower:install before assets precompilation
31
40
  attr_accessor :force_install
32
41
 
42
+ # Where to store the bower components
43
+ attr_accessor :bower_components_directory
44
+
33
45
  def configure &block
34
46
  yield self if block_given?
35
47
  collect_tasks
@@ -58,5 +70,7 @@ module BowerRails
58
70
  @resolve_before_precompile = false
59
71
  @clean_before_precompile = false
60
72
  @use_bower_install_deployment = false
73
+ @use_gem_deps_for_bowerfile = false
61
74
  @force_install = false
75
+ @bower_components_directory = "bower_components"
62
76
  end
@@ -7,7 +7,13 @@ module BowerRails
7
7
  DEFAULT_DEPENDENCY_GROUP = :dependencies
8
8
 
9
9
  def self.evalute(root_path, filename)
10
- new(root_path).tap { |dsl| dsl.eval_file(File.join(root_path, filename)) }
10
+ new(root_path).tap do |dsl|
11
+ dsl.send(eval_file_method, File.join(root_path, filename))
12
+ end
13
+ end
14
+
15
+ def self.eval_file_method
16
+ BowerRails.use_gem_deps_for_bowerfile ? :eval_file_with_deps : :eval_file
11
17
  end
12
18
 
13
19
  attr_reader :dependencies, :root_path
@@ -20,6 +26,7 @@ module BowerRails
20
26
  @resolutions = {}
21
27
  @assets_path ||= "assets"
22
28
  @main_files = {}
29
+ @current_group = nil
23
30
  end
24
31
 
25
32
  def asset(name, *args, &block)
@@ -67,7 +74,15 @@ module BowerRails
67
74
  end
68
75
 
69
76
  def eval_file(file)
70
- instance_eval(File.open(file, "rb") { |f| f.read }, file.to_s)
77
+ instance_eval(File.open(file, 'rb') { |f| f.read }, file.to_s)
78
+ end
79
+
80
+ def eval_file_with_deps(file)
81
+ Gem::Specification.map do |dep|
82
+ bowerfile_in_dep = File.join(dep.gem_dir, 'Bowerfile')
83
+ eval_file(bowerfile_in_dep) if bowerfile_in_dep != file && File.exist?(bowerfile_in_dep)
84
+ end
85
+ eval_file(file)
71
86
  end
72
87
 
73
88
  def final_assets_path
@@ -120,6 +135,7 @@ module BowerRails
120
135
  normalized_group_path = normalize_location_path(group.first, group_assets_path(group))
121
136
  File.open(File.join(normalized_group_path, ".bowerrc"), "w") do |f|
122
137
  f.write(generate_dotbowerrc)
138
+ f.write("\n")
123
139
  end
124
140
  end
125
141
  end
@@ -187,7 +203,7 @@ module BowerRails
187
203
  #
188
204
  def dependencies_to_json(data)
189
205
  JSON.pretty_generate({
190
- :name => "dsl-generated dependencies"
206
+ :name => "dsl-generated-dependencies"
191
207
  }.merge(data))
192
208
  end
193
209
 
@@ -15,8 +15,6 @@ module BowerRails
15
15
  end
16
16
 
17
17
  def perform(remove_components = true, &block)
18
- entries = Dir.entries(root_path)
19
-
20
18
  npm_path = File.join(root_path, 'node_modules', '.bin')
21
19
  bower = find_command('bower', [npm_path])
22
20
 
@@ -24,7 +22,7 @@ module BowerRails
24
22
  $stderr.puts ["Bower not found! You can install Bower using Node and npm:",
25
23
  "$ npm install bower -g",
26
24
  "For more info see http://bower.io/"].join("\n")
27
- return
25
+ exit 127
28
26
  end
29
27
 
30
28
  if entries.include?('Bowerfile')
@@ -69,9 +67,9 @@ module BowerRails
69
67
 
70
68
  # Load and merge root .bowerrc
71
69
  dot_bowerrc = JSON.parse(File.read(File.join(root_path, '.bowerrc'))) rescue {}
72
- dot_bowerrc["directory"] = "bower_components"
70
+ dot_bowerrc["directory"] = components_directory
73
71
 
74
- if json.except('lib', 'vendor').empty?
72
+ if json.reject{ |key| ['lib', 'vendor'].include? key }.empty?
75
73
  folders = json.keys
76
74
  else
77
75
  raise "Assuming a standard bower package but cannot find the required 'name' key" unless !!json['name']
@@ -91,7 +89,7 @@ module BowerRails
91
89
  Dir.chdir(dir) do
92
90
 
93
91
  # Remove old components
94
- FileUtils.rm_rf("bower_components") if remove_components
92
+ FileUtils.rm_rf("#{components_directory}/*") if remove_components
95
93
 
96
94
  # Create bower.json
97
95
  File.open("bower.json", "w") do |f|
@@ -115,25 +113,26 @@ module BowerRails
115
113
  end
116
114
  end
117
115
 
118
- def resolve_asset_paths
116
+ def resolve_asset_paths(root_directory = components_directory)
119
117
  # Resolve relative paths in CSS
120
- Dir['bower_components/**/*.css'].each do |filename|
118
+ Dir["#{components_directory}/**/*.css"].each do |filename|
121
119
  contents = File.read(filename) if FileTest.file?(filename)
122
120
  # http://www.w3.org/TR/CSS2/syndata.html#uri
123
- url_regex = /url\((?!\#)\s*['"]?(?![a-z]+:)([^'"\)]*)['"]?\s*\)/
121
+ url_regex = /url\((?!\#)\s*['"]?((?![a-z]+:)([^'"\)]*?)([?#][^'"\)]*)?)['"]?\s*\)/
124
122
 
125
123
  # Resolve paths in CSS file if it contains a url
126
124
  if contents =~ url_regex
127
125
  directory_path = Pathname.new(File.dirname(filename))
128
- .relative_path_from(Pathname.new('bower_components'))
126
+ .relative_path_from(Pathname.new(root_directory))
129
127
 
130
128
  # Replace relative paths in URLs with Rails asset_path helper
131
129
  new_contents = contents.gsub(url_regex) do |match|
132
- relative_path = $1
130
+ relative_path = $2
131
+ params = $3
133
132
  image_path = directory_path.join(relative_path).cleanpath
134
- puts "#{match} => #{image_path}"
133
+ puts "#{match} => #{image_path} #{params}"
135
134
 
136
- "url(<%= asset_path '#{image_path}' %>)"
135
+ "url(<%= asset_path '#{image_path}' %>#{params})"
137
136
  end
138
137
 
139
138
  # Replace CSS with ERB CSS file with resolved asset paths
@@ -146,7 +145,10 @@ module BowerRails
146
145
  def remove_extra_files
147
146
  puts "\nAttempting to remove all but main files as specified by bower\n"
148
147
 
149
- Dir['bower_components/*'].each do |component_dir|
148
+ Dir["#{components_directory}/*"].each do |component_dir|
149
+ component_name = component_dir.split('/').last
150
+ next if clean_should_skip_component? component_name
151
+
150
152
  if File.exists?(File.join(component_dir, 'bower.json'))
151
153
  bower_file = File.read(File.join(component_dir, 'bower.json'))
152
154
  elsif File.exists?(File.join(component_dir, '.bower.json'))
@@ -157,7 +159,6 @@ module BowerRails
157
159
 
158
160
  # Parse bower.json
159
161
  bower_json = JSON.parse(bower_file)
160
- component_name = component_dir.split('/').last
161
162
  main_files = Array(bower_json['main']) + main_files_for_component(component_name)
162
163
  next if main_files.empty?
163
164
 
@@ -186,7 +187,9 @@ module BowerRails
186
187
  paths.each do |path|
187
188
  exts.each do |ext|
188
189
  exe = File.join(path, "#{cmd}#{ext}")
189
- return exe if (File.executable?(exe) && File.file?(exe))
190
+ if (File.executable?(exe) && File.file?(exe))
191
+ return Shellwords.escape exe
192
+ end
190
193
  end
191
194
  end
192
195
  nil
@@ -195,7 +198,21 @@ module BowerRails
195
198
  private
196
199
 
197
200
  def main_files_for_component(name)
201
+ return [] unless entries.include?('Bowerfile')
198
202
  Array(dsl.main_files[name])
199
203
  end
204
+
205
+ def entries
206
+ @entries ||= Dir.entries(root_path)
207
+ end
208
+
209
+ def clean_should_skip_component?(name)
210
+ BowerRails.exclude_from_clean.respond_to?(:include?) &&
211
+ BowerRails.exclude_from_clean.include?(name)
212
+ end
213
+
214
+ def components_directory
215
+ BowerRails.bower_components_directory
216
+ end
200
217
  end
201
218
  end
@@ -1,6 +1,4 @@
1
- require 'bower-rails'
2
1
  require 'bower-rails/dsl'
3
- require 'rails'
4
2
 
5
3
  module BowerRails
6
4
  class Railtie < Rails::Railtie
@@ -11,13 +9,15 @@ module BowerRails
11
9
  config.before_initialize do |app|
12
10
  @dsl = BowerRails::Dsl.evalute(BowerRails.root_path, @@bowerfile)
13
11
  @dsl.final_assets_path.map do |assets_root, assets_path|
14
- app.config.assets.paths << Rails.root.join(assets_root, assets_path, "bower_components")
12
+ app.config.assets.paths <<
13
+ Rails.root.join(assets_root, assets_path, BowerRails.bower_components_directory)
15
14
  end
16
15
  end
17
16
  else
18
17
  config.before_initialize do |app|
19
18
  ["lib", "vendor"].each do |dir|
20
- app.config.assets.paths << Rails.root.join(dir, 'assets', 'bower_components')
19
+ app.config.assets.paths <<
20
+ Rails.root.join(dir, 'assets', BowerRails.bower_components_directory)
21
21
  end
22
22
  end
23
23
  end
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module BowerRails
3
- VERSION = "0.10.0"
3
+ VERSION = "0.11.0"
4
4
  end
@@ -1,6 +1,8 @@
1
1
  module BowerRails
2
2
  module Generators
3
3
  class InitializeGenerator < Rails::Generators::Base
4
+ INITIALIZE_FILE_PATH = 'config/initializers/bower_rails.rb'
5
+
4
6
  desc 'Adds a boilerplate bower.json or Bowerfile to the root of Rails project and an empty initializer'
5
7
  source_root File.expand_path('../templates', __FILE__)
6
8
  argument :config_file, :type => :string, :default => 'bowerfile'
@@ -16,14 +18,14 @@ module BowerRails
16
18
  end
17
19
 
18
20
  def copy_initializer_file
19
- copy_file 'bower_rails.rb', 'config/initializers/bower_rails.rb'
21
+ copy_file 'bower_rails.rb', INITIALIZE_FILE_PATH
20
22
  end
21
23
 
22
24
  def require_initializer_in_application_rb
23
25
  if Rails.version < "4.0.0"
24
- environment { "require \"#{Rails.root}/config/initializers/bower_rails.rb\"" }
26
+ environment { "require Rails.root.join(\"#{INITIALIZE_FILE_PATH}\").to_s" }
25
27
  end
26
28
  end
27
29
  end
28
30
  end
29
- end
31
+ end
@@ -11,9 +11,12 @@ BowerRails.configure do |bower_rails|
11
11
  # Invokes rake bower:clean before precompilation. Defaults to false
12
12
  # bower_rails.clean_before_precompile = true
13
13
 
14
- # Invokes rake bower:install:deployment instead rake bower:install. Defaults to false
14
+ # Invokes rake bower:install:deployment instead of rake bower:install. Defaults to false
15
15
  # bower_rails.use_bower_install_deployment = true
16
16
  #
17
17
  # Invokes rake bower:install and rake bower:install:deployment with -F (force) flag. Defaults to false
18
18
  # bower_rails.force_install = true
19
+
20
+ # Change the default directory name
21
+ # bower_rails.bower_components_directory = 'bower_components'
19
22
  end
@@ -62,9 +62,10 @@ namespace :bower do
62
62
  end
63
63
 
64
64
  desc "Resolve assets paths in bower components"
65
- task :resolve do
65
+ task :resolve, :relative_directory do |_, args|
66
66
  BowerRails::Performer.perform false do
67
- resolve_asset_paths
67
+ resolve_asset_paths(
68
+ args[:relative_directory] || BowerRails.bower_components_directory)
68
69
  end
69
70
  end
70
71
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bower-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Harrison
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project:
93
- rubygems_version: 2.4.7
93
+ rubygems_version: 2.4.8
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Bower for Rails