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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jbundle (0.0.1)
4
+ jbundle (0.0.3)
5
5
  closure-compiler
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -34,6 +34,8 @@ Then write them to the configured target directory
34
34
 
35
35
  JBundle.write!
36
36
 
37
+ JBundle.write! returns an array of paths of all files written.
38
+
37
39
  This will write the following files:
38
40
 
39
41
  'dist/1.6.1/foo.js'
@@ -1,3 +1,3 @@
1
1
  module JBundle
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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 @compiler.src, ::File.join(@target_dir, version_dir), @compiler.name
44
- write_file @compiler.min, ::File.join(@target_dir, version_dir), @compiler.min_name
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 @compiler.src_path, ::File.join(@target_dir, version_dir, @compiler.name)
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
- path = ::File.join(dir_name, file_name)
61
- JBundle.log("Writing to #{path}")
62
- ::File.open(path, 'w') do |f|
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
@@ -32,9 +32,9 @@ module JBundle
32
32
  end
33
33
 
34
34
  def write!
35
- output.each do |compiler|
35
+ output.map do |compiler|
36
36
  Writer.new(compiler, config.version, config.target_dir || './dist').write
37
- end
37
+ end.flatten
38
38
  end
39
39
 
40
40
  def build(name)
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ismael Celis