jbundle 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jbundle (0.0.5)
4
+ jbundle (0.0.7)
5
5
  closure-compiler
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -114,6 +114,16 @@ You can run arbitrary code after writing all versioned files by registering an a
114
114
  end
115
115
 
116
116
  config.version.releaseble returns an array with with all created versions (ie. ['1.6.1', '1.6'] or just ['1.6.1-pre'] for prereleases).
117
+
118
+ Files in subdirectories in the src directory will keep the local directory tree, so
119
+
120
+ file 'foo/text.txt'
121
+
122
+ Ends up as ./dist/1.6/foo/text.txt and ./dist/1.6.1/foo/text.txt
123
+
124
+ You can also copy to a different file name in the target directory using hash notation
125
+
126
+ file 'foo/text.txt' => 'bar.txt'
117
127
 
118
128
  ## Pre-releases
119
129
 
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
8
8
  s.authors = ['Ismael Celis']
9
9
  s.email = ['ismaelct@gmail.com']
10
10
  s.homepage = "http://github.com/ismasan/jbundle"
11
- s.summary = "Writes versioned, bundled and minified javascript files and dependencies"
12
- s.description = "Good for releasing javascript libraries composed of many files. Writes files apt for deploying to CDNs."
11
+ s.description = "Writes versioned, bundled and minified javascript files and dependencies"
12
+ s.summary = "Good for releasing javascript libraries composed of many files. Writes files apt for deploying to CDNs."
13
13
 
14
14
  s.required_rubygems_version = ">= 1.3.6"
15
15
  s.rubyforge_project = "jbundle"
@@ -6,10 +6,11 @@ module JBundle
6
6
 
7
7
  BUILDABLE_FILES = ['.js']
8
8
 
9
- attr_reader :name, :src_dir
9
+ attr_reader :name, :src_dir, :dir
10
10
 
11
11
  def initialize(name, file_list, src_dir = 'src')
12
- @name, @file_list, @src_dir = name.to_s, file_list, src_dir
12
+ @file_list, @src_dir = file_list, src_dir
13
+ @name, @dir = parse_name(name)
13
14
  end
14
15
 
15
16
  def buildable?
@@ -18,7 +19,7 @@ module JBundle
18
19
 
19
20
  # This only makes sense for one-file objects
20
21
  def src_path
21
- ::File.join(@src_dir, name)
22
+ ::File.join(@src_dir, @file_list.original_name)
22
23
  end
23
24
 
24
25
  def src
@@ -58,6 +59,12 @@ module JBundle
58
59
  end
59
60
  end
60
61
 
62
+ def parse_name(name)
63
+ n = ::File.basename(name)
64
+ d = ::File.dirname(name) if name =~ /\//
65
+ [n,d]
66
+ end
67
+
61
68
  end
62
69
 
63
70
 
@@ -4,10 +4,10 @@ module JBundle
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :name, :licenses
7
+ attr_reader :name, :original_name, :licenses
8
8
 
9
9
  def initialize(name)
10
- @name = name.to_s
10
+ @name = @original_name = name.to_s
11
11
  @files = []
12
12
  @licenses = []
13
13
  end
@@ -4,14 +4,24 @@ module JBundle
4
4
 
5
5
  include Enumerable
6
6
 
7
- attr_reader :name
7
+ attr_reader :name, :original_name
8
8
 
9
9
  def initialize(name)
10
- @name = name.to_s
10
+ @original_name, @name = parse_name(name)
11
11
  end
12
12
 
13
13
  def each(&block)
14
- yield name
14
+ yield original_name
15
+ end
16
+
17
+ protected
18
+
19
+ def parse_name(name)
20
+ if name.is_a?(Hash)
21
+ name.first
22
+ else
23
+ [name, name]
24
+ end
15
25
  end
16
26
 
17
27
  end
@@ -1,3 +1,3 @@
1
1
  module JBundle
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -44,11 +44,12 @@ module JBundle
44
44
 
45
45
  def write
46
46
  @version.releaseable.each do |version_dir|
47
+ versioned_target = ::File.join(@target_dir, version_dir)
47
48
  if @compiler.buildable?
48
- @out << write_file(@compiler.src, ::File.join(@target_dir, version_dir), @compiler.name)
49
- @out << write_file(@compiler.min, ::File.join(@target_dir, version_dir), @compiler.min_name)
49
+ @out << write_file(@compiler.src, versioned_target, @compiler.dir, @compiler.name)
50
+ @out << write_file(@compiler.min, versioned_target, @compiler.dir, @compiler.min_name)
50
51
  else
51
- @out << copy_file(@compiler.src_path, ::File.join(@target_dir, version_dir, @compiler.name))
52
+ @out << copy_file(@compiler.src_path, versioned_target, @compiler.dir, @compiler.name)
52
53
  end
53
54
  end
