bunch 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/bunch.rb CHANGED
@@ -24,6 +24,8 @@ end
24
24
  class << Bunch
25
25
  def Tree(fn)
26
26
  case
27
+ when !File.exist?(fn)
28
+ raise Errno::ENOENT, fn
27
29
  when File.directory?(fn)
28
30
  Bunch::DirectoryNode.new(fn)
29
31
  when fn =~ /\.coffee$/
@@ -35,3 +37,14 @@ class << Bunch
35
37
  end
36
38
  end
37
39
  end
40
+
41
+ #class Module
42
+ # def benchmark(meth)
43
+ # alias_method "#{meth}_old", meth
44
+ # define_method meth do |*args, &blk|
45
+ # t = Time.now
46
+ # send "#{meth}_old", *args, &blk
47
+ # STDERR.puts "Called #{meth} in #{Time.now - t}."
48
+ # end
49
+ # end
50
+ #end
data/lib/bunch/cli.rb CHANGED
@@ -5,6 +5,10 @@ module Bunch
5
5
  @output = output ? Pathname.new(output) : nil
6
6
  @opts = opts
7
7
 
8
+ if @opts[:profile]
9
+ require 'profile'
10
+ end
11
+
8
12
  if @opts[:server]
9
13
  run_server
10
14
  else
@@ -56,6 +60,7 @@ module Bunch
56
60
  on :s, :server, 'Instead of creating files, use WEBrick to serve files from INPUT_PATH'
57
61
  on :i, :individual, 'Create one output file for each file or directory in the input path (default)', :default => true
58
62
  on :a, :all, 'Create an all.[extension] file combining all inputs'
63
+ on :p, :profile
59
64
  on :h, :help, 'Show this message' do
60
65
  puts self
61
66
  exit
@@ -1,7 +1,10 @@
1
1
  module Bunch
2
2
  class CoffeeNode
3
3
  def initialize(fn)
4
- require 'coffee-script'
4
+ unless defined?(@@coffee_required)
5
+ require 'coffee-script'
6
+ @@coffee_required = true
7
+ end
5
8
  @filename = fn
6
9
  rescue LoadError
7
10
  raise "'gem install coffee-script' to compile .coffee files."
data/lib/bunch/rack.rb CHANGED
@@ -15,17 +15,24 @@ module Bunch
15
15
 
16
16
  private
17
17
  def generate(path)
18
- if File.exist?(path)
19
- Bunch::Tree(path).contents
20
- elsif File.exist?(chopped_path = path.sub(%r(\.[^.]*$), ''))
21
- Bunch::Tree(chopped_path).contents
22
- elsif File.basename(path).start_with?('all.')
23
- Bunch::Tree(File.dirname(path)).contents
18
+ case
19
+ when File.exist?(path)
20
+ contents(path)
21
+ when File.exist?(chopped_path = path.sub(%r(\.[^.]*$), ''))
22
+ contents(chopped_path)
23
+ when File.basename(path).start_with?('all.')
24
+ contents(File.dirname(path))
25
+ when (path_w_different_extension = Dir["#{chopped_path}.*"].first)
26
+ contents(path_w_different_extension)
24
27
  else
25
- raise Errno::ENOENT, path
28
+ raise Errno::ENOENT, path.to_s
26
29
  end
27
30
  end
28
31
 
32
+ def contents(path)
33
+ Bunch::Tree(path.to_s).contents
34
+ end
35
+
29
36
  def error_log(e)
30
37
  "#{e.class}: #{e.message}\n #{e.backtrace.join("\n ")}"
31
38
  end
@@ -1,7 +1,10 @@
1
1
  module Bunch
2
2
  class SassNode
3
3
  def initialize(fn)
4
- require 'sass'
4
+ unless defined?(@@sass_required)
5
+ require 'sass'
6
+ @@sass_required = true
7
+ end
5
8
  @filename = fn
6
9
  rescue LoadError
7
10
  raise "'gem install sass' to compile .sass and .scss files."
data/lib/bunch/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bunch
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
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.2
4
+ version: 0.0.3
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-30 00:00:00.000000000 Z
12
+ date: 2012-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mime-types
16
- requirement: &70119922351140 !ruby/object:Gem::Requirement
16
+ requirement: &70173831338560 !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: *70119922351140
24
+ version_requirements: *70173831338560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: slop
27
- requirement: &70119922350720 !ruby/object:Gem::Requirement
27
+ requirement: &70173831338140 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70119922350720
35
+ version_requirements: *70173831338140
36
36
  description: Directory-structure-based asset bundling.
37
37
  email:
38
38
  - rfitz@academia.edu