Module: Dapp::Dapp::Dappfile
- Included in:
- Dapp::Dapp
- Defined in:
- lib/dapp/dapp/dappfile.rb
Instance Method Summary collapse
- #config ⇒ Object
- #dappfile_exists? ⇒ Boolean
- #dappfile_path ⇒ Object
- #expand_path(path, number = 1) ⇒ Object
- #local_git_artifact_exclude_paths(&blk) ⇒ Object
- #work_dir ⇒ Object
Instance Method Details
#config ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/dapp/dapp/dappfile.rb', line 31 def config @config ||= begin ::Dapp::Config::Config.new(dapp: self).tap do |config| begin config.instance_eval File.read(dappfile_path), dappfile_path config.validate! 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 end end |
#dappfile_exists? ⇒ Boolean
12 13 14 |
# File 'lib/dapp/dapp/dappfile.rb', line 12 def dappfile_exists? !!search_file_upward('Dappfile') end |
#dappfile_path ⇒ Object
16 17 18 19 |
# File 'lib/dapp/dapp/dappfile.rb', line 16 def dappfile_path raise Error::Dapp, code: :dappfile_not_found unless (dappfile_path = search_file_upward('Dappfile')) dappfile_path end |
#expand_path(path, number = 1) ⇒ Object
25 26 27 28 29 |
# File 'lib/dapp/dapp/dappfile.rb', line 25 def (path, number = 1) path = File.(path) number.times.each { path = File.dirname(path) } path end |
#local_git_artifact_exclude_paths(&blk) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/dapp/dapp/dappfile.rb', line 4 def local_git_artifact_exclude_paths(&blk) super do |exclude_paths| exclude_paths << 'Dappfile' yield exclude_paths if block_given? end end |
#work_dir ⇒ Object
21 22 23 |
# File 'lib/dapp/dapp/dappfile.rb', line 21 def work_dir File.([:dir] || Dir.pwd) end |