hockeyver 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1001bce448947eaa5e4b28b6b61c2ee80d482cc4
4
- data.tar.gz: 26f32fd7777e211c1394697f969fc2f70ab98915
3
+ metadata.gz: 8d529e0644ef350b83491507063a1d1f91bfa875
4
+ data.tar.gz: 1f8318c4bca9138c1f58c6aaca31a16bfaa00103
5
5
  SHA512:
6
- metadata.gz: 89cb267fab4c740315c0cecec3f38a031350047b9e8766aa5d3c442997dbe20bf6466a585631bafa813142191eaa9fff903883c1fe178ea00f0ddcc2c56de353
7
- data.tar.gz: 6f69cde5e8205234d3386ba4f0d0d60c7bc6bdeb47d87fbcca08e1ce12ae0067cf4018cfcc4d838a77278fb3705a7e8e7652c55da11259dcffaa766b46a425c0
6
+ metadata.gz: c6485abcc34423c4ef20fb3ed4250f9ab15a6f3fe6f949fafa970698b8906aacc68f3f59f050ae214a4315448a2208d788294b0b42c6dae90c85c78ad0e86794
7
+ data.tar.gz: 2b873c998ace30b8ec79ba041245fdcb0af1293686c0996ed1378309e90e1c961d1e51a66ea93be4e4fc45413ff915f55d40f26f016a1604a13789d7f4647804
data/bin/hockeyver CHANGED
@@ -1,4 +1,48 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'hockeyver'
4
- puts Hola.hi(ARGV[0], ARGV[1])
4
+ require 'optparse'
5
+
6
+ # Setup required configuration
7
+ Configuration = Struct.new(:app_id, :token)
8
+ config = Configuration.new(nil, nil)
9
+
10
+ # Parse options
11
+ parser = OptionParser.new do |opts|
12
+ opts.banner = "Usage: hockeyver [options]"
13
+ opts.separator ""
14
+ opts.separator "Outputs the version number of the latest build on Hockey based on the provided Hockey ID and token."
15
+ opts.separator ""
16
+ opts.separator "Specific options:"
17
+
18
+ opts.on("-i", "--app_id APP_IDENTIFIER", "HockeyApp app identifier of the app you want to check version of. (required)") do |identifier|
19
+ config.app_id = identifier
20
+ end
21
+
22
+ opts.on("-t", "--token API_TOKEN", "HockeyApp API token which will be used to connect. (required)") do |token|
23
+ config.token = token
24
+ end
25
+
26
+ opts.on_tail("-h", "--help", "Show this message") do
27
+ puts opts
28
+ exit
29
+ end
30
+ end
31
+ parser.parse!
32
+
33
+ # Safety checks
34
+ if config.app_id.nil?
35
+ puts "ERROR: You need to provide an app identifier. \n\n"
36
+ puts parser.help
37
+ exit 1
38
+ end
39
+
40
+ if config.token.nil?
41
+ puts "ERROR: You need to provide an API token. \n\n"
42
+ puts parser.help
43
+ exit 1
44
+ end
45
+
46
+ # Run the hockey version parser
47
+ result = HockeyVer.parse_hockey_version config.app_id, config.token
48
+ if result.nil? then exit 1 else exit end
data/lib/hockeyver.rb CHANGED
@@ -2,39 +2,29 @@
2
2
 
3
3
  require 'httparty'
4
4
  require 'json'
5
- require 'slop'
6
5
 
7
- opts = Slop.parse do |o|
8
- o.string '-i', '--app_id', 'Hockey app id'
9
- o.string '-t', '--token', 'Hockey api token'
10
- end
11
-
12
- def fail(opts)
13
- puts opts
14
- exit
15
- end
16
-
17
- app_id = opts[:app_id]
18
- if app_id.nil?
19
- puts('ERROR: No app id provided!')
20
- fail(opts)
21
- end
22
-
23
- hockey_token = opts[:token]
24
- if hockey_token.nil?
25
- puts('ERROR: No api token provided!')
26
- fail(opts)
27
- end
28
-
29
- response = HTTParty.get("https://rink.hockeyapp.net/api/2/apps/#{app_id}/app_versions",
30
- :headers => { 'X-HockeyAppToken' => hockey_token})
31
-
32
- json = JSON.parse(response.body)
33
-
34
- begin
35
- latest = json["app_versions"].first
36
- puts(latest["version"])
37
- rescue Exception
38
- puts(json)
39
- exit 1
6
+ module HockeyVer
7
+
8
+ def self.parse_hockey_version(app_id, api_token)
9
+ # Safety checking
10
+ raise "ERROR: No app id provided!" if app_id.nil?
11
+ raise "ERROR: No api token provided!" if api_token.nil?
12
+
13
+ # Fetch the information
14
+ response = HTTParty.get("https://rink.hockeyapp.net/api/2/apps/#{app_id}/app_versions",
15
+ :headers => { 'X-HockeyAppToken' => api_token})
16
+
17
+ json = JSON.parse(response.body)
18
+
19
+ # Parse the JSON
20
+ begin
21
+ # If found, return version
22
+ latest = json["app_versions"].first
23
+ return(latest["version"])
24
+ rescue Exception
25
+ # Error out and return nil otherwise
26
+ puts("Error while parsing hockey ver JSON. ", json)
27
+ return(nil)
28
+ end
29
+ end
40
30
  end
@@ -0,0 +1,3 @@
1
+ module HockeyVer
2
+ VERSION = "0.1.4"
3
+ end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hockeyver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Welner
8
+ - Dominik Hadl
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-08-19 00:00:00.000000000 Z
12
+ date: 2016-08-20 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: httparty
@@ -38,20 +39,6 @@ dependencies:
38
39
  - - "~>"
39
40
  - !ruby/object:Gem::Version
40
41
  version: '1.7'
41
- - !ruby/object:Gem::Dependency
42
- name: slop
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '4.4'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '4.4'
55
42
  - !ruby/object:Gem::Dependency
56
43
  name: bundler
57
44
  requirement: !ruby/object:Gem::Requirement
@@ -77,6 +64,7 @@ extra_rdoc_files: []
77
64
  files:
78
65
  - bin/hockeyver
79
66
  - lib/hockeyver.rb
67
+ - lib/hockeyver/version.rb
80
68
  homepage: http://nodes.dk
81
69
  licenses:
82
70
  - MIT