class Dogen::Base
Public Instance Methods
configuration()
click to toggle source
# File lib/dogen/base.rb, line 31 def configuration @configuration ||= Configuration.new end
generate(path, opts = {})
click to toggle source
# 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)
click to toggle source
# File lib/dogen/base.rb, line 17 def parse_opts(args) Hash[(args.map { |item| item.split(':') })] end
read_opts_from_json(path)
click to toggle source
# 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)
click to toggle source
# 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
Private Instance Methods
base_path()
click to toggle source
# File lib/dogen/base.rb, line 49 def base_path @base_path ||= configuration.get.fetch(:repository).fetch(:place) rescue raise 'Repository configuration error. Check your configuration.' end
current_dir()
click to toggle source
# File lib/dogen/base.rb, line 37 def current_dir Dir.pwd end
file_repo()
click to toggle source
# File lib/dogen/base.rb, line 45 def file_repo @file_repo ||= RenderingEngine::FileRepo.new(base_path) end
provider()
click to toggle source
# File lib/dogen/base.rb, line 41 def provider @provider ||= RenderingEngine::Provider.new(file_repo) end