Class: Scales::Up

Inherits:
Rake::TaskLib
  • Object
show all
Includes:
Helper::ContentTypes, Rake::DSL
Defined in:
lib/scales/up.rb

Constant Summary collapse

@@application =
Worker::Application::Rails

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Up

Returns a new instance of Up.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/scales/up.rb', line 21

def initialize(*args)
  @name   = args.shift || :up
  @paths  = []
  @app    = nil
  @pusher = Scales::Worker::Pusher.new
  
  desc "Scale up task" unless ::Rake.application.last_comment
  task name do
    RakeFileUtils.send(:verbose, verbose) do
      @app = Up.application.initialize_environment!

      yield self if block_given?
      
      @pusher.push!(@paths)
    end
  end
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



7
8
9
# File 'lib/scales/up.rb', line 7

def app
  @app
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/scales/up.rb', line 6

def name
  @name
end

#pathsObject

Returns the value of attribute paths.



8
9
10
# File 'lib/scales/up.rb', line 8

def paths
  @paths
end

Class Method Details

.applicationObject



42
43
44
# File 'lib/scales/up.rb', line 42

def application
  @@application
end

.application=(application) ⇒ Object



46
47
48
# File 'lib/scales/up.rb', line 46

def application=(application)
  @@application = application
end

Instance Method Details

#push(format, options) ⇒ Object



10
11
12
# File 'lib/scales/up.rb', line 10

def push format, options
  paths << { :format => format, :push => true }.merge(options)
end

#update(*new_paths, params) ⇒ Object



14
15
16
17
18
19
# File 'lib/scales/up.rb', line 14

def update *new_paths, params
  raise "Please define a format like this :format => :html" unless params.is_a?(Hash)
  format = params.delete(:format)
  raise "Unknown format :#{format}"                         if format.to_content_type.nil?
  new_paths.each{ |path| paths << { :format => format, :to => path }}
end