Class: Chino::Config
- Inherits:
-
Object
- Object
- Chino::Config
- Defined in:
- lib/chino/config.rb
Instance Method Summary collapse
- #bundle_author ⇒ Object
- #bundle_author_email ⇒ Object
- #bundle_company_name ⇒ Object
- #bundle_created_at ⇒ Object
- #bundle_exports ⇒ Object
- #bundle_identifier ⇒ Object
- #bundle_name ⇒ Object
- #bundle_version ⇒ Object
- #common_path ⇒ Object
- #data_path ⇒ Object
- #dependency_has_file?(file) ⇒ Boolean
- #erb(file) ⇒ Object
- #erb_name(file) ⇒ Object
- #get_file(file) ⇒ Object
- #get_from_dependency(file) ⇒ Object
-
#initialize(file: nil, install: false) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(file: nil, install: false) ⇒ Config
Returns a new instance of Config.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/chino/config.rb', line 8 def initialize(file: nil, install: false) path = File.basename(file || '') file ||= 'Chinofile' @chinofile = Chinofile.new(path: path) do instance_eval File.read(file), file end @dep_puller = DepPuller.new @chinofile.information[:dependencies].each do |dep| @dep_puller.load_dependency!(dep) end end |
Instance Method Details
#bundle_author ⇒ Object
29 30 31 |
# File 'lib/chino/config.rb', line 29 def @chinofile.information[:author] end |
#bundle_author_email ⇒ Object
33 34 35 |
# File 'lib/chino/config.rb', line 33 def @chinofile.information[:author_email] end |
#bundle_company_name ⇒ Object
37 38 39 |
# File 'lib/chino/config.rb', line 37 def bundle_company_name @chinofile.information[:company_name] end |
#bundle_created_at ⇒ Object
45 46 47 |
# File 'lib/chino/config.rb', line 45 def bundle_created_at @chinofile.information[:created_at] end |
#bundle_exports ⇒ Object
49 50 51 |
# File 'lib/chino/config.rb', line 49 def bundle_exports @chinofile.information[:exports] end |
#bundle_identifier ⇒ Object
41 42 43 |
# File 'lib/chino/config.rb', line 41 def bundle_identifier @chinofile.information[:identifier] end |
#bundle_name ⇒ Object
21 22 23 |
# File 'lib/chino/config.rb', line 21 def bundle_name @chinofile.information[:name] end |
#bundle_version ⇒ Object
25 26 27 |
# File 'lib/chino/config.rb', line 25 def bundle_version @chinofile.information[:version] end |
#common_path ⇒ Object
57 58 59 |
# File 'lib/chino/config.rb', line 57 def common_path "#{data_path}/common" end |
#data_path ⇒ Object
53 54 55 |
# File 'lib/chino/config.rb', line 53 def data_path "#{Gem.loaded_specs['chino'].full_gem_path}/data/chino" end |
#dependency_has_file?(file) ⇒ Boolean
70 71 72 |
# File 'lib/chino/config.rb', line 70 def dependency_has_file?(file) @dep_puller.dependency_has_file?(file) end |
#erb(file) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/chino/config.rb', line 82 def erb(file) renderer = ERB.new(File.read(erb_name(file))) { string: renderer.result(binding) } end |
#erb_name(file) ⇒ Object
78 79 80 |
# File 'lib/chino/config.rb', line 78 def erb_name(file) "#{common_path}/#{file}.erb" end |
#get_file(file) ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/chino/config.rb', line 61 def get_file(file) return { filename: file.to_s } if File.exist?(file.to_s) return erb(file) if File.exist?(erb_name(file)) return { filename: "#{common_path}/#{file}" } if File.exist?("#{common_path}/#{file}") return get_from_dependency(file) if dependency_has_file?(file) {} end |
#get_from_dependency(file) ⇒ Object
74 75 76 |
# File 'lib/chino/config.rb', line 74 def get_from_dependency(file) @dep_puller.get_from_dependency(file) end |