Class: Perkins::Build::Data::Var
- Defined in:
- lib/perkins/build/data/var.rb
Constant Summary collapse
- PATTERN =
/(?:SECURE )?([\w]+)=(("|')(.*?)(\3)|\$\(.*?\)|[^"' ]+)/
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, value, secure = nil) ⇒ Var
constructor
A new instance of Var.
- #key ⇒ Object
- #secure? ⇒ Boolean
- #to_s ⇒ Object
- #travis? ⇒ Boolean
Constructor Details
#initialize(key, value, secure = nil) ⇒ Var
Returns a new instance of Var.
24 25 26 27 28 |
# File 'lib/perkins/build/data/var.rb', line 24 def initialize(key, value, secure = nil) @key = key.to_s @value = value.to_s @secure = secure end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
22 23 24 |
# File 'lib/perkins/build/data/var.rb', line 22 def value @value end |
Class Method Details
Instance Method Details
#key ⇒ Object
30 31 32 |
# File 'lib/perkins/build/data/var.rb', line 30 def key strip_secure(@key) end |
#secure? ⇒ Boolean
48 49 50 |
# File 'lib/perkins/build/data/var.rb', line 48 def secure? @secure.nil? ? @key =~ /^SECURE / : @secure end |
#to_s ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/perkins/build/data/var.rb', line 34 def to_s if travis? false elsif secure? "export #{[key, '[secure]'].join('=')}" else "export #{[key, value].join('=')}" end end |
#travis? ⇒ Boolean
44 45 46 |
# File 'lib/perkins/build/data/var.rb', line 44 def travis? @key =~ /^TRAVIS_/ end |