jbundle 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -3
- data/README.md +15 -0
- data/bin/jbundle +1 -8
- data/jbundle.gemspec +2 -0
- data/lib/jbundle/command_line.rb +51 -0
- data/lib/jbundle/server.rb +28 -0
- data/lib/jbundle/version.rb +1 -1
- data/lib/jbundle.rb +7 -1
- data/spec/jbundle_spec.rb +0 -2
- data/spec/server_spec.rb +41 -0
- data/spec/spec_helper.rb +3 -0
- metadata +29 -30
data/Gemfile.lock
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jbundle (0.0.
|
4
|
+
jbundle (0.0.10)
|
5
5
|
closure-compiler
|
6
|
+
rack
|
7
|
+
thor
|
6
8
|
|
7
9
|
GEM
|
8
10
|
remote: http://rubygems.org/
|
9
11
|
specs:
|
10
|
-
closure-compiler (
|
12
|
+
closure-compiler (1.1.1)
|
13
|
+
rack (1.3.0)
|
11
14
|
rspec (1.3.1)
|
15
|
+
thor (0.14.6)
|
12
16
|
|
13
17
|
PLATFORMS
|
14
18
|
ruby
|
15
19
|
|
16
20
|
DEPENDENCIES
|
17
21
|
bundler (>= 1.0.0)
|
18
|
-
closure-compiler
|
19
22
|
jbundle!
|
20
23
|
rspec (= 1.3.1)
|
data/README.md
CHANGED
@@ -155,7 +155,22 @@ If you want a prerelease not to overwrite the previous point release, suffix it
|
|
155
155
|
|
156
156
|
version '1.0.1-pre'
|
157
157
|
|
158
|
+
## Test server
|
158
159
|
|
160
|
+
JBundle command-line comes with a built-in Rack server that makes it easy to test you JavaScript bundles as you develop them.
|
161
|
+
|
162
|
+
jbundle server
|
163
|
+
|
164
|
+
Starting test server on http://localhost:5555. Available bundles:
|
165
|
+
- /foo.js
|
166
|
+
|
167
|
+
That serves bundles defined in your JFile in port 5555. Pass the -p option for a different port.
|
168
|
+
|
169
|
+
Learn more about the JBundle command-line with
|
170
|
+
|
171
|
+
jbundle help # all commands
|
172
|
+
jbundle help server # server command options
|
173
|
+
|
159
174
|
## TODO
|
160
175
|
|
161
176
|
- DRY up stuff, better error handling for missing config
|
data/bin/jbundle
CHANGED
data/jbundle.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_development_dependency "bundler", ">= 1.0.0"
|
18
18
|
s.add_development_dependency "rspec", '1.3.1'
|
19
19
|
s.add_dependency 'closure-compiler'
|
20
|
+
s.add_dependency 'thor'
|
21
|
+
s.add_dependency 'rack'
|
20
22
|
|
21
23
|
s.files = `git ls-files`.split("\n")
|
22
24
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'thor'
|
2
|
+
module JBundle
|
3
|
+
|
4
|
+
class CommandLine < Thor
|
5
|
+
default_task :bundle
|
6
|
+
|
7
|
+
map "s" => :server
|
8
|
+
map "-v" => :version
|
9
|
+
|
10
|
+
desc "bundle", "Minify and bundle bundle declarations into dist directory"
|
11
|
+
def bundle
|
12
|
+
begin
|
13
|
+
JBundle.config_from_file(JBundle::JFILE)
|
14
|
+
JBundle.write!
|
15
|
+
rescue JBundle::NoJFileError => boom
|
16
|
+
puts boom.message
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'server', 'Start test rack server on port 5555'
|
21
|
+
method_option :port, :default => "5555", :aliases => "-p"
|
22
|
+
def server
|
23
|
+
require 'rack'
|
24
|
+
JBundle.config_from_file(JBundle::JFILE)
|
25
|
+
puts "Starting test server on http://localhost:#{options[:port]}. Available bundles:"
|
26
|
+
JBundle.config.bundles_and_files.each do |f|
|
27
|
+
puts "- /#{f.name}"
|
28
|
+
end
|
29
|
+
|
30
|
+
handler = Rack::Handler.default
|
31
|
+
downward = false
|
32
|
+
['INT', 'TERM', 'QUIT'].each do |signal|
|
33
|
+
trap(signal) do
|
34
|
+
exit! if downward
|
35
|
+
downward = true
|
36
|
+
handler.shutdown if handler.respond_to?(:shutdown)
|
37
|
+
Process.wait rescue nil
|
38
|
+
puts 'Shutting down test server'
|
39
|
+
exit!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
handler.run JBundle::Server.new, {:Port => options[:port]}
|
43
|
+
end
|
44
|
+
|
45
|
+
desc 'version', 'Print installed JBundle version'
|
46
|
+
def version
|
47
|
+
puts JBundle::VERSION
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module JBundle
|
2
|
+
|
3
|
+
class Server
|
4
|
+
|
5
|
+
|
6
|
+
def initialize(jfile = JBundle::JFILE)
|
7
|
+
@jfile = jfile
|
8
|
+
end
|
9
|
+
|
10
|
+
# Configure JBundle on every request.
|
11
|
+
# Expensive but allows for reloading changes to JFile
|
12
|
+
def call(env)
|
13
|
+
bundle_name = env['PATH_INFO'].sub('/', '')
|
14
|
+
begin
|
15
|
+
JBundle.config_from_file(@jfile)
|
16
|
+
[200, {'Content-Type' => 'application/x-javascript'}, [JBundle.build(bundle_name).src]]
|
17
|
+
rescue NoBundleError => boom
|
18
|
+
p = bundle_name == '' ? '[bundle_name].js' : bundle_name
|
19
|
+
[404, {'Content-Type' => 'text/plain'}, ["No bundle defined. Try defining /#{p} in your JFile"]]
|
20
|
+
rescue NoJFileError => boom
|
21
|
+
[404, {'Content-Type' => 'text/plain'}, [boom.message]]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
data/lib/jbundle/version.rb
CHANGED
data/lib/jbundle.rb
CHANGED
@@ -4,10 +4,16 @@ require 'jbundle/file'
|
|
4
4
|
require 'jbundle/bundle'
|
5
5
|
require 'jbundle/builder'
|
6
6
|
require 'jbundle/writer'
|
7
|
+
require 'jbundle/command_line'
|
8
|
+
require 'jbundle/server'
|
9
|
+
require 'jbundle/version'
|
7
10
|
|
8
11
|
module JBundle
|
9
12
|
|
13
|
+
JFILE = 'Jfile'
|
14
|
+
|
10
15
|
class NoJFileError < StandardError;end
|
16
|
+
class NoBundleError < StandardError;end
|
11
17
|
|
12
18
|
class << self
|
13
19
|
|
@@ -45,7 +51,7 @@ module JBundle
|
|
45
51
|
|
46
52
|
def build(name)
|
47
53
|
found = config.bundles_and_files.detect {|f| f.name == name}
|
48
|
-
raise "No bundle or file found with name #{name}" unless found
|
54
|
+
raise NoBundleError, "No bundle or file found with name #{name}" unless found
|
49
55
|
Builder.new(config).build_one found
|
50
56
|
end
|
51
57
|
|
data/spec/jbundle_spec.rb
CHANGED
data/spec/server_spec.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
|
4
|
+
describe "JBundle::Server" do
|
5
|
+
|
6
|
+
before do
|
7
|
+
f = File.join(File.expand_path(File.dirname(__FILE__)), 'JFile')
|
8
|
+
@server = JBundle::Server.new(f)
|
9
|
+
end
|
10
|
+
|
11
|
+
describe '#call' do
|
12
|
+
before do
|
13
|
+
@response = @server.call({'PATH_INFO' => '/foo.js'})
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should be 404 if no JFile found' do
|
17
|
+
s = JBundle::Server.new("doesn-not-exist")
|
18
|
+
r = s.call({'PATH_INFO' => '/foo.js'})
|
19
|
+
r[0].should == 404
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should be 200 OK' do
|
23
|
+
@response[0].should == 200
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should be a javascript response' do
|
27
|
+
@response[1]['Content-Type'].should == 'application/x-javascript'
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should return content for given bundle' do
|
31
|
+
@response[2].should == [JBundle.build('foo.js').src]
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should be 404 when no bundle found' do
|
35
|
+
r = @server.call({'PATH_INFO' => '/nonexisting.js'})
|
36
|
+
r[0].should == 404
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jbundle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 9
|
10
|
-
version: 0.0.9
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.10
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Ismael Celis
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-
|
13
|
+
date: 2011-05-30 00:00:00 +01:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,11 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 23
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 0
|
33
|
-
- 0
|
34
24
|
version: 1.0.0
|
35
25
|
type: :development
|
36
26
|
version_requirements: *id001
|
@@ -42,11 +32,6 @@ dependencies:
|
|
42
32
|
requirements:
|
43
33
|
- - "="
|
44
34
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 25
|
46
|
-
segments:
|
47
|
-
- 1
|
48
|
-
- 3
|
49
|
-
- 1
|
50
35
|
version: 1.3.1
|
51
36
|
type: :development
|
52
37
|
version_requirements: *id002
|
@@ -58,12 +43,31 @@ dependencies:
|
|
58
43
|
requirements:
|
59
44
|
- - ">="
|
60
45
|
- !ruby/object:Gem::Version
|
61
|
-
hash: 3
|
62
|
-
segments:
|
63
|
-
- 0
|
64
46
|
version: "0"
|
65
47
|
type: :runtime
|
66
48
|
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: thor
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :runtime
|
59
|
+
version_requirements: *id004
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rack
|
62
|
+
prerelease: false
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
type: :runtime
|
70
|
+
version_requirements: *id005
|
67
71
|
description: Writes versioned, bundled and minified javascript files and dependencies
|
68
72
|
email:
|
69
73
|
- ismaelct@gmail.com
|
@@ -84,13 +88,16 @@ files:
|
|
84
88
|
- lib/jbundle.rb
|
85
89
|
- lib/jbundle/builder.rb
|
86
90
|
- lib/jbundle/bundle.rb
|
91
|
+
- lib/jbundle/command_line.rb
|
87
92
|
- lib/jbundle/config.rb
|
88
93
|
- lib/jbundle/file.rb
|
94
|
+
- lib/jbundle/server.rb
|
89
95
|
- lib/jbundle/version.rb
|
90
96
|
- lib/jbundle/writer.rb
|
91
97
|
- spec/.rspec
|
92
98
|
- spec/JFile
|
93
99
|
- spec/jbundle_spec.rb
|
100
|
+
- spec/server_spec.rb
|
94
101
|
- spec/spec_helper.rb
|
95
102
|
- spec/test_src/file1.js
|
96
103
|
- spec/test_src/file2.js
|
@@ -114,25 +121,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
121
|
requirements:
|
115
122
|
- - ">="
|
116
123
|
- !ruby/object:Gem::Version
|
117
|
-
hash: 3
|
118
|
-
segments:
|
119
|
-
- 0
|
120
124
|
version: "0"
|
121
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
126
|
none: false
|
123
127
|
requirements:
|
124
128
|
- - ">="
|
125
129
|
- !ruby/object:Gem::Version
|
126
|
-
hash: 23
|
127
|
-
segments:
|
128
|
-
- 1
|
129
|
-
- 3
|
130
|
-
- 6
|
131
130
|
version: 1.3.6
|
132
131
|
requirements: []
|
133
132
|
|
134
133
|
rubyforge_project: jbundle
|
135
|
-
rubygems_version: 1.
|
134
|
+
rubygems_version: 1.6.2
|
136
135
|
signing_key:
|
137
136
|
specification_version: 3
|
138
137
|
summary: Good for releasing javascript libraries composed of many files. Writes files apt for deploying to CDNs.
|