machineshop 1.0.0 → 1.0.2
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.
- checksums.yaml +4 -4
- data/lib/machineshop.rb +146 -142
- data/lib/machineshop/api_operations/create.rb +1 -1
- data/lib/machineshop/api_operations/delete.rb +1 -1
- data/lib/machineshop/api_operations/list.rb +1 -1
- data/lib/machineshop/api_operations/update.rb +1 -1
- data/lib/machineshop/api_resource.rb +1 -1
- data/lib/machineshop/configuration.rb +5 -2
- data/lib/machineshop/data_source_types.rb +1 -1
- data/lib/machineshop/data_sources.rb +2 -2
- data/lib/machineshop/device.rb +1 -1
- data/lib/machineshop/device_instance.rb +1 -1
- data/lib/machineshop/end_points.rb +30 -0
- data/lib/machineshop/mapping.rb +3 -3
- data/lib/machineshop/models/api_endpoint.rb +8 -0
- data/lib/machineshop/models/api_request.rb +1 -0
- data/lib/machineshop/models/schema.rb +15 -0
- data/lib/machineshop/rule.rb +6 -22
- data/lib/machineshop/user.rb +3 -3
- data/lib/machineshop/users.rb +3 -3
- data/lib/machineshop/util.rb +82 -5
- data/lib/machineshop/utility.rb +2 -2
- data/lib/machineshop/version.rb +1 -1
- data/machineshop.gemspec +2 -6
- data/spec/lib/api_calls_spec.rb +628 -0
- data/spec/lib/custom_endpoint_test.rb +78 -0
- data/spec/lib/customer_spec.rb +39 -14
- data/spec/lib/data_source.rb +2 -0
- data/spec/lib/database_spec.rb +3 -1
- data/spec/lib/device_instances.rb +9 -1
- data/spec/lib/device_spec.rb +24 -0
- data/spec/lib/endpoint_spec.rb +37 -0
- data/spec/lib/{test_spec.rb → geocode_spec} +12 -14
- data/spec/lib/mapping_spec.rb +11 -0
- data/spec/lib/meter_spec.rb +8 -0
- data/spec/lib/report_spec.rb +6 -0
- data/spec/lib/rule_spec.rb +50 -26
- data/spec/lib/user_spec.rb +11 -0
- data/spec/spec_helper.rb +10 -1
- metadata +12 -5
- data/lib/machineshop/models/people.rb +0 -13
data/spec/lib/meter_spec.rb
CHANGED
@@ -19,6 +19,8 @@ describe MachineShop::Meter do
|
|
19
19
|
it "should get all meter data" do
|
20
20
|
element_data = MachineShop::Meter.all({}, auth_token)
|
21
21
|
|
22
|
+
puts "element_data from all: #{element_data}"
|
23
|
+
|
22
24
|
element_data.should_not be_nil
|
23
25
|
element_data.should_not be_empty
|
24
26
|
end
|
@@ -26,14 +28,20 @@ describe MachineShop::Meter do
|
|
26
28
|
it "should get meter by id " do
|
27
29
|
|
28
30
|
meter_id = element_data[0].id
|
31
|
+
ap "retrieving meter for id #{meter_id}"
|
32
|
+
|
33
|
+
# element_data = MachineShop::Meter.retrieve(meter_id, auth_token)
|
29
34
|
element_data = MachineShop::Meter.retrieve(meter_id, auth_token)
|
35
|
+
puts "meter by id : #{element_data}"
|
30
36
|
element_data.should_not be_nil
|
31
37
|
end
|
32
38
|
|
33
39
|
it "should get meters via a user" do
|
34
40
|
|
41
|
+
ap "meters by user "
|
35
42
|
element_data = user.meters
|
36
43
|
|
44
|
+
puts "meters via user: #{element_data}"
|
37
45
|
element_data.should_not be_nil
|
38
46
|
element_data.should_not be_empty
|
39
47
|
end
|
data/spec/lib/report_spec.rb
CHANGED
@@ -19,6 +19,8 @@ describe MachineShop::Report do
|
|
19
19
|
it "should get all report data" do
|
20
20
|
element_data = MachineShop::Report.all({}, auth_token)
|
21
21
|
reports=element_data
|
22
|
+
puts "element_data: #{element_data}"
|
23
|
+
|
22
24
|
element_data.should_not be_nil
|
23
25
|
element_data.should_not be_empty
|
24
26
|
end
|
@@ -32,6 +34,8 @@ reports=element_data
|
|
32
34
|
#:created_at_between=>'2013-11-04T00:00:00_2014-03-19T17:02:00'
|
33
35
|
}), auth_token)
|
34
36
|
|
37
|
+
puts "element data of f00e5981800ad58000006 #{element_data} "
|
38
|
+
|
35
39
|
element_data.should_not be_nil
|
36
40
|
end
|
37
41
|
|
@@ -39,6 +43,8 @@ reports=element_data
|
|
39
43
|
specific_report_id=reports[0].id
|
40
44
|
element_data = MachineShop::Report.retrieve("5384800dff7346390c000001",auth_token)
|
41
45
|
|
46
|
+
puts "report specific #{element_data} "
|
47
|
+
|
42
48
|
element_data.should_not be_nil
|
43
49
|
end
|
44
50
|
|
data/spec/lib/rule_spec.rb
CHANGED
@@ -13,59 +13,75 @@ MachineShop.configure do |config|
|
|
13
13
|
config.db_password="root"
|
14
14
|
config.db_host= "localhost"
|
15
15
|
config.expiry_time= lambda{10.seconds.ago}
|
16
|
-
|
16
|
+
#second
|
17
17
|
end
|
18
18
|
|
19
|
-
auth_token, user = MachineShop::User.authenticate(
|
20
|
-
:email => publisher_username,
|
21
|
-
:password => publisher_password
|
22
|
-
)
|
19
|
+
auth_token, user = MachineShop::User.authenticate(
|
20
|
+
:email => publisher_username,
|
21
|
+
:password => publisher_password
|
22
|
+
)
|
23
23
|
|
24
24
|
|
25
25
|
describe MachineShop::Rule do
|
26
26
|
|
27
27
|
rules=nil
|
28
|
-
|
28
|
+
|
29
29
|
it "should get all the rules " do
|
30
30
|
rules = MachineShop::Rule.all({},auth_token)
|
31
|
+
# puts "rules haru : #{rules}"
|
32
|
+
# ap "getting rules"
|
33
|
+
# ap rules.as_json
|
31
34
|
rules.should_not be_nil
|
35
|
+
|
36
|
+
|
32
37
|
end
|
33
38
|
|
39
|
+
|
40
|
+
|
41
|
+
|
34
42
|
it "should create rule" do
|
35
43
|
|
36
|
-
|
44
|
+
|
45
|
+
create_hash = {
|
37
46
|
:devices=>["52585e1d981800bab2000479"],
|
38
47
|
:device_instances=>[],
|
39
48
|
:rule=>{
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
49
|
+
:active=>true,
|
50
|
+
:description=>"bajratest",
|
51
|
+
:condition=>{
|
52
|
+
:type=>"and_rule_condition",
|
53
|
+
:rule_conditions=>[{
|
54
|
+
|
55
|
+
:property=>"var",
|
56
|
+
:value=>"30",
|
57
|
+
:type=>"equal_rule_condition"
|
58
|
+
|
59
|
+
}]
|
60
|
+
},
|
61
|
+
:then_actions=>[{
|
62
|
+
:priority=>"1",
|
63
|
+
:send_to=>"abc@me.com",
|
64
|
+
:type=>"email_rule_action"
|
50
65
|
}]
|
51
|
-
},
|
52
|
-
:then_actions=>[{
|
53
|
-
:priority=>"1",
|
54
|
-
:send_to=>"abc@me.com",
|
55
|
-
:type=>"email_rule_action"
|
56
|
-
}]
|
57
66
|
}
|
58
|
-
|
67
|
+
}
|
59
68
|
|
69
|
+
# ap "creating rule "
|
60
70
|
createdRule = MachineShop::Rule.create(create_hash,auth_token)
|
71
|
+
|
72
|
+
# ap createdRule.as_json
|
73
|
+
|
61
74
|
createdRule.should_not be_nil
|
62
75
|
|
63
76
|
end
|
64
77
|
|
65
78
|
specificRule = nil
|
66
|
-
|
79
|
+
|
67
80
|
it "should get rule by id" do
|
81
|
+
# ruleById = MachineShop::Rule.retrieve(rules[0].id,auth_token)
|
68
82
|
specificRule = MachineShop::Rule.retrieve("5395b4829818008e790000f9",auth_token)
|
83
|
+
# ap "retrieved rule"
|
84
|
+
# ap specificRule.as_json
|
69
85
|
specificRule.should_not be_nil
|
70
86
|
|
71
87
|
end
|
@@ -73,12 +89,15 @@ describe MachineShop::Rule do
|
|
73
89
|
it "should delete rule by" do
|
74
90
|
# ruleById = MachineShop::Rule.retrieve(rules[0].id,auth_token)
|
75
91
|
delete = specificRule.delete
|
92
|
+
# ap "Deleted rule"
|
93
|
+
# ap delete.as_json
|
76
94
|
delete.should_not be_nil
|
77
95
|
|
78
96
|
end
|
79
97
|
|
80
98
|
it "should get get join rule conditions" do
|
81
99
|
test_data = MachineShop::Rule.get_join_rule_conditions(auth_token)
|
100
|
+
# puts "rule comparison : #{test_data.inspect}"
|
82
101
|
test_data.should_not be_nil
|
83
102
|
|
84
103
|
end
|
@@ -86,6 +105,8 @@ describe MachineShop::Rule do
|
|
86
105
|
|
87
106
|
it "should get comparison rule_conditions" do
|
88
107
|
test_data = MachineShop::Rule.get_comparison_rule_conditions(auth_token)
|
108
|
+
# ap "comparison rule condition :"
|
109
|
+
# ap test_data.as_json
|
89
110
|
test_data.should_not be_nil
|
90
111
|
|
91
112
|
end
|
@@ -93,14 +114,17 @@ describe MachineShop::Rule do
|
|
93
114
|
|
94
115
|
it "should get rule by device_id" do
|
95
116
|
test_data = MachineShop::Rule.get_by_device_instance(auth_token,'52585e1d981800bab2000478')
|
117
|
+
# ap "rule by_device_instance :"
|
118
|
+
# ap test_data.as_json
|
96
119
|
test_data.should_not be_nil
|
97
120
|
|
98
121
|
end
|
99
122
|
|
100
123
|
it "should get deleted rule" do
|
101
124
|
test_data = MachineShop::Rule.get_deleted(auth_token)
|
125
|
+
# puts "deleted rule : #{test_data.inspect}"
|
102
126
|
test_data.should_not be_nil
|
103
127
|
|
104
128
|
end
|
105
|
-
|
129
|
+
|
106
130
|
end
|
data/spec/lib/user_spec.rb
CHANGED
@@ -19,6 +19,8 @@ describe MachineShop::User do
|
|
19
19
|
:password => publisher_password
|
20
20
|
)
|
21
21
|
|
22
|
+
ap "User Data"
|
23
|
+
ap user.as_json
|
22
24
|
auth_token.should_not be_nil
|
23
25
|
user.should_not be_nil
|
24
26
|
user.should be_kind_of MachineShop::User
|
@@ -27,11 +29,17 @@ describe MachineShop::User do
|
|
27
29
|
it "should get all roles from a static instance" do
|
28
30
|
element_data = MachineShop::User.all_roles(auth_token)
|
29
31
|
|
32
|
+
ap "all_roles: "
|
33
|
+
ap element_data.as_json
|
34
|
+
puts element_data
|
35
|
+
|
30
36
|
element_data.should_not be_nil
|
31
37
|
end
|
32
38
|
|
33
39
|
it "should get all roles from a user instance" do
|
34
40
|
|
41
|
+
ap " here user is : "
|
42
|
+
ap user.as_json
|
35
43
|
element_data = user.all_roles
|
36
44
|
element_data.should_not be_nil
|
37
45
|
end
|
@@ -39,6 +47,9 @@ describe MachineShop::User do
|
|
39
47
|
it "should get a user for the user by id" do
|
40
48
|
element_data = MachineShop::User.retrieve(user.id, auth_token)
|
41
49
|
|
50
|
+
ap "user retrieve"
|
51
|
+
ap element_data.as_json
|
52
|
+
|
42
53
|
element_data.should_not be_nil
|
43
54
|
element_data.should be_kind_of MachineShop::User
|
44
55
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,12 @@
|
|
1
1
|
require 'machineshop'
|
2
2
|
require "awesome_print"
|
3
|
-
require "active_support/core_ext"
|
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
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: machineshop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- machineshop
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/machineshop/database.rb
|
153
153
|
- lib/machineshop/device.rb
|
154
154
|
- lib/machineshop/device_instance.rb
|
155
|
+
- lib/machineshop/end_points.rb
|
155
156
|
- lib/machineshop/errors/api_connection_error.rb
|
156
157
|
- lib/machineshop/errors/api_error.rb
|
157
158
|
- lib/machineshop/errors/authentication_error.rb
|
@@ -164,8 +165,8 @@ files:
|
|
164
165
|
- lib/machineshop/machineshop_object.rb
|
165
166
|
- lib/machineshop/mapping.rb
|
166
167
|
- lib/machineshop/meter.rb
|
168
|
+
- lib/machineshop/models/api_endpoint.rb
|
167
169
|
- lib/machineshop/models/api_request.rb
|
168
|
-
- lib/machineshop/models/people.rb
|
169
170
|
- lib/machineshop/models/schema.rb
|
170
171
|
- lib/machineshop/report.rb
|
171
172
|
- lib/machineshop/rule.rb
|
@@ -175,17 +176,20 @@ files:
|
|
175
176
|
- lib/machineshop/utility.rb
|
176
177
|
- lib/machineshop/version.rb
|
177
178
|
- machineshop.gemspec
|
179
|
+
- spec/lib/api_calls_spec.rb
|
180
|
+
- spec/lib/custom_endpoint_test.rb
|
178
181
|
- spec/lib/customer_spec.rb
|
179
182
|
- spec/lib/data_source.rb
|
180
183
|
- spec/lib/data_source_type_spec.rb
|
181
184
|
- spec/lib/database_spec.rb
|
182
185
|
- spec/lib/device_instances.rb
|
183
186
|
- spec/lib/device_spec.rb
|
187
|
+
- spec/lib/endpoint_spec.rb
|
188
|
+
- spec/lib/geocode_spec
|
184
189
|
- spec/lib/mapping_spec.rb
|
185
190
|
- spec/lib/meter_spec.rb
|
186
191
|
- spec/lib/report_spec.rb
|
187
192
|
- spec/lib/rule_spec.rb
|
188
|
-
- spec/lib/test_spec.rb
|
189
193
|
- spec/lib/user_spec.rb
|
190
194
|
- spec/spec_helper.rb
|
191
195
|
homepage: ''
|
@@ -213,16 +217,19 @@ signing_key:
|
|
213
217
|
specification_version: 4
|
214
218
|
summary: A convenient way to call into the machineshop API.
|
215
219
|
test_files:
|
220
|
+
- spec/lib/api_calls_spec.rb
|
221
|
+
- spec/lib/custom_endpoint_test.rb
|
216
222
|
- spec/lib/customer_spec.rb
|
217
223
|
- spec/lib/data_source.rb
|
218
224
|
- spec/lib/data_source_type_spec.rb
|
219
225
|
- spec/lib/database_spec.rb
|
220
226
|
- spec/lib/device_instances.rb
|
221
227
|
- spec/lib/device_spec.rb
|
228
|
+
- spec/lib/endpoint_spec.rb
|
229
|
+
- spec/lib/geocode_spec
|
222
230
|
- spec/lib/mapping_spec.rb
|
223
231
|
- spec/lib/meter_spec.rb
|
224
232
|
- spec/lib/report_spec.rb
|
225
233
|
- spec/lib/rule_spec.rb
|
226
|
-
- spec/lib/test_spec.rb
|
227
234
|
- spec/lib/user_spec.rb
|
228
235
|
- spec/spec_helper.rb
|