bower-rails 0.0.4 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -2
- data/lib/tasks/bower.rake +40 -19
- metadata +1 -1
data/README.md
CHANGED
data/lib/tasks/bower.rake
CHANGED
@@ -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
|
-
#
|
9
|
-
|
10
|
-
|
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
|
-
|
14
|
-
|
17
|
+
perform_command false do
|
18
|
+
system 'bower update'
|
19
|
+
end
|
15
20
|
end
|
16
21
|
end
|
17
22
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
28
|
-
|
29
|
-
#
|
30
|
-
|
31
|
-
|
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
|