jbundle 0.1.0 → 0.1.1

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.1.0)
4
+ jbundle (0.1.1)
5
5
  closure-compiler
6
6
  rack
7
7
  thor
data/README.md CHANGED
@@ -84,13 +84,13 @@ You can bundle licenses in bundles. Licenses will not be minified even though th
84
84
 
85
85
  All defined filters will run on the src for all these cases.
86
86
 
87
- ## Versiones file names, jQuery style
87
+ ## Versioned file names, jQuery style
88
88
 
89
89
  All of the examples above bundle to versioned directories in the "dist" directory. If you want jQuery-style file names, where there's no version directory and the version number is part of the file name, you can do this:
90
90
 
91
91
  version '1.6.1', :directory => false
92
92
 
93
- bundle 'foo2-[:version].js' do
93
+ bundle 'foo.js' => 'foo2-[:version].js' do
94
94
  license 'license.txt'
95
95
  file 'file3.js'
96
96
  file 'file4.js'
data/lib/jbundle.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  require 'fileutils'
2
2
  require 'jbundle/config'
3
+ require 'jbundle/bundle_utils'
3
4
  require 'jbundle/file'
4
5
  require 'jbundle/bundle'
5
6
  require 'jbundle/builder'
6
7
  require 'jbundle/writer'
7
- require 'jbundle/command_line'
8
8
  require 'jbundle/server'
9
9
  require 'jbundle/version'
10
10
 
@@ -76,3 +76,5 @@ module JBundle
76
76
  self.logger = lambda {|msg| puts "#{msg}\n"}
77
77
 
78
78
  end
79
+
80
+ require 'jbundle/command_line'
@@ -3,11 +3,12 @@ module JBundle
3
3
  class Bundle
4
4
 
5
5
  include Enumerable
6
+ include JBundle::BundleUtils
6
7
 
7
8
  attr_reader :name, :original_name, :licenses
8
9
 
9
10
  def initialize(name)
10
- @name = @original_name = name.to_s
11
+ @original_name, @name = parse_name(name)
11
12
  @files = []
12
13
  @licenses = []
13
14
  end
@@ -0,0 +1,17 @@
1
+ module JBundle
2
+
3
+ module BundleUtils
4
+
5
+ protected
6
+
7
+ def parse_name(name)
8
+ if name.is_a?(Hash)
9
+ name.first
10
+ else
11
+ [name, name]
12
+ end
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -11,9 +11,10 @@ module JBundle
11
11
  map "-v" => :version
12
12
 
13
13
  desc "bundle", "Minify and bundle bundle declarations into dist directory"
14
+ method_option :jfile, :default => JBundle::JFILE, :aliases => "-j"
14
15
  def bundle
15
16
  begin
16
- JBundle.config_from_file(JBundle::JFILE)
17
+ JBundle.config_from_file(options[:jfile])
17
18
  JBundle.write!
18
19
  rescue JBundle::NoJFileError => boom
19
20
  puts boom.message
@@ -22,12 +23,13 @@ module JBundle
22
23
 
23
24
  desc 'server', 'Start test rack server on port 5555'
24
25
  method_option :port, :default => "5555", :aliases => "-p"
26
+ method_option :jfile, :default => JBundle::JFILE, :aliases => "-j"
25
27
  def server
26
28
  require 'rack'
27
- JBundle.config_from_file(JBundle::JFILE)
28
- puts "Starting test server on http://localhost:#{options[:port]}. Available bundles:"
29
+ JBundle.config_from_file(options[:jfile])
30
+ say "Starting test server on http://localhost:#{options[:port]}. Available bundles:", :yellow
29
31
  JBundle.config.bundles_and_files.each do |f|
30
- puts "- /#{f.name}"
32
+ say "- /#{f.name}", :green
31
33
  end
32
34
 
33
35
  handler = Rack::Handler.default
@@ -38,7 +40,7 @@ module JBundle
38
40
  downward = true
39
41
  handler.shutdown if handler.respond_to?(:shutdown)
40
42
  Process.wait rescue nil
41
- puts 'Shutting down test server'
43
+ say 'Shutting down test server', :yellow
42
44
  exit!
43
45
  end
44
46
  end
@@ -47,7 +49,7 @@ module JBundle
47
49
 
48
50
  desc 'version', 'Print installed JBundle version'
49
51
  def version
50
- puts JBundle::VERSION
52
+ say JBundle::VERSION, :green
51
53
  end
52
54
 
53
55
  def self.source_root
@@ -32,13 +32,13 @@ module JBundle
32
32
  @target_dir || './'
33
33
  end
34
34
 
35
- def bundle(name, &block)
36
- name = name.to_sym
35
+ def bundle(names, &block)
36
+ name = (names.is_a?(Hash) ? names.keys.first : names).to_sym
37
37
  if !b = @bundles.detect{|a| a.name == name}
38
- b = Bundle.new(name)
38
+ b = Bundle.new(names)
39
39
  @bundles << b
40
40
  end
41
- b.instance_eval &block
41
+ b.instance_eval &block if block_given?
42
42
  b
43
43
  end
44
44
 
data/lib/jbundle/file.rb CHANGED
@@ -3,6 +3,7 @@ module JBundle
3
3
  class File
4
4
 
5
5
  include Enumerable
6
+ include JBundle::BundleUtils
6
7
 
7
8
  attr_reader :name, :original_name
8
9
 
@@ -14,16 +15,6 @@ module JBundle
14
15
  yield original_name
15
16
  end
16
17
 
17
- protected
18
-
19
- def parse_name(name)
20
- if name.is_a?(Hash)
21
- name.first
22
- else
23
- [name, name]
24
- end
25
- end
26
-
27
18
  end
28
19
 
29
20
  end
@@ -1,3 +1,3 @@
1
1
  module JBundle
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -48,7 +48,6 @@ module JBundle
48
48
 
49
49
  def write
50
50
  release_targets do |versioned_target, version_string|
51
- puts versioned_target.inspect
52
51
  if @compiler.buildable? # versionable JS file
53
52
  @out << write_file(
54
53
  @compiler.src,
data/spec/jbundle_spec.rb CHANGED
@@ -130,7 +130,7 @@ describe 'JBundle', 'with no versioned directory and version in bundle name' do
130
130
  src_dir ::File.dirname(__FILE__) + '/test_src'
131
131
  target_dir DIST
132
132
 
133
- bundle 'foo-[:version].js' do
133
+ bundle 'foo.js' => 'foo-[:version].js' do
134
134
  license 'license.txt'
135
135
  file 'file3.js'
136
136
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jbundle
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ismael Celis
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-01 00:00:00 +01:00
13
+ date: 2011-06-02 00:00:00 +01:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -88,6 +88,7 @@ files:
88
88
  - lib/jbundle.rb
89
89
  - lib/jbundle/builder.rb
90
90
  - lib/jbundle/bundle.rb
91
+ - lib/jbundle/bundle_utils.rb
91
92
  - lib/jbundle/command_line.rb
92
93
  - lib/jbundle/config.rb
93
94
  - lib/jbundle/file.rb