big_door 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +72 -0
- data/README.rdoc +170 -0
- data/Rakefile +32 -0
- data/autotest/discover.rb +1 -0
- data/big_door.gemspec +56 -0
- data/bin/example.rb +93 -0
- data/features/resources/attribute.feature +41 -0
- data/features/resources/currency_type.feature +12 -0
- data/features/resources/end_user.feature +92 -0
- data/features/resources/named_award_collection.feature +42 -0
- data/features/resources/named_good_collection.feature +40 -0
- data/features/resources/named_level_collection.feature +44 -0
- data/features/resources/url.feature +41 -0
- data/features/step_definitions/resources_steps.rb +370 -0
- data/features/support/env.rb +9 -0
- data/lib/big_door/attribute.rb +21 -0
- data/lib/big_door/award.rb +24 -0
- data/lib/big_door/client.rb +281 -0
- data/lib/big_door/currency.rb +26 -0
- data/lib/big_door/currency_balance.rb +27 -0
- data/lib/big_door/currency_type.rb +29 -0
- data/lib/big_door/end_user.rb +32 -0
- data/lib/big_door/good.rb +32 -0
- data/lib/big_door/leaderboard.rb +41 -0
- data/lib/big_door/level.rb +25 -0
- data/lib/big_door/named_award.rb +24 -0
- data/lib/big_door/named_award_collection.rb +21 -0
- data/lib/big_door/named_good.rb +24 -0
- data/lib/big_door/named_good_collection.rb +22 -0
- data/lib/big_door/named_level.rb +26 -0
- data/lib/big_door/named_level_collection.rb +23 -0
- data/lib/big_door/named_transaction.rb +21 -0
- data/lib/big_door/named_transaction_group.rb +74 -0
- data/lib/big_door/profile.rb +28 -0
- data/lib/big_door/resource.rb +204 -0
- data/lib/big_door/resource_end_user.rb +84 -0
- data/lib/big_door/resource_with_association.rb +37 -0
- data/lib/big_door/resource_with_parent.rb +43 -0
- data/lib/big_door/url.rb +21 -0
- data/lib/big_door.rb +40 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/big_door/attribute_spec.rb +18 -0
- data/spec/big_door/award_spec.rb +19 -0
- data/spec/big_door/client_spec.rb +163 -0
- data/spec/big_door/currency_balance_spec.rb +14 -0
- data/spec/big_door/currency_spec.rb +81 -0
- data/spec/big_door/currency_type_spec.rb +21 -0
- data/spec/big_door/end_user_spec.rb +23 -0
- data/spec/big_door/good_spec.rb +14 -0
- data/spec/big_door/leaderboard_spec.rb +15 -0
- data/spec/big_door/level_spec.rb +19 -0
- data/spec/big_door/named_award_collection_spec.rb +23 -0
- data/spec/big_door/named_award_spec.rb +23 -0
- data/spec/big_door/named_good_collection_spec.rb +23 -0
- data/spec/big_door/named_good_spec.rb +23 -0
- data/spec/big_door/named_level_collection_spec.rb +23 -0
- data/spec/big_door/named_level_spec.rb +24 -0
- data/spec/big_door/named_transaction_group_spec.rb +29 -0
- data/spec/big_door/named_transaction_spec.rb +23 -0
- data/spec/big_door/profile_spec.rb +19 -0
- data/spec/big_door/resource_end_user_spec.rb +22 -0
- data/spec/big_door/resource_spec.rb +22 -0
- data/spec/big_door/resource_with_association_spec.rb +23 -0
- data/spec/big_door/resource_with_parent_spec.rb +22 -0
- data/spec/big_door/url_spec.rb +23 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +17 -0
- data/tasks/cucumber.rake +5 -0
- data/tasks/rspec.rake +29 -0
- metadata +263 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
module BigDoor
|
2
|
+
#
|
3
|
+
# This module provides NamedTransactionGroup Resource object
|
4
|
+
# corresponding to /named_transaction_group BigDoor API end point
|
5
|
+
#
|
6
|
+
class NamedTransactionGroup < ResourceWithAssociation
|
7
|
+
##
|
8
|
+
# Initialize new NamedTransaction object with optional Hash
|
9
|
+
#
|
10
|
+
# @param [Hash] hash
|
11
|
+
# Optional fields to assign to object
|
12
|
+
#
|
13
|
+
def initialize( hash = {} )
|
14
|
+
$log.debug( "NamedTransactionGroup init with hash = #{hash.inspect}")
|
15
|
+
default_values = {
|
16
|
+
'end_user_cap' => 0,
|
17
|
+
'end_user_cap_interval' => 0,
|
18
|
+
}
|
19
|
+
default_values.merge!( hash )
|
20
|
+
$log.debug( "NamedTransactionGroup default_values = #{default_values.inspect}")
|
21
|
+
super( default_values )
|
22
|
+
end
|
23
|
+
|
24
|
+
##
|
25
|
+
# Executes this NamedTransaction
|
26
|
+
#
|
27
|
+
# @param [String] end_user_login
|
28
|
+
# String representing end_use_login
|
29
|
+
#
|
30
|
+
# @param [Hash] payload
|
31
|
+
# Hash to be converted to HTTP POST form-url-encoded body
|
32
|
+
#
|
33
|
+
# @param [BigDoor::Client] client
|
34
|
+
# Initialized BigDoor::Client object
|
35
|
+
#
|
36
|
+
# @return [Hash] Decoded JSON response if any
|
37
|
+
#
|
38
|
+
def execute( end_user_login, payload, client )
|
39
|
+
$log.debug('execute transaction');
|
40
|
+
|
41
|
+
# FIXME check for self.resource_id defined
|
42
|
+
# FIXME check end_user_login
|
43
|
+
uri = sprintf '%s/%s/execute/%s',
|
44
|
+
end_point,
|
45
|
+
self.resource_id,
|
46
|
+
end_user_login
|
47
|
+
|
48
|
+
$log.debug( sprintf 'uri = %s', uri )
|
49
|
+
payload ||= { 'verbosity' => '6' }
|
50
|
+
payload['verbosity'] = 9 unless payload['verbosity']
|
51
|
+
result = client.post( uri , { 'format' => 'json'}, payload )
|
52
|
+
$log.debug(sprintf 'result = %s', result.inspect );
|
53
|
+
end
|
54
|
+
|
55
|
+
##
|
56
|
+
# Assocaiate this NamedTransactionGroup with NamedTransaction
|
57
|
+
#
|
58
|
+
# @param [BigDoor::NamedTransaction] transaction
|
59
|
+
# NamedTransaction to be associated with
|
60
|
+
#
|
61
|
+
# @param [BigDoor::Client] client
|
62
|
+
# Initialized BigDoor::Client object
|
63
|
+
#
|
64
|
+
# @param [Fixnum] primary
|
65
|
+
# Indicates whether assocatiate NamedTransaction is primary in this
|
66
|
+
# Named Transaction Group
|
67
|
+
#
|
68
|
+
# @return [Hash] Decoded JSON response if any
|
69
|
+
#
|
70
|
+
def associate_with( transaction, client, primary = 1)
|
71
|
+
super( transaction, client, {'named_transaction_is_primary' => primary } )
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module BigDoor
|
2
|
+
#
|
3
|
+
# This module provides Profile Resource object
|
4
|
+
# corresponding to /end_user/{id}/profile BigDoor API end point
|
5
|
+
#
|
6
|
+
class Profile < ResourceEndUser
|
7
|
+
##
|
8
|
+
# Initialize new Profile object with optional Hash
|
9
|
+
#
|
10
|
+
# @param [Hash] hash
|
11
|
+
# Optional fields to assign to object
|
12
|
+
#
|
13
|
+
def initialize( hash = {} )
|
14
|
+
$log.debug( "Profile init with hash = #{hash.inspect}")
|
15
|
+
default_values = {
|
16
|
+
'provider' => 'publisher',
|
17
|
+
'email' => '',
|
18
|
+
'first_name' => '',
|
19
|
+
'last_name' => '',
|
20
|
+
'display_name' => '',
|
21
|
+
'profile_photo' => '',
|
22
|
+
}
|
23
|
+
default_values.merge!( hash )
|
24
|
+
$log.debug( "Profile default_values = #{default_values.inspect}")
|
25
|
+
super( default_values )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,204 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'logger'
|
3
|
+
|
4
|
+
module BigDoor
|
5
|
+
class Resource < OpenStruct
|
6
|
+
##
|
7
|
+
#
|
8
|
+
# This class provides base class for Resource objects
|
9
|
+
#
|
10
|
+
|
11
|
+
|
12
|
+
##
|
13
|
+
# Initialize new Resource object with optional Hash
|
14
|
+
#
|
15
|
+
# @param [Hash] hash
|
16
|
+
# Optional fields to assign to object
|
17
|
+
#
|
18
|
+
def initialize( hash = {})
|
19
|
+
$log.debug( "Resource init with hash = #{hash.inspect}")
|
20
|
+
default_values = {
|
21
|
+
'pub_title' => '',
|
22
|
+
'pub_description' => '',
|
23
|
+
'end_user_title' => '',
|
24
|
+
'end_user_description' => '',
|
25
|
+
}
|
26
|
+
default_values.merge!( hash )
|
27
|
+
$log.debug( "Resource default_values = #{default_values.inspect}")
|
28
|
+
|
29
|
+
if default_values.key?('id')
|
30
|
+
default_values['resource_id'] = default_values['id']
|
31
|
+
default_values.delete('id')
|
32
|
+
end
|
33
|
+
super( default_values )
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Derieve API end point form Class name
|
38
|
+
#
|
39
|
+
# @param [String] Class name
|
40
|
+
#
|
41
|
+
# @return [String] resource name
|
42
|
+
#
|
43
|
+
def self.end_point_from_classname( name )
|
44
|
+
# FIXME should fail if name = Resource
|
45
|
+
$log.debug("end_point_from_classname called with name = #{name}")
|
46
|
+
if name =~ /BigDoor::(.+)$/
|
47
|
+
resource_name = $1
|
48
|
+
|
49
|
+
$log.debug("resource_name = #{resource_name}")
|
50
|
+
|
51
|
+
resource_name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2');
|
52
|
+
resource_name.gsub!(/([a-z\d])([A-Z])/, '\1_\2');
|
53
|
+
# FIXME if no match
|
54
|
+
resource_name.downcase!
|
55
|
+
|
56
|
+
else
|
57
|
+
# FIXME if no match
|
58
|
+
end
|
59
|
+
$log.debug("resource_name = #{resource_name}")
|
60
|
+
resource_name
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Derieve API end point form Class name
|
65
|
+
#
|
66
|
+
# @return [String] resource name
|
67
|
+
#
|
68
|
+
def end_point
|
69
|
+
Resource.end_point_from_classname( self.class.name )
|
70
|
+
end
|
71
|
+
|
72
|
+
##
|
73
|
+
# Derieve API end point form Class name
|
74
|
+
#
|
75
|
+
# @return [String] resource name
|
76
|
+
#
|
77
|
+
def self.end_point
|
78
|
+
end_point_from_classname( self.name )
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Get Resource id for Resource Object. To be overriden in child classes.
|
83
|
+
#
|
84
|
+
# @return [String] resource ID
|
85
|
+
#
|
86
|
+
def get_id
|
87
|
+
self.resource_id
|
88
|
+
end
|
89
|
+
|
90
|
+
##
|
91
|
+
# Convert object content to Hash
|
92
|
+
#
|
93
|
+
# @return [Hash] Object fields
|
94
|
+
#
|
95
|
+
def instance_to_payload
|
96
|
+
payload = {}
|
97
|
+
@table.each do |key, value|
|
98
|
+
payload[key] = value
|
99
|
+
end
|
100
|
+
payload
|
101
|
+
end
|
102
|
+
|
103
|
+
##
|
104
|
+
# Sets object fields to values from response Hash
|
105
|
+
#
|
106
|
+
# @param [Hash] response
|
107
|
+
# Hash representing decoded JSON response from API
|
108
|
+
#
|
109
|
+
# @return nothing
|
110
|
+
#
|
111
|
+
def response_to_instance( response )
|
112
|
+
$log.debug('update instance from response')
|
113
|
+
response.each do |key, value|
|
114
|
+
key = 'resource_id' if key == 'id'
|
115
|
+
self.instance_eval("self.#{key} = \'#{value}\'")
|
116
|
+
$log.debug(sprintf "%s = %s", key, self.instance_eval("self.#{key}") )
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# Saves Resource object. If object has +id+ attribute defined than
|
122
|
+
# +PUT+ method is used, otherwise +POST+ is used.
|
123
|
+
#
|
124
|
+
# @param [BigDoor::Client] client
|
125
|
+
# Initialized BigDoor::Client object
|
126
|
+
#
|
127
|
+
# @return nothing
|
128
|
+
#
|
129
|
+
def save( client )
|
130
|
+
uri = end_point
|
131
|
+
$log.debug( "end_point = #{uri}")
|
132
|
+
payload = instance_to_payload
|
133
|
+
if payload.key?(:resource_id)
|
134
|
+
$log.debug('PUT');
|
135
|
+
response = client.put( sprintf("%s/%s", uri, self.get_id ), { 'format' => 'json' }, payload )
|
136
|
+
else
|
137
|
+
$log.debug('POST');
|
138
|
+
response = client.post( "#{uri}", { 'format' => 'json' }, payload )
|
139
|
+
end
|
140
|
+
response_to_instance( response )
|
141
|
+
end
|
142
|
+
|
143
|
+
##
|
144
|
+
# Loads Resource object identified by optional ID parameter or by
|
145
|
+
# object own resource_id
|
146
|
+
#
|
147
|
+
# @param [BigDoor::Client] client
|
148
|
+
# Initialized BigDoor::Client object
|
149
|
+
#
|
150
|
+
# @param [String] id
|
151
|
+
# Object resource ID
|
152
|
+
#
|
153
|
+
# @return nothing
|
154
|
+
#
|
155
|
+
def load( client, id = nil)
|
156
|
+
id = self.get_id unless id
|
157
|
+
raise ArgumentError.new('Pass id as param or set resource_id for object ') unless id
|
158
|
+
$log.debug('GET');
|
159
|
+
response = client.get( sprintf("%s/%s", end_point, id), { 'format' => 'json' })
|
160
|
+
response_to_instance( response )
|
161
|
+
end
|
162
|
+
|
163
|
+
##
|
164
|
+
# Deletes Resource object identified by optional ID parameter or by
|
165
|
+
# object own resource_id
|
166
|
+
#
|
167
|
+
# @param [BigDoor::Client] client
|
168
|
+
# Initialized BigDoor::Client object
|
169
|
+
#
|
170
|
+
# @param [String] id
|
171
|
+
# Object resource ID
|
172
|
+
#
|
173
|
+
# @return nothing
|
174
|
+
#
|
175
|
+
def delete( client, id = nil)
|
176
|
+
# FIXME if id defined - should use class method
|
177
|
+
id = self.resource_id unless id
|
178
|
+
# FIXME if no id defined
|
179
|
+
client.delete( (sprintf "%s/%s", end_point, id), { 'format' => 'json' })
|
180
|
+
self.resource_id = nil
|
181
|
+
end
|
182
|
+
|
183
|
+
##
|
184
|
+
# Loads all Resource objects by this type
|
185
|
+
#
|
186
|
+
# @param [BigDoor::Client] client
|
187
|
+
# Initialized BigDoor::Client object
|
188
|
+
#
|
189
|
+
# @return [Array] Array of BigDoor::Resource derieved objects
|
190
|
+
#
|
191
|
+
def self.all( client )
|
192
|
+
uri = end_point
|
193
|
+
$log.debug( "end_point = #{uri}")
|
194
|
+
response = client.get( uri, { 'format' => 'json' } )
|
195
|
+
$log.debug( "response to all = #{response}")
|
196
|
+
allobj = response.map{ |obj|
|
197
|
+
$log.debug("obj = #{obj.inspect}")
|
198
|
+
self.new(obj)
|
199
|
+
}
|
200
|
+
$log.debug( "allobj = #{allobj.inspect}")
|
201
|
+
allobj
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module BigDoor
|
2
|
+
|
3
|
+
#
|
4
|
+
# This module provides Resource class with EndUser Parent
|
5
|
+
#
|
6
|
+
|
7
|
+
class ResourceEndUser < Resource
|
8
|
+
##
|
9
|
+
# Calculates Resource object API end point from its class name using
|
10
|
+
# parent_end_point and parent_id_attr (possibly overriden in child classes)
|
11
|
+
#
|
12
|
+
def end_point
|
13
|
+
$log.debug("parent_end_point = #{ResourceEndUser.parent_end_point}")
|
14
|
+
$log.debug("parent_id_attr = #{parent_id_attr}")
|
15
|
+
$log.debug("parent_id_attr value = #{self.instance_eval("self.#{parent_id_attr}")}")
|
16
|
+
|
17
|
+
# FIXME if parent_id_attr empty
|
18
|
+
# FIXME if no self.#{parent_id_attr}
|
19
|
+
ep = sprintf "%s/%s/%s",
|
20
|
+
ResourceEndUser.parent_end_point,
|
21
|
+
self.instance_eval("self.#{parent_id_attr}"),
|
22
|
+
Resource.end_point_from_classname( self.class.name )
|
23
|
+
ep
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Calculates Resource object API end point from its class name using
|
28
|
+
# parent_end_point and parent_id_attr (possibly overriden in child classes)
|
29
|
+
#
|
30
|
+
def self.end_point( username )
|
31
|
+
# FIXME code duplication
|
32
|
+
$log.debug("parent_end_point = #{ResourceEndUser.parent_end_point}")
|
33
|
+
|
34
|
+
# FIXME if parent_id_attr empty
|
35
|
+
# FIXME if no self.#{parent_id_attr}
|
36
|
+
ep = sprintf "%s/%s/%s",
|
37
|
+
ResourceEndUser.parent_end_point,
|
38
|
+
username,
|
39
|
+
Resource.end_point_from_classname( self.name )
|
40
|
+
ep
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Loads all Resource objects by this type
|
45
|
+
#
|
46
|
+
# @param [String] username
|
47
|
+
# end_user_login to be used as base API end point
|
48
|
+
#
|
49
|
+
# @param [BigDoor::Client] client
|
50
|
+
# Initialized BigDoor::Client object
|
51
|
+
#
|
52
|
+
# @return [Array] Array of BigDoor::Resource derieved objects
|
53
|
+
#
|
54
|
+
def self.all( username, client )
|
55
|
+
# FIXME code duplication
|
56
|
+
uri = self.end_point( username )
|
57
|
+
$log.debug( "end_point = #{uri}")
|
58
|
+
response = client.get( uri, { 'format' => 'json' } )
|
59
|
+
$log.debug( "response to all = #{response}")
|
60
|
+
allobj = response.map{ |obj|
|
61
|
+
$log.debug("obj = #{obj.inspect}")
|
62
|
+
self.new(obj)
|
63
|
+
}
|
64
|
+
$log.debug( "allobj = #{allobj.inspect}")
|
65
|
+
allobj
|
66
|
+
end
|
67
|
+
|
68
|
+
##
|
69
|
+
# Gives default base parent_end_point for object.
|
70
|
+
# Can be overriden in inherited classes.
|
71
|
+
#
|
72
|
+
def self.parent_end_point
|
73
|
+
'end_user'
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# Gives default parent_id attribute name for object.
|
78
|
+
# Can be overriden in inherited classes.
|
79
|
+
#
|
80
|
+
def parent_id_attr
|
81
|
+
'end_user_login'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module BigDoor
|
2
|
+
|
3
|
+
#
|
4
|
+
# This module provides Resource class with Association
|
5
|
+
#
|
6
|
+
|
7
|
+
class ResourceWithAssociation < Resource
|
8
|
+
##
|
9
|
+
# Assocaiate this Resource with another Resource
|
10
|
+
#
|
11
|
+
# @param [BigDoor::Resource] resource
|
12
|
+
# Resource to be associated with. See BigDoor documentation for list
|
13
|
+
# of objects which allow association
|
14
|
+
#
|
15
|
+
# @param [BigDoor::Client] client
|
16
|
+
# Initialized BigDoor::Client object
|
17
|
+
#
|
18
|
+
# @param [Hash] payload
|
19
|
+
# Hash to be converted to HTTP POST form-url-encoded body
|
20
|
+
#
|
21
|
+
# @return [Hash] Decoded JSON response if any
|
22
|
+
#
|
23
|
+
def associate_with(resource, client, payload = {})
|
24
|
+
$log.debug('associate_with');
|
25
|
+
|
26
|
+
uri = sprintf '%s/%s/%s/%s',
|
27
|
+
end_point,
|
28
|
+
self.resource_id,
|
29
|
+
resource.resource_name,
|
30
|
+
resource.resource_id
|
31
|
+
|
32
|
+
$log.debug( sprintf 'uri = %s', uri )
|
33
|
+
result = client.post( uri , { 'format' => 'json'}, payload )
|
34
|
+
$log.debug(sprintf 'result = %s', result.inspect );
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module BigDoor
|
2
|
+
|
3
|
+
#
|
4
|
+
# This module provides Resource class with Parent
|
5
|
+
#
|
6
|
+
|
7
|
+
class ResourceWithParent < Resource
|
8
|
+
##
|
9
|
+
# Calculates Resource object API end point from its class name using
|
10
|
+
# parent_end_point and parent_id_attr (possibly overriden in child classes)
|
11
|
+
#
|
12
|
+
def end_point
|
13
|
+
$log.debug("parent_end_point = #{parent_end_point}")
|
14
|
+
$log.debug("parent_id_attr = #{parent_id_attr}")
|
15
|
+
$log.debug("parent_id_attr value = #{self.instance_eval("self.#{parent_id_attr}")}")
|
16
|
+
|
17
|
+
# FIXME if parent_id_attr empty
|
18
|
+
# FIXME if no self.#{parent_id_attr}
|
19
|
+
ep = sprintf "%s/%s/%s",
|
20
|
+
parent_end_point,
|
21
|
+
self.instance_eval("self.#{parent_id_attr}"),
|
22
|
+
Resource.end_point_from_classname( self.class.name )
|
23
|
+
ep
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# Gives default base parent_end_point for object.
|
28
|
+
# Can be overriden in inherited classes.
|
29
|
+
#
|
30
|
+
def parent_end_point
|
31
|
+
resource_name = Resource.end_point_from_classname( self.class.name )
|
32
|
+
"#{resource_name}_collection"
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Gives default parent_id attribute name for object.
|
37
|
+
# Can be overriden in inherited classes.
|
38
|
+
#
|
39
|
+
def parent_id_attr
|
40
|
+
"#{parent_end_point}_id"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/big_door/url.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module BigDoor
|
2
|
+
#
|
3
|
+
# This module provides URL Resource object
|
4
|
+
# corresponding to /url BigDoor API end point
|
5
|
+
#
|
6
|
+
class URL < ResourceWithAssociation
|
7
|
+
##
|
8
|
+
# Initialize new URL object with optional Hash
|
9
|
+
#
|
10
|
+
# @param [Hash] hash
|
11
|
+
# Optional fields to assign to object
|
12
|
+
#
|
13
|
+
def initialize( hash = {} )
|
14
|
+
$log.debug( "URL init with hash = #{hash.inspect}")
|
15
|
+
default_values = { }
|
16
|
+
default_values.merge!( hash )
|
17
|
+
$log.debug( "URL default_values = #{default_values.inspect}")
|
18
|
+
super( default_values )
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/big_door.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'big_door/client'
|
5
|
+
require 'big_door/resource'
|
6
|
+
require 'big_door/resource_with_association'
|
7
|
+
require 'big_door/resource_with_parent'
|
8
|
+
require 'big_door/resource_end_user'
|
9
|
+
|
10
|
+
require 'big_door/attribute'
|
11
|
+
require 'big_door/award'
|
12
|
+
require 'big_door/currency'
|
13
|
+
require 'big_door/currency_balance'
|
14
|
+
require 'big_door/currency_type'
|
15
|
+
require 'big_door/end_user'
|
16
|
+
require 'big_door/good'
|
17
|
+
require 'big_door/leaderboard'
|
18
|
+
require 'big_door/level'
|
19
|
+
require 'big_door/named_award'
|
20
|
+
require 'big_door/named_award_collection'
|
21
|
+
require 'big_door/named_good'
|
22
|
+
require 'big_door/named_good_collection'
|
23
|
+
require 'big_door/named_level'
|
24
|
+
require 'big_door/named_level_collection'
|
25
|
+
require 'big_door/named_transaction'
|
26
|
+
require 'big_door/named_transaction_group'
|
27
|
+
require 'big_door/profile'
|
28
|
+
require 'big_door/url'
|
29
|
+
|
30
|
+
$log = ENV['BIGDOOR_DEBUG'] ? Logger.new('debug.log') : Logger.new( STDERR )
|
31
|
+
$log.level = ENV['BIGDOOR_DEBUG'] ? Logger::DEBUG : Logger::ERROR
|
32
|
+
|
33
|
+
$log.datetime_format = "%Y-%m-%d %H:%M:%S "
|
34
|
+
$log.debug( '=======================')
|
35
|
+
$log.debug( $log.datetime_format)
|
36
|
+
|
37
|
+
|
38
|
+
module BigDoor
|
39
|
+
VERSION = '0.0.1'
|
40
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/bigdoorkit.rb'}"
|
9
|
+
puts "Loading bigdoorkit gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module BigDoor
|
4
|
+
describe Attribute do
|
5
|
+
before(:each) do
|
6
|
+
@client = BigDoor::Client.new( TEST_APP_SECRET, TEST_APP_KEY )
|
7
|
+
end
|
8
|
+
context "Attribute class" do
|
9
|
+
it "Should respond to :all" do
|
10
|
+
BigDoor::Attribute.should respond_to(:all).with(1).arguments
|
11
|
+
end
|
12
|
+
it "Should load Array of Attributes at the beginning" do
|
13
|
+
currency_types = BigDoor::Attribute.all( @client )
|
14
|
+
currency_types.should be_a_instance_of( Array )
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module BigDoor
|
4
|
+
describe Award do
|
5
|
+
before(:each) do
|
6
|
+
@client = BigDoor::Client.new( TEST_APP_SECRET, TEST_APP_KEY )
|
7
|
+
end
|
8
|
+
context "fresh Award object" do
|
9
|
+
subject { BigDoor::Award.new }
|
10
|
+
it { should be }
|
11
|
+
it { should be_a_instance_of( BigDoor::Award )}
|
12
|
+
end
|
13
|
+
context "Award class" do
|
14
|
+
it "Should respond to :all" do
|
15
|
+
BigDoor::Award.should respond_to(:all).with(2).arguments
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|