machineshop 1.0.2 → 1.1.1

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.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +45 -0
  3. data/{Gemfile → machineshop/Gemfile} +0 -0
  4. data/{LICENSE → machineshop/LICENSE} +0 -0
  5. data/{Rakefile → machineshop/Rakefile} +0 -0
  6. data/{doc.txt → machineshop/doc.txt} +0 -0
  7. data/{lib → machineshop/lib}/machineshop.rb +29 -18
  8. data/{lib → machineshop/lib}/machineshop/api_operations/create.rb +0 -0
  9. data/{lib → machineshop/lib}/machineshop/api_operations/delete.rb +0 -0
  10. data/{lib → machineshop/lib}/machineshop/api_operations/list.rb +0 -0
  11. data/{lib → machineshop/lib}/machineshop/api_operations/update.rb +0 -0
  12. data/machineshop/lib/machineshop/api_proxies.rb +20 -0
  13. data/{lib → machineshop/lib}/machineshop/api_resource.rb +1 -1
  14. data/{lib → machineshop/lib}/machineshop/configuration.rb +2 -1
  15. data/machineshop/lib/machineshop/custom_api.rb +28 -0
  16. data/machineshop/lib/machineshop/custom_apis.rb +21 -0
  17. data/{lib → machineshop/lib}/machineshop/customer.rb +1 -1
  18. data/machineshop/lib/machineshop/customers.rb +20 -0
  19. data/{lib → machineshop/lib}/machineshop/data_source_types.rb +12 -2
  20. data/machineshop/lib/machineshop/data_sources.rb +57 -0
  21. data/{lib → machineshop/lib}/machineshop/database.rb +0 -0
  22. data/{lib → machineshop/lib}/machineshop/device.rb +0 -0
  23. data/{lib → machineshop/lib}/machineshop/device_instance.rb +0 -0
  24. data/{lib → machineshop/lib}/machineshop/end_points.rb +0 -0
  25. data/{lib → machineshop/lib}/machineshop/errors/api_connection_error.rb +0 -0
  26. data/{lib → machineshop/lib}/machineshop/errors/api_error.rb +0 -0
  27. data/{lib → machineshop/lib}/machineshop/errors/authentication_error.rb +0 -0
  28. data/{lib → machineshop/lib}/machineshop/errors/database_error.rb +0 -0
  29. data/{lib → machineshop/lib}/machineshop/errors/invalid_request_error.rb +0 -0
  30. data/{lib → machineshop/lib}/machineshop/errors/machineshop_error.rb +0 -0
  31. data/{lib → machineshop/lib}/machineshop/errors/schema_error.rb +0 -0
  32. data/machineshop/lib/machineshop/gateway_configs.rb +34 -0
  33. data/machineshop/lib/machineshop/gateway_data_source_types.rb +18 -0
  34. data/machineshop/lib/machineshop/gateway_data_sources.rb +60 -0
  35. data/{lib → machineshop/lib}/machineshop/json.rb +0 -0
  36. data/{lib → machineshop/lib}/machineshop/machineshop_cache.rb +0 -0
  37. data/{lib → machineshop/lib}/machineshop/machineshop_object.rb +7 -2
  38. data/{lib → machineshop/lib}/machineshop/mapping.rb +0 -0
  39. data/{lib → machineshop/lib}/machineshop/meter.rb +1 -2
  40. data/{lib → machineshop/lib}/machineshop/models/api_endpoint.rb +0 -0
  41. data/{lib → machineshop/lib}/machineshop/models/api_request.rb +0 -0
  42. data/{lib → machineshop/lib}/machineshop/models/schema.rb +2 -1
  43. data/machineshop/lib/machineshop/monitor.rb +39 -0
  44. data/machineshop/lib/machineshop/report.rb +11 -0
  45. data/{lib/machineshop/report.rb → machineshop/lib/machineshop/reports.rb} +3 -1
  46. data/machineshop/lib/machineshop/routes.rb +29 -0
  47. data/{lib → machineshop/lib}/machineshop/rule.rb +0 -0
  48. data/machineshop/lib/machineshop/rules.rb +56 -0
  49. data/{lib → machineshop/lib}/machineshop/user.rb +22 -4
  50. data/machineshop/lib/machineshop/users.rb +81 -0
  51. data/{lib → machineshop/lib}/machineshop/util.rb +22 -11
  52. data/{lib → machineshop/lib}/machineshop/utility.rb +0 -0
  53. data/{lib → machineshop/lib}/machineshop/version.rb +1 -1
  54. data/{machineshop.gemspec → machineshop/machineshop.gemspec} +2 -1
  55. data/{spec → machineshop/spec}/lib/api_calls_spec.rb +0 -0
  56. data/machineshop/spec/lib/api_proxies_spec.rb +91 -0
  57. data/machineshop/spec/lib/custom_api_spec.rb +0 -0
  58. data/machineshop/spec/lib/custom_api_vo_spec.rb +77 -0
  59. data/{spec → machineshop/spec}/lib/custom_endpoint_test.rb +0 -0
  60. data/{spec → machineshop/spec}/lib/customer_spec.rb +21 -8
  61. data/{spec → machineshop/spec}/lib/data_source.rb +0 -0
  62. data/{spec → machineshop/spec}/lib/data_source_type_spec.rb +0 -0
  63. data/{spec → machineshop/spec}/lib/database_spec.rb +0 -0
  64. data/{spec → machineshop/spec}/lib/device_instances.rb +0 -0
  65. data/{spec → machineshop/spec}/lib/device_spec.rb +0 -0
  66. data/{spec → machineshop/spec}/lib/endpoint_spec.rb +0 -0
  67. data/{spec → machineshop/spec}/lib/geocode_spec +0 -0
  68. data/machineshop/spec/lib/logo_spec.rb +51 -0
  69. data/{spec → machineshop/spec}/lib/mapping_spec.rb +0 -0
  70. data/{spec → machineshop/spec}/lib/meter_spec.rb +3 -3
  71. data/machineshop/spec/lib/monitor_spec.rb +50 -0
  72. data/machineshop/spec/lib/new_api_key.rb +28 -0
  73. data/machineshop/spec/lib/report_spec.rb +91 -0
  74. data/machineshop/spec/lib/reports_v1_spec.rb +65 -0
  75. data/machineshop/spec/lib/routes_spec.rb +26 -0
  76. data/{spec → machineshop/spec}/lib/rule_spec.rb +30 -24
  77. data/machineshop/spec/lib/user_spec.rb +99 -0
  78. data/machineshop/spec/lib/v1_rules_spec.rb +106 -0
  79. data/{spec → machineshop/spec}/spec_helper.rb +0 -0
  80. metadata +115 -110
  81. data/.idea/.name +0 -1
  82. data/.idea/.rakeTasks +0 -7
  83. data/.idea/compiler.xml +0 -23
  84. data/.idea/copyright/profiles_settings.xml +0 -5
  85. data/.idea/encodings.xml +0 -5
  86. data/.idea/inspectionProfiles/Project_Default.xml +0 -7
  87. data/.idea/inspectionProfiles/profiles_settings.xml +0 -7
  88. data/.idea/machineshop.iml +0 -194
  89. data/.idea/misc.xml +0 -5
  90. data/.idea/modules.xml +0 -9
  91. data/.idea/scopes/scope_settings.xml +0 -5
  92. data/.idea/vcs.xml +0 -7
  93. data/.idea/workspace.xml +0 -722
  94. data/lib/machineshop/data_sources.rb +0 -35
  95. data/lib/machineshop/users.rb +0 -43
  96. data/spec/lib/report_spec.rb +0 -52
  97. data/spec/lib/user_spec.rb +0 -58
