Class: Guides::Generator
- Inherits:
-
Object
- Object
- Guides::Generator
- Defined in:
- lib/guides/generator.rb
Constant Summary collapse
- EXTENSIONS =
%w(textile md html.erb)
- GUIDES_RE =
/\.(?:#{EXTENSIONS.map{|e| Regexp.escape(e)}.join('|')})$/
- LOCAL_ASSETS =
File.("../templates/assets", __FILE__)
Instance Attribute Summary collapse
-
#all ⇒ Object
readonly
Returns the value of attribute all.
-
#edge ⇒ Object
readonly
Returns the value of attribute edge.
-
#guides_dir ⇒ Object
readonly
Returns the value of attribute guides_dir.
-
#output_dir ⇒ Object
readonly
Returns the value of attribute output_dir.
-
#source_dir ⇒ Object
readonly
Returns the value of attribute source_dir.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
- #construction?(source_file) ⇒ Boolean
- #generate ⇒ Object
-
#initialize(options) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(options) ⇒ Generator
Returns a new instance of Generator.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/guides/generator.rb', line 68 def initialize() @options = @guides_dir = File.(Dir.pwd) @source_dir = File.join(@guides_dir, "source") @output_dir = File.join(@guides_dir, [:production] ? "output" : "staging") FileUtils.mkdir_p(@output_dir) @edge = [:edge] @warnings = [:warnings] @all = [:all] @production = [:production] @meta = Guides. end |
Instance Attribute Details
#all ⇒ Object (readonly)
Returns the value of attribute all.
62 63 64 |
# File 'lib/guides/generator.rb', line 62 def all @all end |
#edge ⇒ Object (readonly)
Returns the value of attribute edge.
62 63 64 |
# File 'lib/guides/generator.rb', line 62 def edge @edge end |
#guides_dir ⇒ Object (readonly)
Returns the value of attribute guides_dir.
62 63 64 |
# File 'lib/guides/generator.rb', line 62 def guides_dir @guides_dir end |
#output_dir ⇒ Object (readonly)
Returns the value of attribute output_dir.
62 63 64 |
# File 'lib/guides/generator.rb', line 62 def output_dir @output_dir end |
#source_dir ⇒ Object (readonly)
Returns the value of attribute source_dir.
62 63 64 |
# File 'lib/guides/generator.rb', line 62 def source_dir @source_dir end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
62 63 64 |
# File 'lib/guides/generator.rb', line 62 def warnings @warnings end |
Instance Method Details
#construction?(source_file) ⇒ Boolean
90 91 92 93 94 95 |
# File 'lib/guides/generator.rb', line 90 def construction?(source_file) # TODO: Clean this up a bit, it is messy url = source_file.sub(/\.(#{EXTENSIONS.map{|e| Regexp.escape(e) }.join('|')})$/, '') guide = @meta['index'].values.flatten.select{|g| g['url'] == url }.first rescue nil guide && guide['construction'] end |
#generate ⇒ Object
85 86 87 88 |
# File 'lib/guides/generator.rb', line 85 def generate generate_guides copy_assets end |