Class: Crackin::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/crackin/status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStatus

Returns a new instance of Status.



5
6
7
8
9
10
11
12
13
# File 'lib/crackin/status.rb', line 5

def initialize
  @config = Crackin.config
  @source = @config.source
  @verbose = @config['status']['verbose']
  @version = Crackin::VersionFile.new(@config['version'])
  @notices = []

  process
end

Instance Attribute Details

#stateObject (readonly)

Returns the value of attribute state.



3
4
5
# File 'lib/crackin/status.rb', line 3

def state
  @state
end

Instance Method Details

#development?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/crackin/status.rb', line 42

def development?
  @state == 'development'
end

#processObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/crackin/status.rb', line 15

def process
  if (@source.current_branch =~ /^crackin_/) == 0
    # we're releasing
    @state = 'releasing'
    @notices << notice_releasing
    @notices << notice_releasing_pending if @source.pending
    @notices << notice_releasing_finish
  elsif @source.current_branch == @config['branch']['development']
    @state = 'development'
    @notices << notice_development
  elsif @source.current_branch == @config['branch']['production']
    @state = 'production'
    @notices << notice_production
  else
    @state = 'unknown'
    @notices << notice_unknown
  end
end

#production?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/crackin/status.rb', line 38

def production?
  @state == 'production'
end

#releasing?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/crackin/status.rb', line 34

def releasing?
  @state == 'releasing'
end

#status_lineObject



50
51
52
# File 'lib/crackin/status.rb', line 50

def status_line
  "crackin # '#{@version}' # on branch: '#{@source.current_branch}' ('#{@state}') # pending changes: '#{@source.pending?}'"
end

#to_sObject



54
55
56
57
58
59
# File 'lib/crackin/status.rb', line 54

def to_s
  out = []
  out += @notices if @verbose
  out << status_line
  out.join("\n")
end

#unknown?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/crackin/status.rb', line 46

def unknown?
  @state == 'unknown'
end