phonegap-api 1.1.0 → 1.2.0

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.
@@ -15,8 +15,11 @@ https://build.phonegap.com/docs/api
15
15
 
16
16
  Create connection
17
17
 
18
- conn = Phonegap::Connection.new("username", "password")
18
+ conn = Phonegap::Connection.new(:username => "username", :password =>"password")
19
19
 
20
+ Or with config/phonegap.yml populated with phonegap build credentials
21
+
22
+ conn = Phonegap::Connection.new
20
23
 
21
24
  List applications
22
25
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -0,0 +1,2 @@
1
+ :username: ian@ruby-code.com
2
+ :password: password1!
@@ -8,32 +8,38 @@ module Phonegap
8
8
  follow_redirects false
9
9
  format :json
10
10
 
11
- def initialize(username, password)
12
- @auth = {:basic_auth => {:username => username, :password => password}}
11
+ def initialize(*auth)
12
+ if auth != []
13
+ @auth = {:basic_auth => auth}
14
+ else
15
+ @auth = {:basic_auth => YAML.load_file("config/phonegap.yml")}
16
+ end
13
17
  end
14
18
 
15
19
  def get(url)
16
- output = self.class.get(url, @auth).parsed_response
17
- check_response!(output)
20
+ puts @auth.inspect
21
+ output = self.class.get(url, @auth)
22
+ check_response!(output).parsed_response
18
23
  end
19
24
 
20
25
  def post(url, body)
21
- output = self.class.post(url, @auth.merge!({:body =>{:data => body}})).parsed_response
22
- check_response!(output)
26
+ output = self.class.post(url, @auth.merge!({:body =>{:data => body}}))
27
+ check_response!(output).parsed_response
23
28
  end
24
29
 
25
30
  def put(url, body)
26
- output = self.class.put(url, @auth.merge!({:body =>{:data => body}})).parsed_response
27
- check_response!(output)
31
+ output = self.class.put(url, @auth.merge!({:body =>{:data => body}}))
32
+ check_response!(output).parsed_response
28
33
  end
29
34
 
30
35
  def delete(url)
31
- output = self.class.delete(url, @auth).parsed_response
32
- check_response!(output)
36
+ output = self.class.delete(url, @auth)
37
+ check_response!(output).parsed_response
33
38
  end
34
39
 
35
40
  def check_response!(output)
36
41
  raise APIError, output['error'] if output['error'].class == String
42
+
37
43
  output
38
44
  end
39
45
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "phonegap-api"
8
- s.version = "1.1.0"
8
+ s.version = "1.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ian Morgan"]
12
- s.date = "2012-04-10"
12
+ s.date = "2012-07-14"
13
13
  s.description = "Ruby wrapper to the Phonegap build API"
14
14
  s.email = "ian@ruby-code.com"
