Class: Warg::Script
- Inherits:
-
Object
- Object
- Warg::Script
- Defined in:
- lib/warg.rb
Defined Under Namespace
Classes: Interpolations, Template
Constant Summary collapse
- REMOTE_DIRECTORY =
Pathname.new("$HOME").join("warg", "scripts")
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#remote_path ⇒ Object
readonly
Returns the value of attribute remote_path.
Instance Method Summary collapse
-
#initialize(script_name, context, defaults_path: nil) ⇒ Script
constructor
A new instance of Script.
- #install_directory ⇒ Object
- #install_path ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(script_name, context, defaults_path: nil) ⇒ Script
Returns a new instance of Script.
2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 |
# File 'lib/warg.rb', line 2240 def initialize(script_name, context, defaults_path: nil) command_name = Command::Name.from_relative_script_path(script_name) @name = command_name.script @context = context local_path = Pathname.new(@name) # FIXME: search parent directories for a defaults script defaults_path ||= File.join(local_path.dirname, "_defaults") @defaults = Template.find(defaults_path, fail_if_missing: false) @template = Template.find(local_path.to_s) @remote_path = REMOTE_DIRECTORY.join(local_path) end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
2236 2237 2238 |
# File 'lib/warg.rb', line 2236 def content @content end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2237 2238 2239 |
# File 'lib/warg.rb', line 2237 def name @name end |
#remote_path ⇒ Object (readonly)
Returns the value of attribute remote_path.
2238 2239 2240 |
# File 'lib/warg.rb', line 2238 def remote_path @remote_path end |
Instance Method Details
#install_directory ⇒ Object
2264 2265 2266 |
# File 'lib/warg.rb', line 2264 def install_directory @remote_path.dirname end |
#install_path ⇒ Object
2268 2269 2270 |
# File 'lib/warg.rb', line 2268 def install_path @remote_path.relative_path_from Pathname.new("$HOME") end |
#to_s ⇒ Object
2272 2273 2274 |
# File 'lib/warg.rb', line 2272 def to_s name.dup end |