Class: Sekt::Bottle
- Inherits:
-
Object
- Object
- Sekt::Bottle
- Defined in:
- lib/sekt/bottle.rb
Constant Summary collapse
- WINE_PREFIX_NAME =
'windows'.freeze
- REQUIRED_ATTRIBUTES =
%w{id name source}.freeze
- OPTIONAL_ATTRIBUTES =
%w{architecture description dependencies executable}.freeze
- ATTRIBUTES =
REQUIRED_ATTRIBUTES + OPTIONAL_ATTRIBUTES
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#wine_prefix ⇒ Object
readonly
Returns the value of attribute wine_prefix.
Class Method Summary collapse
Instance Method Summary collapse
- #check_args!(hash) ⇒ Object
-
#initialize(hash) ⇒ Bottle
constructor
A new instance of Bottle.
- #inside(&block) ⇒ Object
- #inside_wine(&block) ⇒ Object
- #install_libs(libs) ⇒ Object
- #pp ⇒ Object
- #start ⇒ Object
- #to_h ⇒ Object
- #wine ⇒ Object
- #wine_tricks ⇒ Object
Constructor Details
#initialize(hash) ⇒ Bottle
Returns a new instance of Bottle.
20 21 22 23 24 25 26 27 |
# File 'lib/sekt/bottle.rb', line 20 def initialize(hash) check_args!(hash) ATTRIBUTES.each { |attr| instance_variable_set("@#{attr}", hash[attr]) } @path = File.join(Cellar::CELLAR_PATH, @id) @wine_prefix = File.join(@path, WINE_PREFIX_NAME) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'lib/sekt/bottle.rb', line 13 def path @path end |
#wine_prefix ⇒ Object (readonly)
Returns the value of attribute wine_prefix.
13 14 15 |
# File 'lib/sekt/bottle.rb', line 13 def wine_prefix @wine_prefix end |
Class Method Details
Instance Method Details
#check_args!(hash) ⇒ Object
15 16 17 18 |
# File 'lib/sekt/bottle.rb', line 15 def check_args!(hash) diff = REQUIRED_ATTRIBUTES - hash.keys raise "Some required bottle attributes are missing: #{diff}" unless diff.empty? end |
#inside(&block) ⇒ Object
42 43 44 |
# File 'lib/sekt/bottle.rb', line 42 def inside(&block) Dir.chdir(path, &block) end |
#inside_wine(&block) ⇒ Object
46 47 48 |
# File 'lib/sekt/bottle.rb', line 46 def inside_wine(&block) Dir.chdir(File.join(wine_prefix, 'drive_c'), &block) end |
#install_libs(libs) ⇒ Object
54 55 56 57 |
# File 'lib/sekt/bottle.rb', line 54 def install_libs(libs) wine_tricks.install(libs) @dependencies + libs end |
#pp ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/sekt/bottle.rb', line 63 def pp %( Bottle___________________________________________________ |NAME: #{name} |ID: #{id} |PATH: #{path} |WINE_PREFIX: #{wine_prefix} |________________________________________________________ Description: #{description} Source: #{source} Executable: #{executable} Architecture: #{architecture} ) end |
#start ⇒ Object
50 51 52 |
# File 'lib/sekt/bottle.rb', line 50 def start wine.execute(executable) end |
#to_h ⇒ Object
59 60 61 |
# File 'lib/sekt/bottle.rb', line 59 def to_h ATTRIBUTES.each_with_object({}) { |attr, hash| hash[attr] = instance_variable_get("@#{attr}") } end |
#wine ⇒ Object
34 35 36 |
# File 'lib/sekt/bottle.rb', line 34 def wine Wine.new(wine_prefix, architecture) end |
#wine_tricks ⇒ Object
38 39 40 |
# File 'lib/sekt/bottle.rb', line 38 def wine_tricks WineTricks.new(wine_prefix, architecture) end |