Class: Mactag::Builder
- Inherits:
-
Object
- Object
- Mactag::Builder
- Defined in:
- lib/mactag/builder.rb
Instance Attribute Summary collapse
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
Class Method Summary collapse
Instance Method Summary collapse
- #<<(tags) ⇒ Object
- #all ⇒ Object
- #directories ⇒ Object
- #files ⇒ Object
- #has_gems? ⇒ Boolean
-
#initialize ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize ⇒ Builder
Returns a new instance of Builder.
5 6 7 |
# File 'lib/mactag/builder.rb', line 5 def initialize @tags = [] end |
Instance Attribute Details
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
3 4 5 |
# File 'lib/mactag/builder.rb', line 3 def @tags end |
Class Method Details
.builder ⇒ Object
63 64 65 |
# File 'lib/mactag/builder.rb', line 63 def builder @builder end |
.create ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/mactag/builder.rb', line 38 def create unless gem_home_exists? raise Mactag::MactagError.new("Gem home directory '#{Mactag::Config.gem_home}' does not exist") end if builder.has_gems? Mactag::Ctags.new(@builder.files, Mactag::Config.).create puts "[done] Successfully generated #{Mactag::Config.} file" else raise Mactag::MactagError.new('Nothing to tag') end end |
Instance Method Details
#<<(tags) ⇒ Object
9 10 11 |
# File 'lib/mactag/builder.rb', line 9 def <<() @tags += Array() end |
#all ⇒ Object
29 30 31 |
# File 'lib/mactag/builder.rb', line 29 def all @all ||= @tags.collect!(&:tag) end |
#directories ⇒ Object
25 26 27 |
# File 'lib/mactag/builder.rb', line 25 def directories files.collect { |file| File.dirname(file) }.uniq end |
#files ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/mactag/builder.rb', line 13 def files = all .flatten! .compact! .collect! { |file| File.(file) } .collect! { |file| Dir.glob(file) } .flatten! .uniq! .reject! { |file| File.directory?(file) } end |
#has_gems? ⇒ Boolean
33 34 35 |
# File 'lib/mactag/builder.rb', line 33 def has_gems? all.flatten.compact.any? end |