15
15
  s.extra_rdoc_files = [
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "README.rdoc",
26
26
  "Rakefile",
27
27
  "VERSION",
28
+ "config/phonegap.yml.example",
28
29
  "lib/phonegap-api.rb",
29
30
  "lib/phonegap-api/app.rb",
30
31
  "lib/phonegap-api/apps.rb",
@@ -38,7 +39,7 @@ Gem::Specification.new do |s|
38
39
  s.homepage = "http://github.com/seeingidog/phonegap-api"
39
40
  s.licenses = ["MIT"]
40
41
  s.require_paths = ["lib"]
41
- s.rubygems_version = "1.8.10"
42
+ s.rubygems_version = "1.8.24"
42
43
  s.summary = "Ruby wrapper to the Phonegap build API"
43
44
 
44
45
  if s.respond_to? :specification_version then
@@ -1,56 +1,71 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
 
4
- describe "PhonegapApi" do
5
- before(:each) do
6
- @username = ""
7
- @password = ""
8
- @conn = Phonegap::Connection.new(@username, @password)
9
- end
10
-
11
- it "recieves information about current user" do
12
- @conn.me.keys.should == ["apps", "keys", "username", "id", "link", "email"]
13
- end
14
-
15
- it "retrieves list of keys for account" do
16
- @conn.keys.class.should == Hash
17
- end
18
-
19
- it "gets list of apps" do
20
- @conn.apps.class.should == Phonegap::Apps
4
+ describe "Phonegap config reading" do
5
+ it "reads the config and creates api object" do
6
+ Phonegap::Connection.new.class.should == Phonegap::Connection
21
7
  end
22
-
23
- it "retrieves information about a specific app" do
24
- @conn.get_app(94659).class.should == Phonegap::App
25
- end
26
-
27
- it "retrieves the URL to the app icon" do
28
- @conn.get_icon(94659)["location"].class.should == String
8
+ end
9
+
10
+ describe "Phonegap API operations" do
11
+ before(:each) do
12
+ #assumes config/phonegap.yml exists with credentials
13
+ @conn = Phonegap::Connection.new
14
+ @specific_app_id = 94659
29
15
  end
30
16
 
31
- it "retrieves the URL to the app icon" do
32
- @conn.get_package_url(94659, "android").class.should == String
33
- end
34
17
 
35
- it "returns an App object from API return data" do
36
- @conn.get_app(94659).class.should == Phonegap::App
18
+ describe "Read operations" do
19
+
20
+ it "recieves information about current user" do
21
+ @conn.me.keys.sort.should == ["apps", "keys", "username", "id", "link", "email"].sort
22
+ end
23
+
24
+ it "retrieves list of keys for account" do
25
+ @conn.keys.class.should == Hash
26
+ end
27
+
28
+ it "gets list of apps" do
29
+ @conn.apps.class.should == Phonegap::Apps
30
+ end
31
+
32
+ it "retrieves information about a specific app" do
33
+ @conn.get_app(@specific_app_id).class.should == Phonegap::App
34
+ end
35
+
36
+ it "retrieves the URL to the app icon" do
37
+ @conn.get_icon(@specific_app_id)["location"].class.should == String
38
+ end
39
+
40
+ it "retrieves the URL to the app icon" do
41
+ @conn.get_package_url(@specific_app_id, "android").class.should == String
42
+ end
43
+
44
+ it "returns an App object from API return data" do
45
+ @conn.get_app(@specific_app_id).class.should == Phonegap::App
46
+ end
47
+
48
+ it "returns json usable by the API from an App object" do
49
+ obj = @conn.get_app(@specific_app_id)
50
+ obj.to_json.class.should == String
51
+ end
52
+
37
53
  end
38
54
 
39
- it "returns json usable by the API from an App object" do
40
- obj = @conn.get_app(94659)
41
- obj.to_json.class.should == String
42
- end
55
+ describe "Write operations" do
43
56
 
44
- it "returns an Apps object composed of individual apps based on API return data" do
45
- @conn.apps.class.should == Phonegap::Apps
46
- end
57
+ it "returns an Apps object composed of individual apps based on API return data" do
58
+ @conn.apps.class.should == Phonegap::Apps
59
+ end
47
60
 
48
- it "creates an app" do
49
- @app_id = @conn.create_app(:title => 'API test app', :repo => 'https://github.com/alunny/phonegap-start.git', :create_method => 'remote_repo')['id']
50
- end
61
+ it "creates an app" do
62
+ @app_id = @conn.create_app(:title => 'API test app', :repo => 'https://github.com/alunny/phonegap-start.git', :create_method => 'remote_repo')['id']
63
+ end
51
64
 
52
- it "deletes the created app" do
53
- @conn.delete_app(@app_id)
54
- end
55
-
65
+ it "deletes the created app" do
66
+ @conn.delete_app(@app_id)
67
+ end
68
+
69
+ end
70
+
56
71
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phonegap-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-10 00:00:00.000000000Z
12
+ date: 2012-07-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
16
- requirement: &2153871280 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2153871280
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: rspec
27
- requirement: &2153870220 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: 2.8.0
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *2153870220
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.8.0
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: rdoc
38
- requirement: &2153869340 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '3.12'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *2153869340
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: bundler
49
- requirement: &2153868340 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: 1.0.0
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *2153868340
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.0
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: jeweler
60
- requirement: &2153866900 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: 1.8.3
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *2153866900
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.8.3
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: simplecov
71
- requirement: &2153865600 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,7 +101,12 @@ dependencies:
76
101
  version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *2153865600
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  description: Ruby wrapper to the Phonegap build API
81
111
  email: ian@ruby-code.com
82
112
  executables: []
@@ -93,6 +123,7 @@ files:
93
123
  - README.rdoc
94
124
  - Rakefile
95
125
  - VERSION
126
+ - config/phonegap.yml.example
96
127
  - lib/phonegap-api.rb
97
128
  - lib/phonegap-api/app.rb
98
129
  - lib/phonegap-api/apps.rb
@@ -117,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
148
  version: '0'
118
149
  segments:
119
150
  - 0
120
- hash: -3199833197196286911
151
+ hash: 3020109460896854963
121
152
  required_rubygems_version: !ruby/object:Gem::Requirement
122
153
  none: false
123
154
  requirements:
@@ -126,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
157
  version: '0'
127
158
  requirements: []
128
159
  rubyforge_project:
129
- rubygems_version: 1.8.10
160
+ rubygems_version: 1.8.24
130
161
  signing_key:
131
162
  specification_version: 3
132
163
  summary: Ruby wrapper to the Phonegap build API