Class: C21e::ExeFile
- Inherits:
-
Object
- Object
- C21e::ExeFile
- Defined in:
- lib/c21e/exe_file.rb
Instance Attribute Summary collapse
-
#target_file ⇒ Object
Returns the value of attribute target_file.
Instance Method Summary collapse
- #arch ⇒ Object
- #ext ⇒ Object
-
#initialize(executable_pattern, props = load_props) ⇒ ExeFile
constructor
A new instance of ExeFile.
- #load_props ⇒ Object
- #os ⇒ Object
Constructor Details
#initialize(executable_pattern, props = load_props) ⇒ ExeFile
Returns a new instance of ExeFile.
8 9 10 11 12 13 14 |
# File 'lib/c21e/exe_file.rb', line 8 def initialize(executable_pattern, props = load_props) @props = props @target_file = executable_pattern .gsub('{{.OS}}', os) .gsub('{{.Arch}}', arch) .gsub('{{.Ext}}', ext) end |
Instance Attribute Details
#target_file ⇒ Object
Returns the value of attribute target_file.
6 7 8 |
# File 'lib/c21e/exe_file.rb', line 6 def target_file @target_file end |
Instance Method Details
#arch ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/c21e/exe_file.rb', line 39 def arch # https://github.com/kolosek/residds/blob/master/vendor/bundle/ruby/2.0.0/gems/launchy-2.4.3/spec/tattle-host-os.yaml case @props[:arch] when /i\d86/ then '386' when /x64|x86_64/ then 'amd64' else @props[:arch] end end |
#ext ⇒ Object
23 24 25 |
# File 'lib/c21e/exe_file.rb', line 23 def ext os == 'windows' ? '.exe' : '' end |
#load_props ⇒ Object
16 17 18 19 20 21 |
# File 'lib/c21e/exe_file.rb', line 16 def load_props { os: RbConfig::CONFIG['target_os'], arch: RbConfig::CONFIG['target_cpu'] } end |
#os ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/c21e/exe_file.rb', line 27 def os case @props[:os] when /darwin/ then 'darwin' when /freebsd/ then 'freebsd' when /linux/ then 'linux' when /netbsd/ then 'netbsd' when /openbsd/ then 'openbsd' when /cygwin|mingw32|mswin32/ then 'windows' else @props[:os] end end |