bower-rails 0.0.4 → 0.1.2

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 (3) hide show
  1. data/README.md +3 -2
  2. data/lib/tasks/bower.rake +40 -19
  3. metadata +1 -1
data/README.md CHANGED
@@ -28,8 +28,9 @@ in Gemfile
28
28
  ```
29
29
 
30
30
 
31
- **To install javascript files to correspondign directories**
31
+ **Available command
32
32
 
33
33
  ``` bash
34
- rake bower:install
34
+ rake bower:install #install js components
35
+ rake bower:update #update js components
35
36
  ```
@@ -4,29 +4,50 @@ require 'pp'
4
4
  namespace :bower do
5
5
 
6
6
  desc "install files from bower"
7
- task :install do
8
- #load in bower json file
9
- txt = File.read("#{Rails.root}/bower.json")
10
- json = JSON.parse(txt)
7
+ task :install do
8
+ #install to corresponding directories
9
+ perform_command do
10
+ system 'bower install'
11
+ end
12
+ end
11
13
 
14
+ desc "update bower packages"
15
+ task :update do
12
16
  #install to corresponding directories
13
- install_components "lib", json["lib"]
14
- install_components "vendor", json["vendor"]
17
+ perform_command false do
18
+ system 'bower update'
19
+ end
15
20
  end
16
21
  end
17
22
 
18
- def install_components dir, data = nil
19
- Dir.chdir("#{Rails.root}/#{dir}/assets/javascripts") do
20
- #remove old components
21
- FileUtils.rm_rf("components")
22
- #create component json
23
- File.open("component.json","w") do |f|
24
- f.write(data.to_json)
25
- end
23
+ #run the passed bower block in appropriate folders
24
+ def perform_command remove_components = true
25
+ #load in bower json file
26
+ txt = File.read("#{Rails.root}/bower.json")
27
+ json = JSON.parse(txt)
28
+
29
+ ["lib", "vendor"].each do |dir|
26
30
 
27
- #install
28
- %x[bower install]
29
- #remove component file
30
- FileUtils.rm("component.json")
31
- end if data
31
+ data = json[dir]
32
+
33
+ #go in to dir to act
34
+ Dir.chdir("#{Rails.root}/#{dir}/assets/javascripts") do
35
+
36
+ #remove old components
37
+ FileUtils.rm_rf("components") if remove_components
38
+
39
+ #create component json
40
+ File.open("component.json","w") do |f|
41
+ f.write(data.to_json)
42
+ end
43
+
44
+ #run command
45
+ yield
46
+
47
+ #remove component file
48
+ FileUtils.rm("component.json")
49
+
50
+ end if data
51
+
52
+ end
32
53
  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.0.4
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: