hockeyapp-config 0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +15 -0
  2. data/LICENSE +19 -0
  3. data/lib/hockeyapp-config.rb +91 -0
  4. metadata +58 -0
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTZlNmMxNmQxNjg4ZWVlZWI2OTZkNTQxZDY1YTIzNzRhOTI5OTkwOA==
5
+ data.tar.gz: !binary |-
6
+ N2EyZDliZTdkNzQzMjE2ZWZkNmQ2ODcxZmNjMWZhYWUwOTcwMzRhNw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MDJjMzlhZjNiMTA1YTIzYzc0YWFmZDk3MzBhMzQ2ODRhNjIxZDNlM2FmY2U4
10
+ MDA3YjdhMTg2ZWM1NzNiOTQ3YWQ0NjNkNmYyNTBkYzRiMDJmYTZjZmM4NjY4
11
+ M2VlYjIzMWY4MzllNWNmZGM4OTg0MTY5Yzk0YWJmZDFhODhiOGI=
12
+ data.tar.gz: !binary |-
13
+ OTdiODQ3MmVmY2Q3ZTI0YWEzNjVlMDE0YmNiY2E5Zjc4Mzc3OWJjZTViNDMx
14
+ NGU0N2E4NGQ3NzlmZTdkYjA3MDMyYjBlNzU3NGVkZjIwYTUzN2I2MGQ1ZTkw
15
+ OGQ1ZTdmNzUyZTNiNjM5OTA0YTY2MmIzY2U2YzJiNDM2YjgyYjE=
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Turboprop, Inc. (http://usepropeller.com/)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,91 @@
1
+ require 'hockeyapp'
2
+
3
+ class HockeyAppConfig
4
+ PROPERTIES = HockeyApp::Version::ATTRIBUTES + HockeyApp::Version::POST_PAYLOAD + [:app_id, :api_token]
5
+ attr_accessor *PROPERTIES
6
+
7
+ # Coerce these values to be :symbols
8
+ [["NOTES_TYPES", "notes_type"], ["STATUS","status"]].each do |constant, prop|
9
+ # i.e. Hockey::Version::NOTES_TYPE_TO_SYM
10
+ constant = HockeyApp::Version.const_get(constant + "_TO_SYM")
11
+ define_method("#{prop}=") do |new_value|
12
+ if new_value.is_a?(Numeric)
13
+ new_value = constant[new_value]
14
+ end
15
+ instance_variable_set("@#{prop}", new_value.to_sym)
16
+ end
17
+ end
18
+
19
+ def notify=(notify)
20
+ @notify = string_or_num_to_bool(notify)
21
+ end
22
+
23
+ def mandatory=(mandatory)
24
+ @mandatory = string_or_num_to_bool(mandatory)
25
+ end
26
+
27
+ def initialize(config)
28
+ @config = config
29
+ end
30
+
31
+ def client
32
+ if !api_token
33
+ puts "You need to specify a config.api_token"
34
+ return
35
+ end
36
+ @client ||= HockeyApp.build_client
37
+ end
38
+
39
+ def app
40
+ return if !client
41
+
42
+ @app ||= HockeyApp::App.from_hash({"public_identifier" => app_id}, client)
43
+ end
44
+
45
+ def api_token=(api_token)
46
+ @api_token = api_token
47
+ config_client
48
+ @api_token
49
+ end
50
+
51
+ def inspect
52
+ h = {}
53
+ PROPERTIES.each do |prop|
54
+ h[prop] = self.send(prop)
55
+ end
56
+ h
57
+ end
58
+
59
+ # Public: Creates a HockeyApp::Version object from this configuraiton
60
+ #
61
+ # Returns the new HockeyApp::Version object
62
+ def make_version
63
+ version = HockeyApp::Version.new(app, client)
64
+ version.notes = self.notes
65
+ version.notes_type = HockeyApp::Version::NOTES_TYPES_TO_SYM.invert[self.notes_type]
66
+ version.notify = HockeyApp::Version::NOTIFY_TO_BOOL.invert[self.notify]
67
+ version.status = HockeyApp::Version::STATUS_TO_SYM.invert[self.status]
68
+ version.tags = self.tags
69
+ version
70
+ end
71
+
72
+ private
73
+ def config_client
74
+ HockeyApp::Config.configure do |config|
75
+ config.token = api_token
76
+ end
77
+ end
78
+
79
+ def string_or_num_to_bool(object)
80
+ if object.is_a?(Symbol)
81
+ notify = notify.to_s
82
+ end
83
+ if object.is_a?(String)
84
+ object = (object == "true") ? true : false
85
+ end
86
+ if object.is_a?(Numeric)
87
+ object = HockeyApp::Version::NOTIFY_TO_BOOL[object]
88
+ end
89
+ object
90
+ end
91
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hockeyapp-config
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Clay Allsopp
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: hockeyapp
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Small HockeyApp configuration used by Propeller
28
+ email: clay@usepropeller.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - LICENSE
34
+ - lib/hockeyapp-config.rb
35
+ homepage: https://github.com/usepropeller/hockeyapp-config
36
+ licenses: []
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.0.3
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Small HockeyApp configuration used by Propeller
58
+ test_files: []