Class: JBundle::Config
- Inherits:
-
Object
- Object
- JBundle::Config
- Defined in:
- lib/jbundle/config.rb
Instance Attribute Summary collapse
-
#after_write_blocks ⇒ Object
readonly
Returns the value of attribute after_write_blocks.
-
#bundles ⇒ Object
readonly
Returns the value of attribute bundles.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#filters ⇒ Object
readonly
Returns the value of attribute filters.
Instance Method Summary collapse
- #after_write(&block) ⇒ Object
- #bundle(names, &block) ⇒ Object
- #bundles_and_files ⇒ Object
- #file(f) ⇒ Object
- #filter(mode = :all, &block) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #src_dir(dir = nil) ⇒ Object
- #target_dir(dir = nil) ⇒ Object
- #version(v = nil, opts = {}) ⇒ Object
- #versioned_directories? ⇒ Boolean
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
7 8 9 10 11 12 13 |
# File 'lib/jbundle/config.rb', line 7 def initialize @bundles = [] @files = [] @filters = {:all => [], :min => [], :src => []} @after_write_blocks = [] @version_options = {:directory => true} end |
Instance Attribute Details
#after_write_blocks ⇒ Object (readonly)
Returns the value of attribute after_write_blocks.
5 6 7 |
# File 'lib/jbundle/config.rb', line 5 def after_write_blocks @after_write_blocks end |
#bundles ⇒ Object (readonly)
Returns the value of attribute bundles.
5 6 7 |
# File 'lib/jbundle/config.rb', line 5 def bundles @bundles end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
5 6 7 |
# File 'lib/jbundle/config.rb', line 5 def files @files end |
#filters ⇒ Object (readonly)
Returns the value of attribute filters.
5 6 7 |
# File 'lib/jbundle/config.rb', line 5 def filters @filters end |
Instance Method Details
#after_write(&block) ⇒ Object
53 54 55 |
# File 'lib/jbundle/config.rb', line 53 def after_write(&block) after_write_blocks << block end |
#bundle(names, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/jbundle/config.rb', line 35 def bundle(names, &block) name = (names.is_a?(Hash) ? names.keys.first : names).to_sym if !b = @bundles.detect{|a| a.name == name} b = Bundle.new(names) @bundles << b end b.instance_eval &block if block_given? b end |
#bundles_and_files ⇒ Object
57 58 59 |
# File 'lib/jbundle/config.rb', line 57 def bundles_and_files @bundles + @files end |
#file(f) ⇒ Object
45 46 47 |
# File 'lib/jbundle/config.rb', line 45 def file(f) @files << JBundle::File.new(f) end |
#filter(mode = :all, &block) ⇒ Object
49 50 51 |
# File 'lib/jbundle/config.rb', line 49 def filter(mode = :all, &block) filters[mode.to_sym] << block end |
#src_dir(dir = nil) ⇒ Object
25 26 27 28 |
# File 'lib/jbundle/config.rb', line 25 def src_dir(dir = nil) @src_dir = dir if dir @src_dir || './' end |
#target_dir(dir = nil) ⇒ Object
30 31 32 33 |
# File 'lib/jbundle/config.rb', line 30 def target_dir(dir = nil) @target_dir = dir if dir @target_dir || './' end |
#version(v = nil, opts = {}) ⇒ Object
19 20 21 22 23 |
# File 'lib/jbundle/config.rb', line 19 def version(v = nil, opts = {}) @version_options.merge! opts @version = JBundle::Version.new(v) if v @version end |
#versioned_directories? ⇒ Boolean
15 16 17 |
# File 'lib/jbundle/config.rb', line 15 def versioned_directories? @version_options[:directory] end |