Class: Xphase::Spec
- Inherits:
-
Object
- Object
- Xphase::Spec
- Defined in:
- lib/xphase/spec.rb
Constant Summary collapse
- DEBUG =
true- PATH_BASE =
"https://raw.githubusercontent.com/CoreKit/xphase/master/phases/"- PATH_SPEC =
"/spec.json"- PATH_SCRIPT =
"/script.sh"
Instance Attribute Summary collapse
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id) ⇒ Spec
constructor
A new instance of Spec.
- #script(params) ⇒ Object
- #scriptLocation ⇒ Object
- #specLocation ⇒ Object
Constructor Details
#initialize(id) ⇒ Spec
Returns a new instance of Spec.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/xphase/spec.rb', line 50 def initialize(id) @id = id begin if ENV["XPHASE_LOCAL"].nil? contents = open(self.specLocation).read @template = open(self.scriptLocation).read else contents = File.open(self.specLocation, "rb").read @template = File.open(self.scriptLocation, "rb").read end rescue @id = nil return end json = JSON.parse(contents) @name = json["name"] @description = json["description"] @author = json["author"] @dependency = json["dependency"] @params = json["params"] end |
Instance Attribute Details
#author ⇒ Object (readonly)
Returns the value of attribute author.
16 17 18 |
# File 'lib/xphase/spec.rb', line 16 def @author end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
18 19 20 |
# File 'lib/xphase/spec.rb', line 18 def dependency @dependency end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
15 16 17 |
# File 'lib/xphase/spec.rb', line 15 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
12 13 14 |
# File 'lib/xphase/spec.rb', line 12 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
14 15 16 |
# File 'lib/xphase/spec.rb', line 14 def name @name end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
19 20 21 |
# File 'lib/xphase/spec.rb', line 19 def params @params end |
#template ⇒ Object (readonly)
Returns the value of attribute template.
21 22 23 |
# File 'lib/xphase/spec.rb', line 21 def template @template end |
Class Method Details
.new(val) ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/xphase/spec.rb', line 40 def self.new(val) @@obj = super(val) if @@obj.id.nil? return nil end return @@obj end |
Instance Method Details
#script(params) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/xphase/spec.rb', line 76 def script(params) script = @template if !params.nil? params.each do |key, value| if key.eql? "flags" script = script + ' ' + value next end script = script.gsub('{{'+key+'}}', value) end end script end |
#scriptLocation ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/xphase/spec.rb', line 31 def scriptLocation if ENV["XPHASE_LOCAL"].nil? PATH_BASE + @id + PATH_SCRIPT else Dir.getwd + "/../phases/" + @id + PATH_SCRIPT end end |