Class: HockeyApp::Version

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations, ActiveModelCompliance
Defined in:
lib/hockeyapp/models/version.rb

Constant Summary collapse

ATTRIBUTES =
[:id, :notes, :shortversion, :version, :mandatory, :timestamp, :appsize,  :title, :download_url]
POST_PAYLOAD =
[:status, :ipa, :dsym, :notes_type, :notify, :tags]
NOTES_TYPES_TO_SYM =
{
    0 => :textile,
    1 => :markdown
}
NOTIFY_TO_BOOL =
{
    0 => false,
    1 => true
}
STATUS_TO_SYM =
{
    1 => :deny,
    2 => :allow
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveModelCompliance

#persisted?, #to_model

Constructor Details

#initialize(app, client) ⇒ Version

Returns a new instance of Version.



45
46
47
48
49
# File 'lib/hockeyapp/models/version.rb', line 45

def initialize app, client
  @app = app
  @client = client
  default_values!
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



30
31
32
# File 'lib/hockeyapp/models/version.rb', line 30

def app
  @app
end

Class Method Details

.from_hash(h, app, client) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/hockeyapp/models/version.rb', line 37

def self.from_hash(h, app, client)
  res = self.new app, client
  ATTRIBUTES.each do |attribute|
    res.send("#{attribute.to_s}=", h[attribute.to_s]) unless (h[attribute.to_s].nil?)
  end
  res
end

Instance Method Details

#crash_reasonsObject



60
61
62
# File 'lib/hockeyapp/models/version.rb', line 60

def crash_reasons
  @crash_groups ||= @app.crash_reasons.select{|crash_reason| "#{crash_reason.app_version_id}" == @id.to_s}
end

#crashesObject



56
57
58
# File 'lib/hockeyapp/models/version.rb', line 56

def crashes
  @crashes ||= @app.crashes.select{|crash| "#{crash.app_version_id}" == @id.to_s}
end

#direct_download_urlObject



65
66
67
# File 'lib/hockeyapp/models/version.rb', line 65

def direct_download_url
  url_strategy.direct_download_url
end

#install_urlObject



69
70
71
# File 'lib/hockeyapp/models/version.rb', line 69

def install_url
  url_strategy.install_url
end

#to_keyObject



52
53
54
# File 'lib/hockeyapp/models/version.rb', line 52

def to_key
  [@id] if persisted?
end