big_door 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,12 @@
1
+ === 0.0.2 2011-02-03
2
+
3
+ * 1 minor enhancement:
4
+ * added HTTP calls timing to debug output
5
+
6
+ * 3 minor bugfixes
7
+ Leaderboard#execute, NamedTransactionGroup#execute and
8
+ ResourceWithAssociation were all missing returning result
9
+
1
10
  === 0.0.1 2010-12-14
2
11
 
3
12
  * 1 major enhancement:
data/big_door.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{big_door}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Alex L. Demidov"]
9
- s.date = %q{2011-01-26}
9
+ s.date = %q{2011-02-03}
10
10
  s.default_executable = %q{example.rb}
11
11
  s.description = %q{Client library for the BigDoor REST API (http://bigdoor.com). This package
12
12
  provides both low-level procedural (BigDoor::Client) and object-oriented
@@ -3,6 +3,7 @@ require 'addressable/uri'
3
3
  require 'json'
4
4
  require 'digest/sha1'
5
5
  require 'uuidtools'
6
+ require 'benchmark'
6
7
 
7
8
  module BigDoor
8
9
  #
@@ -267,7 +268,11 @@ module BigDoor
267
268
  $log.debug( sprintf 'method url = %s %s', method, url )
268
269
  $log.debug( sprintf 'payload = %s', payload.inspect )
269
270
 
270
- response = RestClient::Request.execute(:method => method, :url => url.to_s, :payload => payload, :headers => headers, :raw_response => false)
271
+ response = nil
272
+ ms = Benchmark.measure {
273
+ response = RestClient::Request.execute(:method => method, :url => url.to_s, :payload => payload, :headers => headers, :raw_response => false)
274
+ }
275
+ $log.debug("delay #{'%.1f' % (ms.real * 1000)} ms")
271
276
  if response && !response.empty?
272
277
  $log.debug( sprintf 'undecoded_response = %s', response.inspect )
273
278
  decoded_response = JSON.parse( response )
@@ -36,6 +36,7 @@ module BigDoor
36
36
  $log.debug( sprintf 'execute uri = %s', uri )
37
37
  result = client.get( uri , params )
38
38
  $log.debug(sprintf 'result = %s', result.inspect );
39
+ result
39
40
  end
40
41
  end
41
42
  end
@@ -50,6 +50,7 @@ module BigDoor
50
50
  payload['verbosity'] = 9 unless payload['verbosity']
51
51
  result = client.post( uri , { 'format' => 'json'}, payload )
52
52
  $log.debug(sprintf 'result = %s', result.inspect );
53
+ result
53
54
  end
54
55
 
55
56
  ##
@@ -32,6 +32,7 @@ module BigDoor
32
32
  $log.debug( sprintf 'uri = %s', uri )
33
33
  result = client.post( uri , { 'format' => 'json'}, payload )
34
34
  $log.debug(sprintf 'result = %s', result.inspect );
35
+ result
35
36
  end
36
37
  end
37
38
  end
data/lib/big_door.rb CHANGED
@@ -36,5 +36,5 @@ $log.debug( $log.datetime_format)
36
36
 
37
37
 
38
38
  module BigDoor
39
- VERSION = '0.0.1'
39
+ VERSION = '0.0.2'
40
40
  end
@@ -10,6 +10,22 @@ module BigDoor
10
10
  it { should be }
11
11
  it { should be_a_instance_of( BigDoor::Leaderboard )}
12
12
  it { should respond_to(:execute).with(2).arguments}
13
+ it "Should return Array on execute" do
14
+ currency = BigDoor::Currency.new({
15
+ 'pub_title' => 'Coins',
16
+ 'pub_description' => 'an example of the Purchase currency type',
17
+ 'end_user_title' => 'Coins',
18
+ 'end_user_description' => 'can only be purchased',
19
+ 'currency_type_id' => 1,
20
+ 'currency_type_title' => 'Purchase',
21
+ 'exchange_rate' => 900,
22
+ 'relative_weight' => 2,
23
+ })
24
+ currency.save( @client )
25
+ result = subject.execute( { 'format' => 'json', 'verbosity' => '9', 'type' => 'currency', 'filter_value' => currency.resource_id }, @client )
26
+ result['results'].should be_a_instance_of( Array )
27
+ currency.delete( @client )
28
+ end
13
29
  end
14
30
  end
15
31
  end
@@ -24,6 +24,93 @@ module BigDoor
24
24
  it { should respond_to(:execute).with(3).arguments}
25
25
  it { should respond_to(:associate_with).with(2).arguments}
26
26
  it { should respond_to(:associate_with).with(3).arguments}
27
+ it "Should return Array on associate_with" do
28
+ currency = BigDoor::Currency.new({
29
+ 'pub_title' => 'Coins',
30
+ 'pub_description' => 'an example of the Purchase currency type',
31
+ 'end_user_title' => 'Coins',
32
+ 'end_user_description' => 'can only be purchased',
33
+ 'currency_type_id' => 1,
34
+ 'currency_type_title' => 'Purchase',
35
+ 'exchange_rate' => 900,
36
+ 'relative_weight' => 2,
37
+ })
38
+ currency.save( @client )
39
+ ntg = BigDoor::NamedTransactionGroup.new({
40
+ 'pub_title' => 'Test Transaction Group',
41
+ 'pub_description' => 'test description',
42
+ 'end_user_title' => 'end user title',
43
+ 'end_user_description' => 'end user description',
44
+ 'end_user_cap' => '-1',
45
+ 'end_user_cap_interval' => '-1',
46
+ })
47
+ ntg.save( @client )
48
+
49
+ nt = BigDoor::NamedTransaction.new({
50
+ 'pub_title' => 'Test Transaction',
51
+ 'pub_description' => 'test description',
52
+ 'end_user_title' => 'end user title',
53
+ 'end_user_description' => 'end user description',
54
+ 'currency_id' => currency.resource_id,
55
+ 'amount' => '50',
56
+ 'default_amount' => '50',
57
+ })
58
+ nt.save( @client )
59
+
60
+ result = ntg.associate_with( nt, @client, 1 )
61
+ result.should be_a_instance_of( Hash )
62
+ result['resource_name'].should == 'transaction_group_to_transaction'
63
+
64
+ ntg.delete( @client )
65
+ nt.delete( @client )
66
+ currency.delete( @client )
67
+ end
68
+ it "Should return Array on execute" do
69
+ username = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
70
+ end_user = BigDoor::EndUser.new({
71
+ 'end_user_login' => username
72
+ })
73
+ end_user.save( @client )
74
+ currency = BigDoor::Currency.new({
75
+ 'pub_title' => 'Coins',
76
+ 'pub_description' => 'an example of the Purchase currency type',
77
+ 'end_user_title' => 'Coins',
78
+ 'end_user_description' => 'can only be purchased',
79
+ 'currency_type_id' => 1,
80
+ 'currency_type_title' => 'Purchase',
81
+ 'exchange_rate' => 900,
82
+ 'relative_weight' => 2,
83
+ })
84
+ currency.save( @client )
85
+ ntg = BigDoor::NamedTransactionGroup.new({
86
+ 'pub_title' => 'Test Transaction Group',
87
+ 'pub_description' => 'test description',
88
+ 'end_user_title' => 'end user title',
89
+ 'end_user_description' => 'end user description',
90
+ 'end_user_cap' => '-1',
91
+ 'end_user_cap_interval' => '-1',
92
+ })
93
+ ntg.save( @client )
94
+
95
+ nt = BigDoor::NamedTransaction.new({
96
+ 'pub_title' => 'Test Transaction',
97
+ 'pub_description' => 'test description',
98
+ 'end_user_title' => 'end user title',
99
+ 'end_user_description' => 'end user description',
100
+ 'currency_id' => currency.resource_id,
101
+ 'amount' => '50',
102
+ 'default_amount' => '50',
103
+ })
104
+ nt.save( @client )
105
+ ntg.associate_with( nt, @client, 1 )
106
+ result = ntg.execute( username, { 'good_receiver' => username , 'verbosity' => '9', 'allow_negative_balance' => 'true'}, @client )
107
+ result.should be_a_instance_of( Hash )
108
+ result['transaction_group_id'].should be
109
+ ntg.delete( @client )
110
+ nt.delete( @client )
111
+ currency.delete( @client )
112
+ end_user.delete( @client )
113
+ end
27
114
  end
28
115
  end
29
116
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: big_door
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 27
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 1
9
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
10
11
  platform: ruby
11
12
  authors:
12
13
  - Alex L. Demidov
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-26 00:00:00 +03:00
18
+ date: 2011-02-03 00:00:00 +03:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,6 +26,7 @@ dependencies:
25
26
  requirements:
26
27
  - - ~>
27
28
  - !ruby/object:Gem::Version
29
+ hash: 15
28
30
  segments:
29
31
  - 1
30
32
  - 0
@@ -39,6 +41,7 @@ dependencies:
39
41
  requirements:
40
42
  - - ~>
41
43
  - !ruby/object:Gem::Version
44
+ hash: 3
42
45
  segments:
43
46
  - 2
44
47
  - 0
@@ -53,6 +56,7 @@ dependencies:
53
56
  requirements:
54
57
  - - ~>
55
58
  - !ruby/object:Gem::Version
59
+ hash: 15
56
60
  segments:
57
61
  - 1
58
62
  - 0
@@ -67,6 +71,7 @@ dependencies:
67
71
  requirements:
68
72
  - - ~>
69
73
  - !ruby/object:Gem::Version
74
+ hash: 3
70
75
  segments:
71
76
  - 2
72
77
  - 0
@@ -81,6 +86,7 @@ dependencies:
81
86
  requirements:
82
87
  - - ~>
83
88
  - !ruby/object:Gem::Version
89
+ hash: 31
84
90
  segments:
85
91
  - 0
86
92
  - 10
@@ -95,6 +101,7 @@ dependencies:
95
101
  requirements:
96
102
  - - ~>
97
103
  - !ruby/object:Gem::Version
104
+ hash: 11
98
105
  segments:
99
106
  - 2
100
107
  - 4
@@ -109,6 +116,7 @@ dependencies:
109
116
  requirements:
110
117
  - - ">="
111
118
  - !ruby/object:Gem::Version
119
+ hash: 47
112
120
  segments:
113
121
  - 2
114
122
  - 8
@@ -217,6 +225,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
225
  requirements:
218
226
  - - ">="
219
227
  - !ruby/object:Gem::Version
228
+ hash: 3
220
229
  segments:
221
230
  - 0
222
231
  version: "0"
@@ -225,13 +234,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
234
  requirements:
226
235
  - - ">="
227
236
  - !ruby/object:Gem::Version
237
+ hash: 3
228
238
  segments:
229
239
  - 0
230
240
  version: "0"
231
241
  requirements: []
232
242
 
233
243
  rubyforge_project: big_door
234
- rubygems_version: 1.3.7
244
+ rubygems_version: 1.4.2
235
245
  signing_key:
236
246
  specification_version: 3
237
247
  summary: Client library for the BigDoor REST API (http://bigdoor.com)