phone_gap-build 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: def3c1fe04ee9c71d97860ca06ada7b491b720e5
4
+ data.tar.gz: 13040e4d4859a256fd9abecf9cd8a05c2a7256c1
5
+ SHA512:
6
+ metadata.gz: 0b65111712fdfe2bed7ee68ad7cf3e7193c97920582011b9550f206a49338b5f5181d922bd0e3909fab29298a1761210ab0aadf8f95bf202476d5bc3e97d4d0a
7
+ data.tar.gz: 3981955216cfa781999ce4130fea294520621d5206230236533719d13ecce85040d17d1ef7427762bddb401b6c8cecd92ea430ccca3041d4e97fc4420340e9a9
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in phone_gap-build.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Seb Glazebrook
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # PhoneGap::Build
2
+
3
+ A simple Ruby api client for PhoneGap Build.
4
+
5
+ I made this as the only other Ruby gem didn't work.
6
+
7
+ Selfishly I have/will only include the api calls that I require.
8
+
9
+ If people start using it or pull requests come in then we'll see what happens.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'phone_gap-build'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install phone_gap-build
24
+
25
+ ## Usage
26
+
27
+ require 'phone_gap/build'
28
+
29
+ PhoneGap::Build.credentials(token: 'my_api_token')
30
+
31
+ apps = PhoneGap::Build.apps
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it ( https://github.com/sebglazebrook/phone_gap-build/fork )
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ # for RSpec
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new('spec')
@@ -0,0 +1,14 @@
1
+ module PhoneGap
2
+ module Build
3
+ class App
4
+
5
+ def initialize(params)
6
+ params.each do |key, value|
7
+ instance_variable_set("@#{key}", value)
8
+ singleton_class.class_eval { attr_accessor key }
9
+ end
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module PhoneGap
2
+ module Build
3
+ class AppFactory
4
+
5
+ def self.create_many(attributes)
6
+ attributes['apps'].map do |attrs|
7
+ create(attrs)
8
+ end
9
+ end
10
+
11
+ def self.create(attributes)
12
+ App.new(attributes)
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ module PhoneGap
2
+ module Build
3
+ class Credentials
4
+
5
+ attr_reader :username, :password, :token
6
+
7
+ def initialize(params)
8
+ @username, @password, @token = params[:username], params[:password], params[:token]
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ module PhoneGap
2
+ module Build
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ require 'phone_gap/build/version'
2
+ require 'phone_gap/build/credentials'
3
+ require 'phone_gap/build/app_factory'
4
+ require 'phone_gap/build/app'
5
+
6
+ require 'httparty'
7
+
8
+ module PhoneGap
9
+ module Build
10
+
11
+ def self.credentials(credentials)
12
+ @credentials = Credentials.new(credentials)
13
+ end
14
+
15
+ def self.apps
16
+ http_response = HTTParty.get("https://build.phonegap.com/api/v1/apps?auth_token=#{@credentials.token}")
17
+ parsed_response = JSON.parse(http_response.body)
18
+ AppFactory.create_many(parsed_response)
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'phone_gap/build/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'phone_gap-build'
8
+ spec.version = PhoneGap::Build::VERSION
9
+ spec.authors = ['Seb Glazebrook']
10
+ spec.email = ['me@sebglazebrook.com']
11
+ spec.summary = %q{PhoneGap Build Api gem}
12
+ spec.description = %q{}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'httparty'
22
+
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec', '~> 2.14.1'
26
+ spec.add_development_dependency 'debugger'
27
+ end
@@ -0,0 +1,62 @@
1
+ {
2
+ "apps": [
3
+ {
4
+ "title": "My Index",
5
+ "id": 1,
6
+ "package": "com.my.index",
7
+ "version": "0.0.1",
8
+ "repo": null,
9
+ "description": "An Index of My Applications",
10
+ "debug": false,
11
+ "private": true,
12
+ "link": "/api/v1/apps/1",
13
+ "build_count": 4,
14
+ "phonegap_version": "2.9.0",
15
+ "hydrates": false,
16
+ "status": {
17
+ "android": "complete",
18
+ "ios": null,
19
+ "winphone": "pending"
20
+ },
21
+ "download": {
22
+ "android": "/api/v1/apps/1/android"
23
+ },
24
+ "error": {
25
+ },
26
+ "icon": {
27
+ "filename": "icon.png",
28
+ "link": "/api/v1/apps/1/icon"
29
+ },
30
+ "role": "admin"
31
+ },
32
+ {
33
+ "title": "PhoneGap: Getting Started",
34
+ "id": 2,
35
+ "package": "com.phonegap.getting.started",
36
+ "version": "1.0.0",
37
+ "repo": "https://github.com/phonegap/phonegap-start.git",
38
+ "description": "A template for getting started with PhoneGap development and build.phonegap.com",
39
+ "debug": false,
40
+ "private": true,
41
+ "link": "/api/v1/apps/2",
42
+ "build_count": 12,
43
+ "status": {
44
+ "android": "complete",
45
+ "ios": "complete",
46
+ "winphone": "complete"
47
+ },
48
+ "download": {
49
+ "android": "/api/v1/apps/1/android",
50
+ "ios": "/api/v1/apps/1/ios",
51
+ "winphone": "/api/v1/apps/1/winphone"
52
+ },
53
+ "error": {},
54
+ "icon": {
55
+ "filename": "big-icon.png",
56
+ "link": "/api/v1/apps/2/icon"
57
+ },
58
+ "role": "admin"
59
+ }
60
+ ],
61
+ "link": "/api/v1/apps"
62
+ }
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe PhoneGap::Build::App do
4
+
5
+ describe 'upon instantiation' do
6
+
7
+ context 'when given parameters' do
8
+
9
+ let(:params) do
10
+ { name: 'Batman', title: 'Dark Knight', status: { height: 'tall', weight: 'heavy'} }
11
+ end
12
+
13
+ subject { PhoneGap::Build::App.new(params) }
14
+
15
+ it 'makes an attribute of each parameter' do
16
+ expect(subject.name).to eq 'Batman'
17
+ expect(subject.title).to eq 'Dark Knight'
18
+ expect(subject.status).to eq({height: 'tall', weight: 'heavy'})
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'httparty'
3
+
4
+ describe PhoneGap::Build do
5
+
6
+ subject { PhoneGap::Build }
7
+
8
+ describe '#credentials' do
9
+
10
+ describe 'token authentication' do
11
+
12
+ it 'gets stored for future api calls' do
13
+ subject.credentials(token: 'some awesome token')
14
+ expect(subject.instance_variable_get(:'@credentials').token).to eq 'some awesome token'
15
+ end
16
+ end
17
+ end
18
+
19
+ context 'with token authentication' do
20
+
21
+ let(:token) { 'BATMAN' }
22
+
23
+ before do
24
+ subject.credentials(token: token)
25
+ end
26
+
27
+ describe '#apps' do
28
+
29
+ let(:url) { "https://build.phonegap.com/api/v1/apps?auth_token=#{token}" }
30
+ let(:api_response) { double(body: response_body_for('get-apps')) }
31
+
32
+ before do
33
+ HTTParty.stub(:get).with(url).and_return api_response
34
+ end
35
+
36
+ it 'makes a call to the api' do
37
+ expect(HTTParty).to receive(:get).with(url).and_return api_response
38
+ subject.apps
39
+ end
40
+
41
+ it 'returns a collection of apps' do
42
+ expect(subject.apps.size).to eq 2
43
+ expect(subject.apps.first).to be_kind_of PhoneGap::Build::App
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,15 @@
1
+ require 'rspec'
2
+ require_relative '../lib/phone_gap/build'
3
+
4
+ ROOT_DIR = Pathname.new(File.expand_path('..', __FILE__))
5
+
6
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
7
+
8
+ RSpec.configure do |config|
9
+ config.color_enabled = true
10
+ config.formatter = 'documentation'
11
+ end
12
+
13
+
14
+
15
+
@@ -0,0 +1,6 @@
1
+ require 'json'
2
+
3
+ def response_body_for(request)
4
+ fixture_file = File.open(ROOT_DIR + "fixtures/api_responses/#{request}.json")
5
+ File.read(fixture_file)
6
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: phone_gap-build
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Seb Glazebrook
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
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
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
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: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: debugger
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: ''
84
+ email:
85
+ - me@sebglazebrook.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - LICENSE.txt
93
+ - README.md
94
+ - Rakefile
95
+ - lib/phone_gap/build.rb
96
+ - lib/phone_gap/build/app.rb
97
+ - lib/phone_gap/build/app_factory.rb
98
+ - lib/phone_gap/build/credentials.rb
99
+ - lib/phone_gap/build/version.rb
100
+ - phone_gap-build.gemspec
101
+ - spec/fixtures/api_responses/get-apps.json
102
+ - spec/phone_gap/build/app_spec.rb
103
+ - spec/phone_gap/build_spec.rb
104
+ - spec/spec_helper.rb
105
+ - spec/support/fixtures.rb
106
+ homepage: ''
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: PhoneGap Build Api gem
130
+ test_files:
131
+ - spec/fixtures/api_responses/get-apps.json
132
+ - spec/phone_gap/build/app_spec.rb
133
+ - spec/phone_gap/build_spec.rb
134
+ - spec/spec_helper.rb
135
+ - spec/support/fixtures.rb