bunch 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bunch.gemspec +4 -4
- data/lib/bunch/cli.rb +28 -15
- data/lib/bunch/coffee_node.rb +1 -1
- data/lib/bunch/directory_node.rb +1 -1
- data/lib/bunch/file_node.rb +1 -1
- data/lib/bunch/rack.rb +1 -1
- data/lib/bunch/sass_node.rb +1 -1
- data/lib/bunch/version.rb +1 -1
- metadata +10 -10
data/bunch.gemspec
CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "bunch"
|
7
7
|
s.version = Bunch::VERSION
|
8
8
|
s.authors = ["Ryan Fitzgerald"]
|
9
|
-
s.email = ["
|
10
|
-
s.homepage = "
|
11
|
-
s.summary = %q{
|
12
|
-
s.description = %q{
|
9
|
+
s.email = ["rfitz@academia.edu"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{Directory-structure-based asset bundling.}
|
12
|
+
s.description = %q{Directory-structure-based asset bundling.}
|
13
13
|
|
14
14
|
s.rubyforge_project = "bunch"
|
15
15
|
|
data/lib/bunch/cli.rb
CHANGED
@@ -4,9 +4,23 @@ module Bunch
|
|
4
4
|
@input = Pathname.new(input)
|
5
5
|
@output = output ? Pathname.new(output) : nil
|
6
6
|
@opts = opts
|
7
|
+
|
8
|
+
if @opts[:server]
|
9
|
+
run_server
|
10
|
+
else
|
11
|
+
generate_files
|
12
|
+
end
|
7
13
|
end
|
8
14
|
|
9
|
-
def
|
15
|
+
def run_server
|
16
|
+
require 'rack'
|
17
|
+
::Rack::Handler::WEBrick.run(Bunch::Rack.new(@input), :Port => 3001)
|
18
|
+
rescue LoadError
|
19
|
+
$stderr.puts "ERROR: 'gem install rack' to run Bunch in server mode."
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_files
|
10
24
|
tree = Bunch::Tree(@input.to_s)
|
11
25
|
|
12
26
|
if @output
|
@@ -15,7 +29,7 @@ module Bunch
|
|
15
29
|
|
16
30
|
if @opts[:all]
|
17
31
|
if @output
|
18
|
-
write(
|
32
|
+
write("all.#{tree.target_extension}", tree.contents)
|
19
33
|
else
|
20
34
|
puts tree.contents
|
21
35
|
end
|
@@ -23,14 +37,14 @@ module Bunch
|
|
23
37
|
|
24
38
|
if @opts[:individual]
|
25
39
|
tree.children.each do |child|
|
26
|
-
write(
|
40
|
+
write("#{child.name}.#{child.target_extension}", child.contents)
|
27
41
|
end
|
28
42
|
end
|
29
43
|
end
|
30
44
|
|
31
45
|
private
|
32
46
|
def write(fn, contents)
|
33
|
-
File.open(fn, 'w') { |f| f.write(contents) }
|
47
|
+
File.open(@output.join(fn), 'w') { |f| f.write(contents) }
|
34
48
|
end
|
35
49
|
end
|
36
50
|
|
@@ -39,37 +53,36 @@ module Bunch
|
|
39
53
|
opts = Slop.parse! do
|
40
54
|
banner 'Usage: bunch [options] INPUT_PATH [OUTPUT_PATH]'
|
41
55
|
|
56
|
+
on :s, :server, 'Instead of creating files, use WEBrick to serve files from INPUT_PATH'
|
42
57
|
on :i, :individual, 'Create one output file for each file or directory in the input path (default)', :default => true
|
43
58
|
on :a, :all, 'Create an all.[extension] file combining all inputs'
|
44
59
|
on :h, :help, 'Show this message' do
|
45
|
-
|
60
|
+
puts self
|
61
|
+
exit
|
46
62
|
end
|
47
63
|
end
|
48
64
|
|
49
65
|
if ARGV.count < 1
|
50
|
-
$stderr.puts "ERROR: Must give an input path."
|
51
66
|
display_help = true
|
67
|
+
raise "Must give an input path."
|
52
68
|
end
|
53
69
|
|
54
|
-
if ARGV.count < 2 && opts[:individual]
|
55
|
-
$stderr.puts "ERROR: Must give an output path unless --no-individual is provided."
|
70
|
+
if ARGV.count < 2 && opts[:individual] && !opts[:server]
|
56
71
|
display_help = true
|
57
|
-
|
58
|
-
|
59
|
-
if display_help
|
60
|
-
$stderr.puts "\n#{opts}"
|
61
|
-
exit
|
72
|
+
raise "Must give an output path unless --no-individual or --server is provided."
|
62
73
|
end
|
63
74
|
|
64
75
|
input = ARGV.shift
|
65
76
|
output = ARGV.shift
|
66
77
|
|
67
|
-
CLI.new(input, output, opts)
|
68
|
-
rescue
|
78
|
+
CLI.new(input, output, opts)
|
79
|
+
rescue => e
|
69
80
|
if ENV['BUNCH_DEBUG']
|
70
81
|
raise
|
71
82
|
else
|
72
83
|
$stderr.puts "ERROR: #{e.message}"
|
84
|
+
$stderr.puts "\n#{opts}" if display_help
|
85
|
+
exit 1
|
73
86
|
end
|
74
87
|
end
|
75
88
|
end
|
data/lib/bunch/coffee_node.rb
CHANGED
data/lib/bunch/directory_node.rb
CHANGED
data/lib/bunch/file_node.rb
CHANGED
data/lib/bunch/rack.rb
CHANGED
@@ -17,7 +17,7 @@ module Bunch
|
|
17
17
|
def generate(path)
|
18
18
|
if File.exist?(path)
|
19
19
|
Bunch::Tree(path).contents
|
20
|
-
elsif File.exist?(chopped_path = path.sub(%r(\.[
|
20
|
+
elsif File.exist?(chopped_path = path.sub(%r(\.[^.]*$), ''))
|
21
21
|
Bunch::Tree(chopped_path).contents
|
22
22
|
elsif File.basename(path).start_with?('all.')
|
23
23
|
Bunch::Tree(File.dirname(path)).contents
|
data/lib/bunch/sass_node.rb
CHANGED
data/lib/bunch/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mime-types
|
16
|
-
requirement: &
|
16
|
+
requirement: &70119922351140 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70119922351140
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: slop
|
27
|
-
requirement: &
|
27
|
+
requirement: &70119922350720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
36
|
-
description:
|
35
|
+
version_requirements: *70119922350720
|
36
|
+
description: Directory-structure-based asset bundling.
|
37
37
|
email:
|
38
|
-
-
|
38
|
+
- rfitz@academia.edu
|
39
39
|
executables:
|
40
40
|
- bunch
|
41
41
|
extensions: []
|
@@ -72,7 +72,7 @@ files:
|
|
72
72
|
- lib/bunch/rack.rb
|
73
73
|
- lib/bunch/sass_node.rb
|
74
74
|
- lib/bunch/version.rb
|
75
|
-
homepage:
|
75
|
+
homepage: ''
|
76
76
|
licenses: []
|
77
77
|
post_install_message:
|
78
78
|
rdoc_options: []
|
@@ -95,6 +95,6 @@ rubyforge_project: bunch
|
|
95
95
|
rubygems_version: 1.8.10
|
96
96
|
signing_key:
|
97
97
|
specification_version: 3
|
98
|
-
summary:
|
98
|
+
summary: Directory-structure-based asset bundling.
|
99
99
|
test_files: []
|
100
100
|
has_rdoc:
|