Class: Freezer
- Inherits:
-
Object
- Object
- Freezer
- Includes:
- FreezerMode
- Defined in:
- lib/merb-freezer/freezer.rb
Constant Summary collapse
- @@components =
{ "core" => "git://github.com/wycats/merb-core.git", "more" => "git://github.com/wycats/merb-more.git", "plugins" => "git://github.com/wycats/merb-plugins.git" }
- @@framework_dir =
File.join(Dir.pwd, "framework")
- @@gems_dir =
File.join(Dir.pwd, "gems")
Instance Attribute Summary collapse
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#freezer_dir ⇒ Object
Returns the value of attribute freezer_dir.
-
#mode ⇒ Object
readonly
Returns the value of attribute mode.
-
#update ⇒ Object
readonly
Returns the value of attribute update.
Class Method Summary collapse
-
.components ⇒ Object
Returns the components to freeze a class variable is used so we could decide to add a setter and support custom components.
- .framework_dir ⇒ Object
-
.freeze(component, update, mode) ⇒ Object
Freezes a component.
- .gems_dir ⇒ Object
Instance Method Summary collapse
-
#framework_component? ⇒ Boolean
Returns true if the gem is part of the Merb components.
-
#freeze ⇒ Object
Calls the freezer mode on the component.
-
#initialize(component, update = false, mode = nil) ⇒ Freezer
constructor
Initializes a Freeze instance.
Methods included from FreezerMode
#create_freezer_dir, #gitmodules, #install_rubygem, #rubygems_freeze, #submodules_freeze, #sudo
Constructor Details
#initialize(component, update = false, mode = nil) ⇒ Freezer
Initializes a Freeze instance
Parameters
- component<String>
-
The component to freeze, it needs to be defined in @@components
- update<Boolean>
-
An optional value to tell the freezer to update the previously frozen or not, this will default to false
- mode<String>
-
An optional value to tell the freezer what freezer mode to use (submodules or rubygems), this will default to submodules
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/merb-freezer/freezer.rb', line 53 def initialize(component, update=false, mode=nil) @component = Freezer.components.keys.include?(component) ? "merb-" + component : component @update = update if (mode.nil? && framework_component?) || component.match(/^git:\/\//) || mode == 'submodules' @mode = 'submodules' else @mode = 'rubygems' end @freezer_dir = framework_component? ? Freezer.framework_dir : Freezer.gems_dir end |
Instance Attribute Details
#component ⇒ Object (readonly)
Returns the value of attribute component.
6 7 8 |
# File 'lib/merb-freezer/freezer.rb', line 6 def component @component end |
#freezer_dir ⇒ Object
Returns the value of attribute freezer_dir.
7 8 9 |
# File 'lib/merb-freezer/freezer.rb', line 7 def freezer_dir @freezer_dir end |
#mode ⇒ Object (readonly)
Returns the value of attribute mode.
6 7 8 |
# File 'lib/merb-freezer/freezer.rb', line 6 def mode @mode end |
#update ⇒ Object (readonly)
Returns the value of attribute update.
6 7 8 |
# File 'lib/merb-freezer/freezer.rb', line 6 def update @update end |
Class Method Details
.components ⇒ Object
Returns the components to freeze a class variable is used so we could decide to add a setter and support custom components
21 22 23 |
# File 'lib/merb-freezer/freezer.rb', line 21 def self.components @@components end |
.framework_dir ⇒ Object
25 26 27 |
# File 'lib/merb-freezer/freezer.rb', line 25 def self.framework_dir @@framework_dir end |
.freeze(component, update, mode) ⇒ Object
Freezes a component
Parameters
- component<String>
-
The component to freeze, it needs to be defined in @@components
- update<Boolean>
-
An optional value to tell the freezer to update the previously frozen or not, this will default to false
- mode<String>
-
An optional value to tell the freezer what freezer mode to use (submodules or rubygems), this will default to submodules
41 42 43 |
# File 'lib/merb-freezer/freezer.rb', line 41 def self.freeze(component, update, mode) new(component, update, mode).freeze end |
.gems_dir ⇒ Object
29 30 31 |
# File 'lib/merb-freezer/freezer.rb', line 29 def self.gems_dir @@gems_dir end |
Instance Method Details
#framework_component? ⇒ Boolean
Returns true if the gem is part of the Merb components
71 72 73 |
# File 'lib/merb-freezer/freezer.rb', line 71 def framework_component? Freezer.components.keys.include?(@component.gsub("merb-", "")) end |
#freeze ⇒ Object
Calls the freezer mode on the component
65 66 67 68 |
# File 'lib/merb-freezer/freezer.rb', line 65 def freeze puts "freezing mode: #{@mode}" send "#{@mode}_freeze" end |