Module: Dapp::Project::Dappfile
- Included in:
- Dapp::Project
- Defined in:
- lib/dapp/project/dappfile.rb
Overview
Dappfile
Instance Method Summary collapse
- #build_configs ⇒ Object
- #dappfile_path ⇒ Object
- #dimgs(dappfile_path) ⇒ Object
- #expand_path(path, number = 1) ⇒ Object
- #work_dir ⇒ Object
Instance Method Details
#build_configs ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/dapp/project/dappfile.rb', line 6 def build_configs @configs ||= begin dimgs(dappfile_path).flatten.tap do |dimgs| raise Error::Project, code: :no_such_dimg, data: { dimgs_patterns: dimgs_patterns.join(', ') } if dimgs.empty? end end end |
#dappfile_path ⇒ Object
14 15 16 17 |
# File 'lib/dapp/project/dappfile.rb', line 14 def dappfile_path raise Error::Project, code: :dappfile_not_found unless (dappfile_path = search_file_upward('Dappfile')) dappfile_path end |
#dimgs(dappfile_path) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/dapp/project/dappfile.rb', line 29 def dimgs(dappfile_path) Config::DimgGroupMain.new(project: self) do |conf| begin conf.instance_eval File.read(dappfile_path), dappfile_path rescue SyntaxError, StandardError => e backtrace = e.backtrace.find { |line| line.start_with?(dappfile_path) } = begin case e when NoMethodError e. =~ /`.*'/ "undefined method #{Regexp.last_match}" when NameError then e.[/.*(?= for)/] else e. end end = "#{backtrace[/.*(?=:in)/]}: #{}" if backtrace raise Error::Dappfile, code: :incorrect, data: { error: e.class.name, message: } end end._dimg.select { |dimg| dimgs_patterns.any? { |pattern| dimg._name.nil? || File.fnmatch(pattern, dimg._name) } }.tap do |dimgs| dimgs.each { |dimg| dimg.send(:validate!) } end end |
#expand_path(path, number = 1) ⇒ Object
23 24 25 26 27 |
# File 'lib/dapp/project/dappfile.rb', line 23 def (path, number = 1) path = File.(path) number.times.each { path = File.dirname(path) } path end |
#work_dir ⇒ Object
19 20 21 |
# File 'lib/dapp/project/dappfile.rb', line 19 def work_dir File.([:dir] || Dir.pwd) end |