Class: Mxrb::RubyApp::Manifest
- Inherits:
-
Object
- Object
- Mxrb::RubyApp::Manifest
- Defined in:
- lib/mxrb/ruby_app.rb
Overview
Reads and validates paths before runtime or reverse compilation uses them.
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #absolute_path(key) ⇒ Object
- #coverage ⇒ Object
-
#initialize(root, data) ⇒ Manifest
constructor
A new instance of Manifest.
- #modules ⇒ Object
- #mpr_name ⇒ Object
Constructor Details
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
92 93 94 |
# File 'lib/mxrb/ruby_app.rb', line 92 def data @data end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
92 93 94 |
# File 'lib/mxrb/ruby_app.rb', line 92 def root @root end |
Class Method Details
.load(root) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/mxrb/ruby_app.rb', line 94 def self.load(root) = File.(root) path = File.join(, MANIFEST_PATH) raise ArgumentError, "not an MXRB Ruby application: #{}" unless File.file?(path) new(, JSON.parse(File.read(path))) rescue JSON::ParserError => e raise ArgumentError, "invalid MXRB Ruby application manifest: #{e.}" end |
Instance Method Details
#absolute_path(key) ⇒ Object
114 115 116 117 118 119 120 121 122 123 |
# File 'lib/mxrb/ruby_app.rb', line 114 def absolute_path(key) relative = data.fetch('round_trip').fetch(key) clean = Pathname.new(relative).cleanpath if clean.absolute? || clean.to_s.start_with?('../') raise ArgumentError, "unsafe Ruby application path: #{relative}" end File.join(root, clean.to_s) end |
#coverage ⇒ Object
112 |
# File 'lib/mxrb/ruby_app.rb', line 112 def coverage = data.fetch('coverage') |
#modules ⇒ Object
111 |
# File 'lib/mxrb/ruby_app.rb', line 111 def modules = data.fetch('modules') |
#mpr_name ⇒ Object
110 |
# File 'lib/mxrb/ruby_app.rb', line 110 def mpr_name = data.fetch('source').fetch('name') |