Class: Dogen::Base
- Inherits:
-
Object
- Object
- Dogen::Base
- Defined in:
- lib/dogen/base.rb
Instance Method Summary collapse
- #configuration ⇒ Object
- #generate(path, opts = {}) ⇒ Object
- #parse_opts(args) ⇒ Object
- #read_opts_from_json(path) ⇒ Object
- #set_repository(args) ⇒ Object
Instance Method Details
#configuration ⇒ Object
31 32 33 |
# File 'lib/dogen/base.rb', line 31 def configuration @configuration ||= Configuration.new end |
#generate(path, opts = {}) ⇒ Object
26 27 28 29 |
# File 'lib/dogen/base.rb', line 26 def generate(path, opts = {}) new_file_path = File.join(current_dir, File.basename(path)) File.write(new_file_path, provider.get(path, data: opts).source) end |
#parse_opts(args) ⇒ Object
17 18 19 |
# File 'lib/dogen/base.rb', line 17 def parse_opts(args) Hash[(args.map { |item| item.split(':') })] end |
#read_opts_from_json(path) ⇒ Object
21 22 23 24 |
# File 'lib/dogen/base.rb', line 21 def read_opts_from_json(path) raise 'File not found' unless File.exist?(path) JSON.parse(IO.read(path)) end |
#set_repository(args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/dogen/base.rb', line 6 def set_repository(args) source, place = args.first.to_s.split('::') if source.downcase == 'path' raise "Missing path: #{place}" unless File.directory?(place) configuration.set(repository: { source: 'path', place: place }) else raise "Unknown source #{source}" end end |