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 +1 -1
- data/README.md +2 -2
- data/lib/jbundle.rb +3 -1
- data/lib/jbundle/bundle.rb +2 -1
- data/lib/jbundle/bundle_utils.rb +17 -0
- data/lib/jbundle/command_line.rb +8 -6
- data/lib/jbundle/config.rb +4 -4
- data/lib/jbundle/file.rb +1 -10
- data/lib/jbundle/version.rb +1 -1
- data/lib/jbundle/writer.rb +0 -1
- data/spec/jbundle_spec.rb +1 -1
- metadata +3 -2
data/Gemfile.lock
CHANGED
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
|
-
##
|
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'
|
data/lib/jbundle/bundle.rb
CHANGED
@@ -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
|
-
@
|
11
|
+
@original_name, @name = parse_name(name)
|
11
12
|
@files = []
|
12
13
|
@licenses = []
|
13
14
|
end
|
data/lib/jbundle/command_line.rb
CHANGED
@@ -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(
|
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(
|
28
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
52
|
+
say JBundle::VERSION, :green
|
51
53
|
end
|
52
54
|
|
53
55
|
def self.source_root
|
data/lib/jbundle/config.rb
CHANGED
@@ -32,13 +32,13 @@ module JBundle
|
|
32
32
|
@target_dir || './'
|
33
33
|
end
|
34
34
|
|
35
|
-
def bundle(
|
36
|
-
name =
|
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(
|
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
|
data/lib/jbundle/version.rb
CHANGED
data/lib/jbundle/writer.rb
CHANGED
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.
|
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-
|
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
|