test_machine_shop 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.idea/.name +1 -0
  3. data/.idea/.rakeTasks +7 -0
  4. data/.idea/compiler.xml +23 -0
  5. data/.idea/copyright/profiles_settings.xml +5 -0
  6. data/.idea/encodings.xml +5 -0
  7. data/.idea/inspectionProfiles/Project_Default.xml +7 -0
  8. data/.idea/inspectionProfiles/profiles_settings.xml +7 -0
  9. data/.idea/machineshop.iml +194 -0
  10. data/.idea/misc.xml +5 -0
  11. data/.idea/modules.xml +9 -0
  12. data/.idea/scopes/scope_settings.xml +5 -0
  13. data/.idea/vcs.xml +7 -0
  14. data/.idea/workspace.xml +722 -0
  15. data/Gemfile +9 -0
  16. data/LICENSE +22 -0
  17. data/README.md +977 -0
  18. data/Rakefile +8 -0
  19. data/doc.txt +50 -0
  20. data/lib/machineshop.rb +475 -0
  21. data/lib/machineshop/api_operations/create.rb +17 -0
  22. data/lib/machineshop/api_operations/delete.rb +11 -0
  23. data/lib/machineshop/api_operations/list.rb +16 -0
  24. data/lib/machineshop/api_operations/update.rb +11 -0
  25. data/lib/machineshop/api_resource.rb +35 -0
  26. data/lib/machineshop/configuration.rb +14 -0
  27. data/lib/machineshop/customer.rb +15 -0
  28. data/lib/machineshop/data_source_types.rb +28 -0
  29. data/lib/machineshop/data_sources.rb +35 -0
  30. data/lib/machineshop/database.rb +59 -0
  31. data/lib/machineshop/device.rb +30 -0
  32. data/lib/machineshop/device_instance.rb +30 -0
  33. data/lib/machineshop/end_points.rb +30 -0
  34. data/lib/machineshop/errors/api_connection_error.rb +4 -0
  35. data/lib/machineshop/errors/api_error.rb +4 -0
  36. data/lib/machineshop/errors/authentication_error.rb +4 -0
  37. data/lib/machineshop/errors/database_error.rb +5 -0
  38. data/lib/machineshop/errors/invalid_request_error.rb +10 -0
  39. data/lib/machineshop/errors/machineshop_error.rb +20 -0
  40. data/lib/machineshop/errors/schema_error.rb +5 -0
  41. data/lib/machineshop/json.rb +21 -0
  42. data/lib/machineshop/machineshop_cache.rb +49 -0
  43. data/lib/machineshop/machineshop_object.rb +165 -0
  44. data/lib/machineshop/mapping.rb +34 -0
  45. data/lib/machineshop/meter.rb +12 -0
  46. data/lib/machineshop/models/api_endpoint.rb +8 -0
  47. data/lib/machineshop/models/api_request.rb +28 -0
  48. data/lib/machineshop/models/schema.rb +184 -0
  49. data/lib/machineshop/report.rb +11 -0
  50. data/lib/machineshop/rule.rb +42 -0
  51. data/lib/machineshop/user.rb +43 -0
  52. data/lib/machineshop/users.rb +43 -0
  53. data/lib/machineshop/util.rb +193 -0
  54. data/lib/machineshop/utility.rb +30 -0
  55. data/lib/machineshop/version.rb +3 -0
  56. data/machineshop.gemspec +35 -0
  57. data/spec/lib/api_calls_spec.rb +628 -0
  58. data/spec/lib/custom_endpoint_test.rb +78 -0
  59. data/spec/lib/customer_spec.rb +87 -0
  60. data/spec/lib/data_source.rb +138 -0
  61. data/spec/lib/data_source_type_spec.rb +77 -0
  62. data/spec/lib/database_spec.rb +45 -0
  63. data/spec/lib/device_instances.rb +73 -0
  64. data/spec/lib/device_spec.rb +172 -0
  65. data/spec/lib/endpoint_spec.rb +37 -0
  66. data/spec/lib/geocode_spec +45 -0
  67. data/spec/lib/mapping_spec.rb +68 -0
  68. data/spec/lib/meter_spec.rb +49 -0
  69. data/spec/lib/report_spec.rb +52 -0
  70. data/spec/lib/rule_spec.rb +130 -0
  71. data/spec/lib/user_spec.rb +58 -0
  72. data/spec/spec_helper.rb +12 -0
  73. metadata +235 -0
