bower-rails 0.9.2 → 0.10.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: bac09d7777aefd06a5be16848df529d7f0ab4ada
4
- data.tar.gz: 6b77c226ceffd97162d54ba8fec64fe0303507b3
3
+ metadata.gz: 05faebea58423491bfd583dab2eca0b0ba062724
4
+ data.tar.gz: e63b4071d055ccd6b8c68898311c3fa794a02871
5
5
  SHA512:
6
- metadata.gz: 8e23cf065c09988eaf220f21298b9ca8a54f5c0b8d7aabb0be498680d024b7bf6fd64747f3faaffead35d7e66b064885b37b25e40bdb44bf1ccdc50f65800113
7
- data.tar.gz: 040922cf262805e6283b93c7ece6fed77ea42745e289d2b9ead335c1e09dba2c286a7f44474e41e2b6c08a8ac0fea204e681ee2e001bfc0bf2b282d747c80fa3
6
+ metadata.gz: 8683a3796762962d9d43030c2af460440b7cc25c45f6ef9b1f380797ba295878975346d6d076e6900d3a44737d2312e92f512e0ed774333057f25585100a0239
7
+ data.tar.gz: dece1f7c79ce74a344d30a56d1dd2b1e6e17336e20b07a0b69c6543f4da1e9a57051f39de3b04a2694f79b89cb0cc1040ba72cedbf6805e10ce23f631ebb5f8f
File without changes
data/README.md CHANGED
@@ -4,11 +4,11 @@ bower-rails
4
4
  [![Gem Version](http://img.shields.io/gem/v/bower-rails.svg)][gem]
5
5
  [![Code Climate](http://img.shields.io/codeclimate/github/42dev/bower-rails.svg)][codeclimate]
6
6
  [![Dependency Status](http://img.shields.io/gemnasium/SergeyKishenin/bower-rails.svg)][gemnasium]
7
- [![Build Status](https://travis-ci.org/42dev/bower-rails.svg?branch=master)][travis]
7
+ [![Build Status](https://travis-ci.org/rharriso/bower-rails.svg?branch=master)][travis]
8
8
  [![Coverage Status](https://coveralls.io/repos/42dev/bower-rails/badge.png)][coveralls]
9
9
 
10
10
  [gem]: https://rubygems.org/gems/bower-rails
11
- [travis]: https://travis-ci.org/42dev/bower-rails
11
+ [travis]: https://travis-ci.org/rharriso/bower-rails
12
12
  [gemnasium]: https://gemnasium.com/SergeyKishenin/bower-rails
13
13
  [codeclimate]: https://codeclimate.com/github/42dev/bower-rails
14
14
  [coveralls]: https://coveralls.io/r/42dev/bower-rails
@@ -23,12 +23,14 @@ Check out [changelog][] for the latest changes and releases.
23
23
  * [node](http://nodejs.org) ([on github](https://github.com/joyent/node))
24
24
  * [bower](https://github.com/bower/bower) (>= 0.10.0) installed with npm
25
25
 
26
+ NOTE: If you install `node` via package manager with `sudo apt-get install nodejs` you'll also need to install `nodejs-legacy` with `sudo apt-get install nodejs-legacy`. See [#91](https://github.com/42dev/bower-rails/issues/91)
27
+
26
28
  **Install**
27
29
 
28
30
  in Gemfile
29
31
 
30
32
  ``` Ruby
31
- gem "bower-rails", "~> 0.9.1"
33
+ gem "bower-rails", "~> 0.10.0"
32
34
  ```
33
35
 
34
36
  ##JSON configuration
@@ -92,6 +94,9 @@ asset "secret_logic", "1.0.0", github: "initech/secret_logic"
92
94
 
93
95
  # get a specific revision from a git endpoint
94
96
  asset "secret_logic", github: "initech/secret_logic", ref: '0adff'
97
+
98
+ # get a single file
99
+ asset "three.js", "https://raw.github.com/mrdoob/three.js/master/build/three.js"
95
100
  ```
96
101
 
97
102
  But the default value can be overridden by `assets_path` method:
@@ -124,6 +129,23 @@ end
124
129
  NOTE: Available groups are `:lib` and `:vendor`. Others are not allowed according to the Rails convention.
125
130
  NOTE: All the assets should be stored in `/assets` subdirectory so putting it under `./vendor/js` directory is unavailable
126
131
 
132
+ You can extend `main` directive to include some missing files using `main_files`
133
+ option as parameter or in a block:
134
+
135
+ ``` ruby
136
+ # via argument
137
+ asset "moment", "2.10.1", main_files: ["./locale/en-gb.js"]
138
+
139
+ # or in block
140
+ asset "moment", "2.10.1" do
141
+ main_files [
142
+ "./locale/en-gb.js",
143
+ "./locale/fr.js",
144
+ "./locale/lv.js"
145
+ ]
146
+ end
147
+ ```
148
+
127
149
  And finally, you can specify the assets to be in the devDependencies block:
128
150
 
129
151
  ``` ruby
@@ -201,6 +223,9 @@ BowerRails.configure do |bower_rails|
201
223
 
202
224
  # Invokes rake bower:install:deployment instead rake bower:install. Defaults to false
203
225
  bower_rails.use_bower_install_deployment = true
226
+
227
+ # Passes the -F option to rake bower:install or rake bower:install:deployment. Defaults to false.
228
+ bower_rails.force_install = true
204
229
  end
205
230
  ```
206
231
 
@@ -236,6 +261,24 @@ If you'd like to pass any bower CLI options to a rake task, like `-f`, `-j`, you
236
261
  rake bower:install['-f']
237
262
  ```
238
263
 
264
+ ##Capistrano 3 Configuration
265
+
266
+ 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
+
268
+ ```
269
+ namespace :bower do
270
+ desc 'Install bower'
271
+ task :install do
272
+ on roles(:web) do
273
+ within release_path do
274
+ execute :rake, 'bower:install CI=true'
275
+ end
276
+ end
277
+ end
278
+ end
279
+ before 'deploy:compile_assets', 'bower:install'
280
+ ```
281
+
239
282
  ##Bower Configuration
240
283
 
241
284
  If you provide a `.bowerrc` in the rails project root, bower-rails will use it for bower configuration.
@@ -254,4 +297,11 @@ Remember that you should have [bower installed](#bower-installation) either loca
254
297
 
255
298
  ##Bower Main Files
256
299
 
257
- Each bower component should follow the [bower.json spec](https://github.com/bower/bower.json-spec) which designates a recommended `main` directive that lists the primary files of that component. You may choose to reference these files if you are using the asset pipeline, in which case other extraneous includes of the bower component are not needed. The `rake bower:clean` task removes every file that isn't listed in the `main` directive, if the component specifies a `main` directive. Otherwise, the library will remain as bower installed it. It supports wildcards in files listed in `main` directive.
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,
305
+ 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
307
+ in files listed in `main` directive.
@@ -26,6 +26,10 @@ module BowerRails
26
26
  # instead of rake bower:install before assets precompilation
27
27
  attr_accessor :use_bower_install_deployment
28
28
 
29
+ # If set to true then rake bower:install[-f] will be invoked
30
+ # instead of rake bower:install before assets precompilation
31
+ attr_accessor :force_install
32
+
29
33
  def configure &block
30
34
  yield self if block_given?
31
35
  collect_tasks
@@ -36,6 +40,7 @@ module BowerRails
36
40
  def collect_tasks
37
41
  install_cmd = 'bower:install'
38
42
  install_cmd = 'bower:install:deployment' if @use_bower_install_deployment
43
+ install_cmd += '[-F]' if @force_install
39
44
 
40
45
  @tasks << [install_cmd] if @install_before_precompile
41
46
  @tasks << [install_cmd, 'bower:clean'] if @clean_before_precompile
@@ -53,4 +58,5 @@ module BowerRails
53
58
  @resolve_before_precompile = false
54
59
  @clean_before_precompile = false
55
60
  @use_bower_install_deployment = false
61
+ @force_install = false
56
62
  end
@@ -19,9 +19,11 @@ module BowerRails
19
19
  @dependencies = {}
20
20
  @resolutions = {}
21
21
  @assets_path ||= "assets"
22
+ @main_files = {}
22
23
  end
23
24
 
24
- def asset(name, *args)
25
+ def asset(name, *args, &block)
26
+ @asset_name = name
25
27
  group = @current_group || default_group
26
28
  options = Hash === args.last ? args.pop.dup : {}
27
29
 
@@ -38,6 +40,12 @@ module BowerRails
38
40
  end
39
41
  end
40
42
 
43
+ if options[:main_files]
44
+ main_files(options[:main_files])
45
+ end
46
+
47
+ instance_eval(&block) if block_given?
48
+
41
49
  normalized_group_path = normalize_location_path(group.first, group_assets_path(group))
42
50
  @dependencies[normalized_group_path] ||= {}
43
51
  @dependencies[normalized_group_path][current_dependency_group_normalized] ||= {}
@@ -116,6 +124,14 @@ module BowerRails
116
124
  end
117
125
  end
118
126
 
127
+ # accepts string or array to alter main option for bower.json
128
+ def main_files(value = nil)
129
+ if value
130
+ @main_files[@asset_name] = Array(value)
131
+ end
132
+ @main_files
133
+ end
134
+
119
135
  private
120
136
 
121
137
  # Stores the dependency group name in the stack
@@ -157,11 +157,9 @@ module BowerRails
157
157
 
158
158
  # Parse bower.json
159
159
  bower_json = JSON.parse(bower_file)
160
- main_files = bower_json['main']
161
- next unless main_files
162
-
163
- # Handle singular or multiple files
164
- main_files = [main_files] unless main_files.is_a?(Array)
160
+ component_name = component_dir.split('/').last
161
+ main_files = Array(bower_json['main']) + main_files_for_component(component_name)
162
+ next if main_files.empty?
165
163
 
166
164
  # Remove "./" relative path from main file strings
167
165
  main_files.map! { |file| File.join(component_dir, file.gsub(/^\.\//, '')) }
@@ -194,5 +192,10 @@ module BowerRails
194
192
  nil
195
193
  end
196
194
 
195
+ private
196
+
197
+ def main_files_for_component(name)
198
+ Array(dsl.main_files[name])
199
+ end
197
200
  end
198
- end
201
+ end
File without changes
@@ -1,4 +1,4 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module BowerRails
3
- VERSION = "0.9.2"
3
+ VERSION = "0.10.0"
4
4
  end
@@ -10,7 +10,10 @@ BowerRails.configure do |bower_rails|
10
10
 
11
11
  # Invokes rake bower:clean before precompilation. Defaults to false
12
12
  # bower_rails.clean_before_precompile = true
13
-
13
+
14
14
  # Invokes rake bower:install:deployment instead rake bower:install. Defaults to false
15
15
  # bower_rails.use_bower_install_deployment = true
16
+ #
17
+ # Invokes rake bower:install and rake bower:install:deployment with -F (force) flag. Defaults to false
18
+ # bower_rails.force_install = true
16
19
  end
@@ -86,7 +86,7 @@ namespace :bower do
86
86
 
87
87
  task :before_precompile do
88
88
  BowerRails.tasks.each do |task|
89
- Rake::Task[task].invoke
89
+ Rake.application.invoke_task(task)
90
90
  end
91
91
  end
92
92
  end
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.9.2
4
+ version: 0.10.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.2.2
93
+ rubygems_version: 2.4.7
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Bower for Rails