Class: Docforge::Inputs
- Inherits:
-
Object
- Object
- Docforge::Inputs
- Defined in:
- lib/docforge/inputs.rb
Overview
Reads a feature folder. Default layout:
<folder>/
PRD.md (required — name configurable via input_files.prd)
SPEC.md (required — name configurable via input_files.spec)
notes.md (optional — name configurable via input_files.notes)
_assets/ (optional)
Instance Attribute Summary collapse
-
#assets ⇒ Object
readonly
Returns the value of attribute assets.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#folder ⇒ Object
readonly
Returns the value of attribute folder.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#prd ⇒ Object
readonly
Returns the value of attribute prd.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, config: Config.new) ⇒ Inputs
constructor
A new instance of Inputs.
- #load! ⇒ Object
- #slug ⇒ Object
Constructor Details
Instance Attribute Details
#assets ⇒ Object (readonly)
Returns the value of attribute assets.
12 13 14 |
# File 'lib/docforge/inputs.rb', line 12 def assets @assets end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/docforge/inputs.rb', line 12 def config @config end |
#folder ⇒ Object (readonly)
Returns the value of attribute folder.
12 13 14 |
# File 'lib/docforge/inputs.rb', line 12 def folder @folder end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
12 13 14 |
# File 'lib/docforge/inputs.rb', line 12 def notes @notes end |
#prd ⇒ Object (readonly)
Returns the value of attribute prd.
12 13 14 |
# File 'lib/docforge/inputs.rb', line 12 def prd @prd end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
12 13 14 |
# File 'lib/docforge/inputs.rb', line 12 def spec @spec end |
Class Method Details
Instance Method Details
#load! ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/docforge/inputs.rb', line 23 def load! raise InputError, "Folder not found: #{folder}" unless File.directory?(folder) prd_name = config.input_filenames["prd"] spec_name = config.input_filenames["spec"] notes_name = config.input_filenames["notes"] prd_path = locate(prd_name) spec_path = locate(spec_name) raise InputError, "#{prd_name} not found in #{folder}" unless prd_path raise InputError, "#{spec_name} not found in #{folder}" unless spec_path @prd = File.read(prd_path) @spec = File.read(spec_path) notes_p = notes_name ? locate(notes_name) : nil @notes = notes_p ? File.read(notes_p) : nil @assets = locate_assets self end |
#slug ⇒ Object
43 44 45 |
# File 'lib/docforge/inputs.rb', line 43 def slug File.basename(folder).downcase.gsub(/[^a-z0-9-]+/, "-").gsub(/^-|-$/, "") end |