Class: Freezer

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

#componentObject (readonly)

Returns the value of attribute component.



6
7
8
# File 'lib/merb-freezer/freezer.rb', line 6

def component
  @component
end

#freezer_dirObject

Returns the value of attribute freezer_dir.



7
8
9
# File 'lib/merb-freezer/freezer.rb', line 7

def freezer_dir
  @freezer_dir
end

#modeObject (readonly)

Returns the value of attribute mode.



6
7
8
# File 'lib/merb-freezer/freezer.rb', line 6

def mode
  @mode
end

#updateObject (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

.componentsObject

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_dirObject



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_dirObject



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

Returns:

  • (Boolean)


71
72
73
# File 'lib/merb-freezer/freezer.rb', line 71

def framework_component?
  Freezer.components.keys.include?(@component.gsub("merb-", ""))
end

#freezeObject

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