Class: HockeyApp::App

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

Constant Summary collapse

ANDROID =
'Android'
IOS =
'iOS'
ATTRIBUTES =
[:title, :minimum_os_version, :status, :company, :owner, :bundle_identifier, :device_family, :platform,
:public_identifier, :role, :release_type]
POST_PAYLOAD =
[:status,:notes_type, :notify]
NOTES_TYPES_TO_SYM =
{
    0 => :textile,
    1 => :markdown
}
NOTIFY_TO_BOOL =
{
    0 => false,
    1 => true
}
STATUS_TO_SYM =
{
    1 => :deny,
    2 => :allow
}

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActiveModelCompliance

#persisted?, #to_model

Constructor Details

#initialize(client) ⇒ App

Returns a new instance of App.



49
50
51
# File 'lib/hockeyapp/models/app.rb', line 49

def initialize client
  @client = client
end

Class Method Details

.from_hash(h, client) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/hockeyapp/models/app.rb', line 41

def self.from_hash(h, client)
  res = self.new 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



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

def crash_reasons
  @crash_reasons ||= client.get_crash_groups(self)
end

#crashesObject



61
62
63
# File 'lib/hockeyapp/models/app.rb', line 61

def crashes
  @crashes ||= client.get_crashes(self)
end

#create_version(file, release_notes = "", notify = :none, status = :allow, tags = "") ⇒ Object



94
95
96
97
98
99
100
101
102
103
# File 'lib/hockeyapp/models/app.rb', line 94

def create_version file, release_notes = "", notify = :none, status = :allow , tags = ""
  version = Version.new(self, @client)
  version.ipa = file
  version.notes = release_notes
  version.notify = notify
  version.status = status
  version.tags = tags
  client.post_new_version version
  @versions = nil
end

#direct_download_urlObject



86
87
88
# File 'lib/hockeyapp/models/app.rb', line 86

def direct_download_url
  url_strategy.direct_download_url
end

#download_urlObject



82
83
84
# File 'lib/hockeyapp/models/app.rb', line 82

def download_url
  last_version.download_url
end

#iconObject



78
79
80
# File 'lib/hockeyapp/models/app.rb', line 78

def icon
  "https://rink.hockeyapp.net/api/2/apps/#{public_identifier}?format=png"
end

#install_urlObject



90
91
92
# File 'lib/hockeyapp/models/app.rb', line 90

def install_url
  url_strategy.install_url
end

#last_versionObject



73
74
75
76
# File 'lib/hockeyapp/models/app.rb', line 73

def last_version
  sorted_version = versions.sort_by { |v| v.version.to_i}
  sorted_version.last
end

#platform=(platform) ⇒ Object



57
58
59
# File 'lib/hockeyapp/models/app.rb', line 57

def platform= platform
  @platform = platform
end

#removeObject



105
106
107
# File 'lib/hockeyapp/models/app.rb', line 105

def remove
  client.remove_app self
end

#to_keyObject



53
54
55
# File 'lib/hockeyapp/models/app.rb', line 53

def to_key
  [public_identifier] if persisted?
end

#versionsObject



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

def versions
  @versions ||= client.get_versions(self)
end