machineshop 0.0.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.
- checksums.yaml +7 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/compiler.xml +23 -0
- data/.idea/copyright/profiles_settings.xml +5 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/inspectionProfiles/Project_Default.xml +7 -0
- data/.idea/inspectionProfiles/profiles_settings.xml +7 -0
- data/.idea/machineshop.iml +194 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +722 -0
- data/Gemfile +8 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +8 -0
- data/doc.txt +50 -0
- data/lib/machineshop.rb +234 -0
- data/lib/machineshop/api_operations/create.rb +17 -0
- data/lib/machineshop/api_operations/delete.rb +11 -0
- data/lib/machineshop/api_operations/list.rb +16 -0
- data/lib/machineshop/api_operations/update.rb +17 -0
- data/lib/machineshop/api_resource.rb +35 -0
- data/lib/machineshop/configuration.rb +11 -0
- data/lib/machineshop/customer.rb +9 -0
- data/lib/machineshop/database.rb +112 -0
- data/lib/machineshop/device.rb +30 -0
- data/lib/machineshop/device_instance.rb +30 -0
- data/lib/machineshop/errors/api_error.rb +4 -0
- data/lib/machineshop/errors/authentication_error.rb +4 -0
- data/lib/machineshop/errors/database_error.rb +5 -0
- data/lib/machineshop/errors/invalid_request_error.rb +10 -0
- data/lib/machineshop/errors/machineshop_error.rb +20 -0
- data/lib/machineshop/json.rb +21 -0
- data/lib/machineshop/machineshop_cache.rb +49 -0
- data/lib/machineshop/machineshop_object.rb +164 -0
- data/lib/machineshop/mapping.rb +34 -0
- data/lib/machineshop/meter.rb +12 -0
- data/lib/machineshop/models/people.rb +11 -0
- data/lib/machineshop/report.rb +11 -0
- data/lib/machineshop/rule.rb +58 -0
- data/lib/machineshop/user.rb +43 -0
- data/lib/machineshop/util.rb +115 -0
- data/lib/machineshop/utility.rb +30 -0
- data/lib/machineshop/version.rb +3 -0
- data/machineshop.gemspec +24 -0
- data/spec/lib/api_calls_spec.rb +628 -0
- data/spec/lib/customer_spec.rb +76 -0
- data/spec/lib/device_spec.rb +179 -0
- data/spec/lib/mapping_spec.rb +64 -0
- data/spec/lib/meter_spec.rb +46 -0
- data/spec/lib/report_spec.rb +52 -0
- data/spec/lib/rule_spec.rb +117 -0
- data/spec/lib/user_spec.rb +53 -0
- data/spec/spec_helper.rb +3 -0
- metadata +184 -0
@@ -0,0 +1,53 @@
|
|
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
|
+
element_data.should_not be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should get all roles from a user instance" do
|
38
|
+
|
39
|
+
ap " here user is : "
|
40
|
+
ap user.as_json
|
41
|
+
element_data = user.all_roles
|
42
|
+
element_data.should_not be_nil
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should get a user for the user by id" do
|
46
|
+
element_data = MachineShop::User.retrieve(user.id, auth_token)
|
47
|
+
|
48
|
+
element_data.should_not be_nil
|
49
|
+
element_data.should be_kind_of MachineShop::User
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: machineshop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- machineshop
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-02 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: addressable
|
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: rest-client
|
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: multi_json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.4
|
76
|
+
- - <
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '2'
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.0.4
|
86
|
+
- - <
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2'
|
89
|
+
description: Wraps the machineshop API.
|
90
|
+
email:
|
91
|
+
- john@mach19.com
|
92
|
+
executables: []
|
93
|
+
extensions: []
|
94
|
+
extra_rdoc_files: []
|
95
|
+
files:
|
96
|
+
- .idea/.name
|
97
|
+
- .idea/.rakeTasks
|
98
|
+
- .idea/compiler.xml
|
99
|
+
- .idea/copyright/profiles_settings.xml
|
100
|
+
- .idea/encodings.xml
|
101
|
+
- .idea/inspectionProfiles/Project_Default.xml
|
102
|
+
- .idea/inspectionProfiles/profiles_settings.xml
|
103
|
+
- .idea/machineshop.iml
|
104
|
+
- .idea/misc.xml
|
105
|
+
- .idea/modules.xml
|
106
|
+
- .idea/scopes/scope_settings.xml
|
107
|
+
- .idea/vcs.xml
|
108
|
+
- .idea/workspace.xml
|
109
|
+
- Gemfile
|
110
|
+
- LICENSE
|
111
|
+
- README.md
|
112
|
+
- Rakefile
|
113
|
+
- doc.txt
|
114
|
+
- lib/machineshop.rb
|
115
|
+
- lib/machineshop/api_operations/create.rb
|
116
|
+
- lib/machineshop/api_operations/delete.rb
|
117
|
+
- lib/machineshop/api_operations/list.rb
|
118
|
+
- lib/machineshop/api_operations/update.rb
|
119
|
+
- lib/machineshop/api_resource.rb
|
120
|
+
- lib/machineshop/configuration.rb
|
121
|
+
- lib/machineshop/customer.rb
|
122
|
+
- lib/machineshop/database.rb
|
123
|
+
- lib/machineshop/device.rb
|
124
|
+
- lib/machineshop/device_instance.rb
|
125
|
+
- lib/machineshop/errors/api_error.rb
|
126
|
+
- lib/machineshop/errors/authentication_error.rb
|
127
|
+
- lib/machineshop/errors/database_error.rb
|
128
|
+
- lib/machineshop/errors/invalid_request_error.rb
|
129
|
+
- lib/machineshop/errors/machineshop_error.rb
|
130
|
+
- lib/machineshop/json.rb
|
131
|
+
- lib/machineshop/machineshop_cache.rb
|
132
|
+
- lib/machineshop/machineshop_object.rb
|
133
|
+
- lib/machineshop/mapping.rb
|
134
|
+
- lib/machineshop/meter.rb
|
135
|
+
- lib/machineshop/models/people.rb
|
136
|
+
- lib/machineshop/report.rb
|
137
|
+
- lib/machineshop/rule.rb
|
138
|
+
- lib/machineshop/user.rb
|
139
|
+
- lib/machineshop/util.rb
|
140
|
+
- lib/machineshop/utility.rb
|
141
|
+
- lib/machineshop/version.rb
|
142
|
+
- machineshop.gemspec
|
143
|
+
- spec/lib/api_calls_spec.rb
|
144
|
+
- spec/lib/customer_spec.rb
|
145
|
+
- spec/lib/device_spec.rb
|
146
|
+
- spec/lib/mapping_spec.rb
|
147
|
+
- spec/lib/meter_spec.rb
|
148
|
+
- spec/lib/report_spec.rb
|
149
|
+
- spec/lib/rule_spec.rb
|
150
|
+
- spec/lib/user_spec.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
homepage: ''
|
153
|
+
licenses: []
|
154
|
+
metadata: {}
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - '>='
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 2.2.1
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: A convenient way to call into the machineshop API.
|
175
|
+
test_files:
|
176
|
+
- spec/lib/api_calls_spec.rb
|
177
|
+
- spec/lib/customer_spec.rb
|
178
|
+
- spec/lib/device_spec.rb
|
179
|
+
- spec/lib/mapping_spec.rb
|
180
|
+
- spec/lib/meter_spec.rb
|
181
|
+
- spec/lib/report_spec.rb
|
182
|
+
- spec/lib/rule_spec.rb
|
183
|
+
- spec/lib/user_spec.rb
|
184
|
+
- spec/spec_helper.rb
|