jbundle 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +2 -0
- data/lib/jbundle/version.rb +1 -1
- data/lib/jbundle/writer.rb +10 -6
- data/lib/jbundle.rb +2 -2
- data/spec/jbundle_spec.rb +24 -2
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
data/lib/jbundle/version.rb
CHANGED
data/lib/jbundle/writer.rb
CHANGED
@@ -35,17 +35,19 @@ module JBundle
|
|
35
35
|
|
36
36
|
def initialize(compiler, version, target_dir)
|
37
37
|
@compiler, @version, @target_dir = compiler, Version.new(version), target_dir
|
38
|
+
@out = []
|
38
39
|
end
|
39
40
|
|
40
41
|
def write
|
41
42
|
@version.releaseable.each do |version_dir|
|
42
43
|
if @compiler.buildable?
|
43
|
-
write_file
|
44
|
-
write_file
|
44
|
+
@out << write_file(@compiler.src, ::File.join(@target_dir, version_dir), @compiler.name)
|
45
|
+
@out << write_file(@compiler.min, ::File.join(@target_dir, version_dir), @compiler.min_name)
|
45
46
|
else
|
46
|
-
copy_file
|
47
|
+
@out << copy_file(@compiler.src_path, ::File.join(@target_dir, version_dir, @compiler.name))
|
47
48
|
end
|
48
49
|
end
|
50
|
+
@out
|
49
51
|
end
|
50
52
|
|
51
53
|
protected
|
@@ -53,15 +55,17 @@ module JBundle
|
|
53
55
|
def copy_file(src, target)
|
54
56
|
JBundle.log("Copying to #{target}")
|
55
57
|
FileUtils.cp src, target
|
58
|
+
target
|
56
59
|
end
|
57
60
|
|
58
61
|
def write_file(content, dir_name, file_name)
|
59
62
|
FileUtils.mkdir_p dir_name
|
60
|
-
|
61
|
-
JBundle.log("Writing to #{
|
62
|
-
::File.open(
|
63
|
+
target = ::File.join(dir_name, file_name)
|
64
|
+
JBundle.log("Writing to #{target}")
|
65
|
+
::File.open(target, 'w') do |f|
|
63
66
|
f.write content
|
64
67
|
end
|
68
|
+
target
|
65
69
|
end
|
66
70
|
|
67
71
|
end
|
data/lib/jbundle.rb
CHANGED
data/spec/jbundle_spec.rb
CHANGED
@@ -71,11 +71,10 @@ describe "JBundle" do
|
|
71
71
|
|
72
72
|
before do
|
73
73
|
FileUtils.rm_rf DIST
|
74
|
+
@written_files = JBundle.write!
|
74
75
|
end
|
75
76
|
|
76
77
|
it 'should write files' do
|
77
|
-
JBundle.write!
|
78
|
-
|
79
78
|
File.exist?(DIST + '/1.6.1/foo.js').should be_true
|
80
79
|
File.exist?(DIST + '/1.6.1/foo.min.js').should be_true
|
81
80
|
File.exist?(DIST + '/1.6.1/foo2.js').should be_true
|
@@ -94,6 +93,29 @@ describe "JBundle" do
|
|
94
93
|
File.exist?(DIST + '/1.6/text.txt').should be_true
|
95
94
|
File.exist?(DIST + '/1.6/text.min.txt').should be_false
|
96
95
|
end
|
96
|
+
|
97
|
+
it 'should return a list of files written' do
|
98
|
+
@written_files.should == [
|
99
|
+
DIST + '/1.6.1/foo.js',
|
100
|
+
DIST + '/1.6.1/foo.min.js',
|
101
|
+
DIST + '/1.6/foo.js',
|
102
|
+
DIST + '/1.6/foo.min.js',
|
103
|
+
|
104
|
+
DIST + '/1.6.1/foo2.js',
|
105
|
+
DIST + '/1.6.1/foo2.min.js',
|
106
|
+
DIST + '/1.6/foo2.js',
|
107
|
+
DIST + '/1.6/foo2.min.js',
|
108
|
+
|
109
|
+
DIST + '/1.6.1/file4.js',
|
110
|
+
DIST + '/1.6.1/file4.min.js',
|
111
|
+
DIST + '/1.6/file4.js',
|
112
|
+
DIST + '/1.6/file4.min.js',
|
113
|
+
|
114
|
+
DIST + '/1.6.1/text.txt',
|
115
|
+
DIST + '/1.6/text.txt'
|
116
|
+
]
|
117
|
+
end
|
118
|
+
|
97
119
|
end
|
98
120
|
|
99
121
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jbundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ismael Celis
|