54
55
  @out
@@ -56,15 +57,19 @@ module JBundle
56
57
 
57
58
  protected
58
59
 
59
- def copy_file(src, target)
60
+ def copy_file(src, target, subdir, name)
61
+ sub = ::File.join([target, subdir].compact)
62
+ FileUtils.mkdir_p sub
63
+ target = ::File.join(sub, name)
60
64
  JBundle.log("Copying to #{target}")
61
65
  FileUtils.cp src, target
62
66
  target
63
67
  end
64
68
 
65
- def write_file(content, dir_name, file_name)
66
- FileUtils.mkdir_p dir_name
67
- target = ::File.join(dir_name, file_name)
69
+ def write_file(content, dir_name, subdir, file_name)
70
+ sub = ::File.join([dir_name, subdir].compact)
71
+ FileUtils.mkdir_p sub
72
+ target = ::File.join(sub, file_name)
68
73
  JBundle.log("Writing to #{target}")
69
74
  ::File.open(target, 'w') do |f|
70
75
  f.write content
data/spec/JFile CHANGED
@@ -18,6 +18,10 @@ file 'file4.js'
18
18
 
19
19
  file 'text.txt'
20
20
 
21
+ file 'nested/foo.txt'
22
+
23
+ file 'nested/foo.txt' => 'flat_foo.txt'
24
+
21
25
  filter do |src, config|
22
26
  src.gsub!(/<VERSION>/, config.version.full)
23
27
  end
@@ -26,7 +26,7 @@ describe "JBundle" do
26
26
  end
27
27
 
28
28
  it 'should bundle bundles' do
29
- JBundle.output.size.should == 4
29
+ JBundle.output.size.should == 6
30
30
  JBundle.output[0].name.should == 'foo.js'
31
31
  JBundle.output[0].src.should == "var VERSION = '1.6.1';\nvar a1 = 1;\nvar a2 = 2;\n"
32
32
  JBundle.output[0].min.should == "var VERSION=\"1.6.1\",a1=1,a2=2;\n"
@@ -71,6 +71,16 @@ describe "JBundle" do
71
71
  File.exist?(DIST + '/1.6/foo.txt').should be_true
72
72
  end
73
73
 
74
+ it 'should copy files in subdirectories' do
75
+ File.exist?(DIST + '/1.6.1/nested/foo.txt').should be_true
76
+ File.exist?(DIST + '/1.6/nested/foo.txt').should be_true
77
+ end
78
+
79
+ it 'should copy files to new names if hash given' do
80
+ File.exist?(DIST + '/1.6.1/flat_foo.txt').should be_true
81
+ File.exist?(DIST + '/1.6/flat_foo.txt').should be_true
82
+ end
83
+
74
84
  it 'should return a list of files written' do
75
85
  @written_files.should == [
76
86
  DIST + '/1.6.1/foo.js',
@@ -89,7 +99,13 @@ describe "JBundle" do
89
99
  DIST + '/1.6/file4.min.js',
90
100
 
91
101
  DIST + '/1.6.1/text.txt',
92
- DIST + '/1.6/text.txt'
102
+ DIST + '/1.6/text.txt',
103
+
104
+ DIST + '/1.6.1/nested/foo.txt',
105
+ DIST + '/1.6/nested/foo.txt',
106
+
107
+ DIST + '/1.6.1/flat_foo.txt',
108
+ DIST + '/1.6/flat_foo.txt'
93
109
  ]
94
110
  end
95
111
 
@@ -0,0 +1 @@
1
+ This file is in a nested subdirectory
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ismael Celis
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-19 00:00:00 -03:00
18
+ date: 2011-01-20 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -64,7 +64,7 @@ dependencies:
64
64
  version: "0"
65
65
  type: :runtime
66
66
  version_requirements: *id003
67
- description: Good for releasing javascript libraries composed of many files. Writes files apt for deploying to CDNs.
67
+ description: Writes versioned, bundled and minified javascript files and dependencies
68
68
  email:
69
69
  - ismaelct@gmail.com
70
70
  executables:
@@ -98,6 +98,7 @@ files:
98
98
  - spec/test_src/file4.js
99
99
  - spec/test_src/foo.txt
100
100
  - spec/test_src/license.txt
101
+ - spec/test_src/nested/foo.txt
101
102
  - spec/test_src/text.txt
102
103
  has_rdoc: true
103
104
  homepage: http://github.com/ismasan/jbundle
@@ -134,6 +135,6 @@ rubyforge_project: jbundle
134
135
  rubygems_version: 1.3.7
135
136
  signing_key:
136
137
  specification_version: 3
137
- summary: Writes versioned, bundled and minified javascript files and dependencies
138
+ summary: Good for releasing javascript libraries composed of many files. Writes files apt for deploying to CDNs.
138
139
  test_files: []
139
140