bower-rails 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/MIT-LICENSE +0 -0
- data/README.md +54 -4
- data/lib/bower-rails.rb +6 -0
- data/lib/bower-rails/dsl.rb +17 -1
- data/lib/bower-rails/performer.rb +9 -6
- data/lib/bower-rails/railtie.rb +0 -0
- data/lib/bower-rails/version.rb +1 -1
- data/lib/generators/bower_rails/initialize/initialize_generator.rb +0 -0
- data/lib/generators/bower_rails/initialize/templates/Bowerfile +0 -0
- data/lib/generators/bower_rails/initialize/templates/bower.json +0 -0
- data/lib/generators/bower_rails/initialize/templates/bower_rails.rb +4 -1
- data/lib/tasks/bower.rake +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05faebea58423491bfd583dab2eca0b0ba062724
|
4
|
+
data.tar.gz: e63b4071d055ccd6b8c68898311c3fa794a02871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8683a3796762962d9d43030c2af460440b7cc25c45f6ef9b1f380797ba295878975346d6d076e6900d3a44737d2312e92f512e0ed774333057f25585100a0239
|
7
|
+
data.tar.gz: dece1f7c79ce74a344d30a56d1dd2b1e6e17336e20b07a0b69c6543f4da1e9a57051f39de3b04a2694f79b89cb0cc1040ba72cedbf6805e10ce23f631ebb5f8f
|
data/MIT-LICENSE
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -4,11 +4,11 @@ bower-rails
|
|
4
4
|
[][gem]
|
5
5
|
[][codeclimate]
|
6
6
|
[][gemnasium]
|
7
|
-
[][travis]
|
8
8
|
[][coveralls]
|
9
9
|
|
10
10
|
[gem]: https://rubygems.org/gems/bower-rails
|
11
|
-
[travis]: https://travis-ci.org/
|
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.
|
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)
|
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.
|
data/lib/bower-rails.rb
CHANGED
@@ -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
|
data/lib/bower-rails/dsl.rb
CHANGED
@@ -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
|
-
|
161
|
-
|
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
|
data/lib/bower-rails/railtie.rb
CHANGED
File without changes
|
data/lib/bower-rails/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
@@ -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
|
data/lib/tasks/bower.rake
CHANGED
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.
|
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.
|
93
|
+
rubygems_version: 2.4.7
|
94
94
|
signing_key:
|
95
95
|
specification_version: 4
|
96
96
|
summary: Bower for Rails
|