@@ -0,0 +1,58 @@
1
+ require_relative '../spec_helper'
2
+
3
+
4
+ #MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
5
+ MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
6
+
7
+ #publisher_username = 'publisher@machineshop.com'
8
+ publisher_username = 'admin@csr.com'
9
+ publisher_password = 'password'
10
+
11
+ describe MachineShop::User do
12
+ auth_token = nil
13
+ user = nil
14
+
15
+ it "should allow a user to authenticate" do
16
+ auth_token.should be_nil
17
+ auth_token, user = MachineShop::User.authenticate(
18
+ :email => publisher_username,
19
+ :password => publisher_password
20
+ )
21
+
22
+ ap "User Data"
23
+ ap user.as_json
24
+ auth_token.should_not be_nil
25
+ user.should_not be_nil
26
+ user.should be_kind_of MachineShop::User
27
+ end
28
+
29
+ it "should get all roles from a static instance" do
30
+ element_data = MachineShop::User.all_roles(auth_token)
31
+
32
+ ap "all_roles: "
33
+ ap element_data.as_json
34
+ puts element_data
35
+
36
+ element_data.should_not be_nil
37
+ end
38
+
39
+ it "should get all roles from a user instance" do
40
+
41
+ ap " here user is : "
42
+ ap user.as_json
43
+ element_data = user.all_roles
44
+ element_data.should_not be_nil
45
+ end
46
+
47
+ it "should get a user for the user by id" do
48
+ element_data = MachineShop::User.retrieve(user.id, auth_token)
49
+
50
+ ap "user retrieve"
51
+ ap element_data.as_json
52
+
53
+ element_data.should_not be_nil
54
+ element_data.should be_kind_of MachineShop::User
55
+ end
56
+
57
+ end
58
+
@@ -0,0 +1,12 @@
1
+ require 'machineshop'
2
+ require "awesome_print"
3
+ require "active_support/core_ext"
4
+
5
+ MachineShop.configure do |config|
6
+ config.db_name = "machineshop"
7
+ config.db_username="root"
8
+ config.db_password="root"
9
+ config.db_host= "localhost"
10
+ config.expiry_time= lambda{120.seconds.ago}
11
+ #second
12
+ end
metadata ADDED
@@ -0,0 +1,235 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test_machine_shop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - machineshop
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: rspec
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: mysql
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
+ - !ruby/object:Gem::Dependency
56
+ name: addressable
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rest-client
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: multi_json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.0.4
90
+ - - <
91
+ - !ruby/object:Gem::Version
92
+ version: '2'
93
+ type: :runtime
94
+ prerelease: false
95
+ version_requirements: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: 1.0.4
100
+ - - <
101
+ - !ruby/object:Gem::Version
102
+ version: '2'
103
+ - !ruby/object:Gem::Dependency
104
+ name: activerecord
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 4.0.0
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: 4.0.0
117
+ description: Wraps the machineshop API.
118
+ email:
119
+ - john@mach19.com
120
+ executables: []
121
+ extensions: []
122
+ extra_rdoc_files: []
123
+ files:
124
+ - .idea/.name
125
+ - .idea/.rakeTasks
126
+ - .idea/compiler.xml
127
+ - .idea/copyright/profiles_settings.xml
128
+ - .idea/encodings.xml
129
+ - .idea/inspectionProfiles/Project_Default.xml
130
+ - .idea/inspectionProfiles/profiles_settings.xml
131
+ - .idea/machineshop.iml
132
+ - .idea/misc.xml
133
+ - .idea/modules.xml
134
+ - .idea/scopes/scope_settings.xml
135
+ - .idea/vcs.xml
136
+ - .idea/workspace.xml
137
+ - Gemfile
138
+ - LICENSE
139
+ - README.md
140
+ - Rakefile
141
+ - doc.txt
142
+ - lib/machineshop.rb
143
+ - lib/machineshop/api_operations/create.rb
144
+ - lib/machineshop/api_operations/delete.rb
145
+ - lib/machineshop/api_operations/list.rb
146
+ - lib/machineshop/api_operations/update.rb
147
+ - lib/machineshop/api_resource.rb
148
+ - lib/machineshop/configuration.rb
149
+ - lib/machineshop/customer.rb
150
+ - lib/machineshop/data_source_types.rb
151
+ - lib/machineshop/data_sources.rb
152
+ - lib/machineshop/database.rb
153
+ - lib/machineshop/device.rb
154
+ - lib/machineshop/device_instance.rb
155
+ - lib/machineshop/end_points.rb
156
+ - lib/machineshop/errors/api_connection_error.rb
157
+ - lib/machineshop/errors/api_error.rb
158
+ - lib/machineshop/errors/authentication_error.rb
159
+ - lib/machineshop/errors/database_error.rb
160
+ - lib/machineshop/errors/invalid_request_error.rb
161
+ - lib/machineshop/errors/machineshop_error.rb
162
+ - lib/machineshop/errors/schema_error.rb
163
+ - lib/machineshop/json.rb
164
+ - lib/machineshop/machineshop_cache.rb
165
+ - lib/machineshop/machineshop_object.rb
166
+ - lib/machineshop/mapping.rb
167
+ - lib/machineshop/meter.rb
168
+ - lib/machineshop/models/api_endpoint.rb
169
+ - lib/machineshop/models/api_request.rb
170
+ - lib/machineshop/models/schema.rb
171
+ - lib/machineshop/report.rb
172
+ - lib/machineshop/rule.rb
173
+ - lib/machineshop/user.rb
174
+ - lib/machineshop/users.rb
175
+ - lib/machineshop/util.rb
176
+ - lib/machineshop/utility.rb
177
+ - lib/machineshop/version.rb
178
+ - machineshop.gemspec
179
+ - spec/lib/api_calls_spec.rb
180
+ - spec/lib/custom_endpoint_test.rb
181
+ - spec/lib/customer_spec.rb
182
+ - spec/lib/data_source.rb
183
+ - spec/lib/data_source_type_spec.rb
184
+ - spec/lib/database_spec.rb
185
+ - spec/lib/device_instances.rb
186
+ - spec/lib/device_spec.rb
187
+ - spec/lib/endpoint_spec.rb
188
+ - spec/lib/geocode_spec
189
+ - spec/lib/mapping_spec.rb
190
+ - spec/lib/meter_spec.rb
191
+ - spec/lib/report_spec.rb
192
+ - spec/lib/rule_spec.rb
193
+ - spec/lib/user_spec.rb
194
+ - spec/spec_helper.rb
195
+ homepage: ''
196
+ licenses: []
197
+ metadata: {}
198
+ post_install_message: Thanks for installing Machineshop gem, Enjoy!!
199
+ rdoc_options: []
200
+ require_paths:
201
+ - lib
202
+ required_ruby_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - '>='
205
+ - !ruby/object:Gem::Version
206
+ version: 1.9.3
207
+ required_rubygems_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - '>='
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ requirements:
213
+ - mysql, activerecord
214
+ rubyforge_project:
215
+ rubygems_version: 2.2.1
216
+ signing_key:
217
+ specification_version: 4
218
+ summary: A convenient way to call into the machineshop API.
219
+ test_files:
220
+ - spec/lib/api_calls_spec.rb
221
+ - spec/lib/custom_endpoint_test.rb
222
+ - spec/lib/customer_spec.rb
223
+ - spec/lib/data_source.rb
224
+ - spec/lib/data_source_type_spec.rb
225
+ - spec/lib/database_spec.rb
226
+ - spec/lib/device_instances.rb
227
+ - spec/lib/device_spec.rb
228
+ - spec/lib/endpoint_spec.rb
229
+ - spec/lib/geocode_spec
230
+ - spec/lib/mapping_spec.rb
231
+ - spec/lib/meter_spec.rb
232
+ - spec/lib/report_spec.rb
233
+ - spec/lib/rule_spec.rb
234
+ - spec/lib/user_spec.rb
235
+ - spec/spec_helper.rb