@@ -1,35 +0,0 @@
1
- module MachineShop
2
- class DataSources < APIResource
3
- include MachineShop::APIOperations::List
4
- include MachineShop::APIOperations::Create
5
- include MachineShop::APIOperations::Update
6
- # include MachineShop::APIOperations::Delete
7
-
8
- # Specific API calls
9
-
10
- def report_count(params)
11
- MachineShop.gem_get(report_count_url, @auth_token, params)
12
- end
13
-
14
- def reports(filters={})
15
- filters.merge!(:device_instance_id => self.id)
16
- MachineShop::Report.all(filters, @auth_token)
17
- end
18
-
19
- def meters(filters={})
20
- filters.merge!(:device_instance_id => self.id)
21
- MachineShop::Meter.all(filters, @auth_token)
22
- end
23
-
24
- def delete
25
- MachineShop.gem_delete("/platform/data_sources/#{self.id}?_type=#{self._type}", @auth_token,{})
26
- end
27
-
28
- private
29
-
30
- def report_count_url
31
- url + '/report_count'
32
- end
33
-
34
- end
35
- end
@@ -1,43 +0,0 @@
1
- module MachineShop
2
- class Users < APIResource
3
-
4
- # Specific API calls
5
- def self.authenticate(user_hash)
6
- #user_hash is => { email: email, password: password }
7
- response = MachineShop.gem_post(authenticate_url, nil, user_hash)
8
- auth_token = response[:authentication_token]
9
- id = response[:_id]
10
-
11
- return auth_token, self.retrieve(id, auth_token)
12
- end
13
-
14
- def self.all_roles(auth_token)
15
- MachineShop.gem_get(self.role_url, auth_token)
16
- end
17
-
18
- def all_roles
19
- MachineShop.gem_get(self.class.role_url, @auth_token)
20
- end
21
-
22
- def device_instances(filters={})
23
- filters.merge!(:user_id => self.id)
24
- MachineShop::DeviceInstance.all(filters, @auth_token)
25
- end
26
-
27
- def meters(filters={})
28
- filters.merge!(:user_id => self.id)
29
- MachineShop::Meter.all(filters, @auth_token)
30
- end
31
-
32
- private
33
-
34
- def self.authenticate_url
35
- '/user_session/user/authenticate'
36
- end
37
-
38
- def self.role_url
39
- '/platform/role'
40
- end
41
-
42
- end
43
- end
@@ -1,52 +0,0 @@
1
- require_relative '../spec_helper'
2
-
3
- #MachineShop.api_base_url= 'http://machineshop.dev:3000/api/v0'
4
- MachineShop.api_base_url= 'http://stage.services.machineshop.io/api/v0'
5
-
6
- #publisher_username = 'publisher@machineshop.com'
7
- publisher_username = 'publisher@csr.com'
8
- publisher_password = 'password'
9
-
10
-
11
- auth_token, user = MachineShop::User.authenticate(
12
- :email => publisher_username,
13
- :password => publisher_password
14
- )
15
-
16
- reports=nil
17
- describe MachineShop::Report do
18
-
19
- it "should get all report data" do
20
- element_data = MachineShop::Report.all({}, auth_token)
21
- reports=element_data
22
- puts "element_data: #{element_data}"
23
-
24
- element_data.should_not be_nil
25
- element_data.should_not be_empty
26
- end
27
-
28
-
29
-
30
- it "should get report of specific device" do
31
- element_data = MachineShop::Report.all(
32
- ({:device_instance_id => '538461dc9818006e0900005e',
33
- :per_page=>'1000',
34
- #:created_at_between=>'2013-11-04T00:00:00_2014-03-19T17:02:00'
35
- }), auth_token)
36
-
37
- puts "element data of f00e5981800ad58000006 #{element_data} "
38
-
39
- element_data.should_not be_nil
40
- end
41
-
42
- it "should get specific report by id" do
43
- specific_report_id=reports[0].id
44
- element_data = MachineShop::Report.retrieve("5384800dff7346390c000001",auth_token)
45
-
46
- puts "report specific #{element_data} "
47
-
48
- element_data.should_not be_nil
49
- end
50
-
51
-
52
- end
@@ -1,58 +0,0 @@
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
-