hockeyhelper 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 84b31e41e4246673cf43b1671a0fc205ac1fb816
4
+ data.tar.gz: 1f10602b546ce8c5a9e304282277c50e3317456f
5
+ SHA512:
6
+ metadata.gz: 600285712ac5710c9b120e29e8d088d7f9a2dd0791ccfcb226b5f1df0437625f8d858733acd3d6319d0597ce0198e361640d36ff8b2b10152b3e9096d03f7f38
7
+ data.tar.gz: 1de0fbb7332569483739909115d8a14b79f7973dc46cc105d71aa5c9b2879913ccca3976e3c12f85cee91dbd0422c341b23205cc69ac08f227c07c29f42bf273
data/.gitignore ADDED
@@ -0,0 +1,36 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ # Gemfile.lock
30
+ # .ruby-version
31
+ # .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+
36
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,2 @@
1
+ language: ruby
2
+ rvm: 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hockeyhelper.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem 'rspec'
8
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Hiroki Yagita
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Hockey
2
+
3
+ Helper gem for HokceyApp API
4
+
5
+ [![Build Status](https://travis-ci.org/yagihiro/hockey.svg?branch=master)](https://travis-ci.org/yagihiro/hockey)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'hockeyhelper'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install hockeyhelper
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/hockey/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :test => :spec
7
+ task :default => :spec
data/hockey.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hockeyhelper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hockeyhelper"
8
+ spec.version = Hockey::VERSION
9
+ spec.authors = ["Hiroki Yagita"]
10
+ spec.email = ["yagihiro@gmail.com"]
11
+ spec.summary = %q{Helper gem for HokceyApp API}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.required_ruby_version = '>= 2.0.0'
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_dependency "faraday"
25
+ end
@@ -0,0 +1,73 @@
1
+ module Hockey
2
+
3
+ # App on HockeyApp
4
+ class App
5
+
6
+ attr_reader :title
7
+ attr_reader :bundle_identifier
8
+ attr_reader :public_identifier
9
+ attr_reader :device_family
10
+ attr_reader :minimum_os_version
11
+ attr_reader :release_type
12
+ attr_reader :status
13
+ attr_reader :platform
14
+ attr_reader :original_hash
15
+
16
+ attr :net, :users
17
+
18
+ def self.create_from(hashobj, networking)
19
+ self.new hashobj, networking
20
+ end
21
+
22
+ def initialize(hashobj, networking)
23
+ @title = hashobj['title']
24
+ @bundle_identifier = hashobj['bundle_identifier']
25
+ @public_identifier = hashobj['public_identifier']
26
+ @device_family = hashobj['device_family']
27
+ @minimum_os_version = hashobj['minimum_os_version']
28
+ @release_type = hashobj['release_type']
29
+ @status = hashobj['status']
30
+ @platform = hashobj['platform']
31
+ @original_hash = hashobj
32
+ @net = networking
33
+ @users = nil
34
+ end
35
+
36
+ def inspect
37
+ "#{@title}, #{@bundle_identifier}, #{@platform}, #{@public_identifier}"
38
+ end
39
+ alias_method :to_s, :inspect
40
+
41
+ def remove_user(email:nil)
42
+ users()
43
+ user = @users.find {|u| u.email == email }
44
+
45
+ if user
46
+ @net.delete "/api/2/apps/#{@public_identifier}/app_users/#{user.id}"
47
+ end
48
+ end
49
+
50
+ def users
51
+ return @users if @users
52
+
53
+ obj = @net.get_object "/api/2/apps/#{@public_identifier}/app_users"
54
+
55
+ @users = []
56
+ obj['app_users'].each do |hashobj|
57
+ @users << User.create_from(hashobj, @net)
58
+ end
59
+
60
+ @users
61
+ end
62
+
63
+ def invite_user(email:email)
64
+ obj = @net.post_object "/api/2/apps/#{@public_identifier}/app_users", {:email=>email, :role=>1}
65
+
66
+ user = User.create_from(obj, @net)
67
+
68
+ user
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,40 @@
1
+ require_relative 'app'
2
+ require_relative 'networking'
3
+
4
+ module Hockey
5
+
6
+ # HockeyApp API Client for Application
7
+ class Client
8
+
9
+ #
10
+ def initialize(token, debug:false)
11
+ @net = Networking.new token, debug:debug
12
+ @apps = nil
13
+ end
14
+
15
+ # return Array of App objects
16
+ def apps
17
+ return @apps if @apps
18
+
19
+ obj = @net.get_object '/api/2/apps'
20
+
21
+ @apps = []
22
+ obj['apps'].each do |hashobj|
23
+ @apps << App.create_from(hashobj, @net)
24
+ end
25
+
26
+ @apps
27
+ end
28
+
29
+ # create new app on HockeyApp
30
+ def new_app(title:title, bundle_identifier:bundle_identifier, platform: 'iOS')
31
+ obj = @net.post_object '/api/2/apps/new', {:title=>title, :bundle_identifier=>bundle_identifier, :platform=>platform, :release_type=>0}
32
+
33
+ app = App.create_from(obj, @net)
34
+
35
+ app
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,78 @@
1
+ require 'faraday'
2
+ require 'json'
3
+ require 'logger'
4
+
5
+ module Hockey
6
+
7
+ class NullLogger < Logger
8
+ def initialize *args
9
+ end
10
+ def debug; end
11
+ def info; end
12
+ def warn; end
13
+ def error; end
14
+ def fatal; end
15
+ end
16
+
17
+ # Networking Core Lib
18
+ class Networking
19
+
20
+ attr :l
21
+
22
+ def initialize(token, debug:false)
23
+ @client = Faraday.new(:url => 'https://rink.hockeyapp.net')
24
+ @token = token
25
+ @l = if debug
26
+ Logger.new(STDOUT)
27
+ else
28
+ NullLogger.new
29
+ end
30
+ end
31
+
32
+ def get(path)
33
+ @l.info "GET #{path}"
34
+
35
+ response = @client.get do |req|
36
+ req.url path
37
+ req.headers['X-HockeyAppToken'] = @token
38
+ end
39
+
40
+ response
41
+ end
42
+
43
+ def get_object(path)
44
+ response = get path
45
+ JSON.parse(response.body) || {}
46
+ end
47
+
48
+ def post(path, bodyhash)
49
+ @l.info "POST #{path}, #{bodyhash}"
50
+
51
+ response = @client.post do |req|
52
+ req.url path
53
+ req.headers['X-HockeyAppToken'] = @token
54
+ req.body = bodyhash
55
+ end
56
+
57
+ response
58
+ end
59
+
60
+ def post_object(path, bodyhash)
61
+ response = post path, bodyhash
62
+ JSON.parse(response.body) || {}
63
+ end
64
+
65
+ def delete(path)
66
+ @l.info "DELETE #{path}"
67
+
68
+ response = @client.delete do |req|
69
+ req.url path
70
+ req.headers['X-HockeyAppToken'] = @token
71
+ end
72
+
73
+ response
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -0,0 +1,38 @@
1
+ module Hockey
2
+
3
+ # User on HockeyApp
4
+ class User
5
+
6
+ attr_reader :role
7
+ attr_reader :id
8
+ attr_reader :user_id
9
+ attr_reader :full_name
10
+ attr_reader :email
11
+ attr_reader :invited_at
12
+ attr_reader :original_hash
13
+
14
+ attr :net
15
+
16
+ def self.create_from(hashobj, networking)
17
+ self.new hashobj, networking
18
+ end
19
+
20
+ def initialize(hashobj, networking)
21
+ @role = hashobj['role']
22
+ @id = hashobj['id']
23
+ @user_id = hashobj['user_id']
24
+ @full_name = hashobj['full_name']
25
+ @email = hashobj['email']
26
+ @invited_at = hashobj['invited_at']
27
+ @original_hash = hashobj
28
+ @net = networking
29
+ end
30
+
31
+ def inspect
32
+ "#{@user_id}, #{@full_name}, #{@email}"
33
+ end
34
+ alias_method :to_s, :inspect
35
+
36
+ end
37
+
38
+ end
@@ -0,0 +1,3 @@
1
+ module Hockey
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require 'hockeyhelper/app'
2
+ require 'hockeyhelper/client'
3
+ require 'hockeyhelper/networking'
4
+ require 'hockeyhelper/user'
5
+ require 'hockeyhelper/version'
6
+
data/spec/app_spec.rb ADDED
@@ -0,0 +1,5 @@
1
+ require_relative '../lib/hockeyhelper/app'
2
+
3
+ RSpec.describe Hockey::App do
4
+
5
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hockeyhelper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Hiroki Yagita
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: faraday
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - yagihiro@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - .travis.yml
64
+ - Gemfile
65
+ - LICENSE
66
+ - README.md
67
+ - Rakefile
68
+ - hockey.gemspec
69
+ - lib/hockeyhelper.rb
70
+ - lib/hockeyhelper/app.rb
71
+ - lib/hockeyhelper/client.rb
72
+ - lib/hockeyhelper/networking.rb
73
+ - lib/hockeyhelper/user.rb
74
+ - lib/hockeyhelper/version.rb
75
+ - spec/app_spec.rb
76
+ homepage: ''
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: 2.0.0
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.2.2
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Helper gem for HokceyApp API
100
+ test_files:
101
+ - spec/app_spec.rb