bower-rails 0.6.0 → 0.6.1

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -1
  3. data/lib/tasks/bower.rake +42 -13
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98d9ed52d0507bd2dcc3e78fefa66982aae28f3e
4
- data.tar.gz: c483f89a0b7509543f31ba6d4922c86dcc8d560a
3
+ metadata.gz: e4ef492a2a98874b7cada24b2c7ed2f07a8a3eef
4
+ data.tar.gz: b669749e25008d4156955d52737d802d76f942ef
5
5
  SHA512:
6
- metadata.gz: c2cf8e667c67755b5ff2f3694896f454c0286a56b4f84e7ba84dc9ae454f73d1bb482ea8e59b688c5ed455ad6b754736b4edf87a2df55f0a77faba097b688d32
7
- data.tar.gz: 120b78bc07539c8616b09843473b23807f8b97abaa7193227fd26f173c273f398110c0f7d6fc68504f695b737a13cce0fe26002f5d3c1b714a8283f140ac2224
6
+ metadata.gz: 46f2239173c06b472b628861afb68b52474f1e6513b56ea2be4cab21f0b7690541544bedec6496ceb0cc64bdfdce26d4afe1b063ebfbbc5952e1000974b1c5e9
7
+ data.tar.gz: de4a5b73737347a9b163492abcd9a756e41a847de7dda2f1a2895afd767beb98c605f35ff2c3d1a3d881d4949228d57d3e2848b274e4962eed7adacf873c3853
data/README.md CHANGED
@@ -20,7 +20,7 @@ Check out Changelog.md for the latest changes and releases.
20
20
  in Gemfile
21
21
 
22
22
  ``` Ruby
23
- gem "bower-rails", "~> 0.5.0"
23
+ gem "bower-rails", "~> 0.6.1"
24
24
  ```
25
25
 
26
26
  ##JSON configuration
@@ -117,6 +117,10 @@ If you provide a `.bowerrc` in the rails project root, bower-rails will use it f
117
117
  Some .bowerrc options are not supported: `directory`, `cwd`, and `interactive`. Bower-rails
118
118
  will ignore the `directory` property and instead will use the automatically generated asset path.
119
119
 
120
+ ###Bower Installation
121
+
122
+ [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.
123
+
120
124
  ##Relative asset paths
121
125
 
122
126
  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.
data/lib/tasks/bower.rake CHANGED
@@ -4,39 +4,39 @@ require 'pp'
4
4
  namespace :bower do
5
5
  desc "Install components from bower"
6
6
  task :install do
7
- perform do
8
- sh 'bower install'
7
+ perform do |bower|
8
+ sh "#{bower} install"
9
9
  end
10
10
  end
11
11
 
12
12
  namespace :install do
13
13
  desc "Install components with -F option"
14
14
  task :force do
15
- perform do
16
- sh 'bower install -F'
15
+ perform do |bower|
16
+ sh "#{bower} install -F"
17
17
  end
18
18
  end
19
19
  end
20
20
 
21
21
  desc "Update bower components"
22
22
  task :update do
23
- perform do
24
- sh 'bower update'
23
+ perform do |bower|
24
+ sh "#{bower} update"
25
25
  end
26
26
  end
27
27
 
28
28
  desc "List bower components"
29
29
  task :list do
30
- perform false do
31
- sh 'bower list'
30
+ perform false do |bower|
31
+ sh "#{bower} list"
32
32
  end
33
33
  end
34
34
 
35
35
  namespace :update do
36
36
  desc "Update existing components and uninstalls extraneous components"
37
37
  task :prune do
38
- perform do
39
- sh 'bower update && bower prune'
38
+ perform do |bower|
39
+ sh "#{bower} update && #{bower} prune"
40
40
  end
41
41
  end
42
42
  end
@@ -50,15 +50,31 @@ namespace :bower do
50
50
  end
51
51
 
52
52
  # Install bower assets before precompile
53
- Rake::Task['assets:precompile'].enhance ['bower:install', 'bower:resolve']
53
+ # Rake::Task['assets:precompile'].enhance ['bower:install', 'bower:resolve']
54
54
 
55
55
  def perform remove_components = true, &block
56
56
  entries = Dir.entries(get_bower_root_path)
57
57
 
58
+ npm_path = File.join(get_bower_root_path, 'node_modules', '.bin')
59
+ bower = find_command('bower', [npm_path])
60
+
61
+ if bower.nil?
62
+ $stderr.puts <<EOS
63
+ Bower not found! You can install Bower using Node and npm:
64
+ $ npm install bower -g
65
+ For more info see http://twitter.github.com/bower/
66
+ EOS
67
+ return
68
+ end
69
+
58
70
  if entries.include?('Bowerfile')
59
- dsl_perform_command remove_components, &block
71
+ dsl_perform_command remove_components do
72
+ yield bower if block_given?
73
+ end
60
74
  elsif entries.include?('bower.json')
61
- perform_command remove_components, &block
75
+ perform_command remove_components do
76
+ yield bower if block_given?
77
+ end
62
78
  else
63
79
  raise LoadError, "No Bowerfile or bower.json file found. Make sure you have it at the root of your project"
64
80
  end
@@ -171,3 +187,16 @@ def resolve_asset_paths
171
187
  end
172
188
  end
173
189
  end
190
+
191
+ # http://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
192
+ def find_command(cmd, paths = [])
193
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
194
+ paths += ENV['PATH'].split(File::PATH_SEPARATOR)
195
+ paths.each do |path|
196
+ exts.each do |ext|
197
+ exe = File.join(path, "#{cmd}#{ext}")
198
+ return exe if File.executable? exe
199
+ end
200
+ end
201
+ nil
202
+ 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.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ross Harrison