vidibus-service 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,6 @@
1
- Copyright (c) 2010-2011 Andre Pankratz
1
+ MIT License
2
+
3
+ Copyright (c) 2010-2013 Andre Pankratz
2
4
 
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Vidibus::Service [![](http://travis-ci.org/vidibus/vidibus-service.png)](http://travis-ci.org/vidibus/vidibus-service) [![](http://stillmaintained.com/vidibus/vidibus-service.png)](http://stillmaintained.com/vidibus/vidibus-service)
1
+ # Vidibus::Service [![](http://travis-ci.org/vidibus/vidibus-service.png)](http://travis-ci.org/vidibus/vidibus-service)
2
2
 
3
3
  DESCRIBE
4
4
 
@@ -12,11 +12,11 @@ Add `gem "vidibus-service"` to your Gemfile. Then call `bundle install` on your
12
12
 
13
13
  ## Requirements
14
14
 
15
- In order to work properly this gem needs the route /connector to call a Rack app. Usually this
16
- route gets provided automatically but that may fail if your application has some sort of catch-all
17
- route. To check if the route works as expected, just call http://yourapp.com/connector and expect
15
+ In order to work properly this gem needs the route /connector to call a Rack app. Usually this
16
+ route gets provided automatically but that may fail if your application has some sort of catch-all
17
+ route. To check if the route works as expected, just call http://yourapp.com/connector and expect
18
18
  an error message like this:
19
-
19
+
20
20
  ```
21
21
  This service has not been configured yet. Use your Connector to set it up.
22
22
  ```
@@ -35,4 +35,4 @@ DESCRIBE
35
35
 
36
36
  ## Copyright
37
37
 
38
- © 2010-2011 Andre Pankratz. See LICENSE for details.
38
+ © 2010-2013 Andre Pankratz. See LICENSE for details.
data/Rakefile CHANGED
@@ -8,12 +8,6 @@ Bundler::GemHelper.install_tasks
8
8
  $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
9
9
  require "vidibus/service/version"
10
10
 
11
- RSpec::Core::RakeTask.new(:rcov) do |t|
12
- t.pattern = "spec/**/*_spec.rb"
13
- t.rcov = true
14
- t.rcov_opts = ["--exclude", "^spec,/gems/"]
15
- end
16
-
17
11
  Rake::RDocTask.new do |rdoc|
18
12
  rdoc.rdoc_dir = "rdoc"
19
13
  rdoc.title = "vidibus-sysinfo #{Vidibus::Service::VERSION}"
@@ -21,5 +15,3 @@ Rake::RDocTask.new do |rdoc|
21
15
  rdoc.rdoc_files.include("lib/**/*.rb")
22
16
  rdoc.options << "--charset=utf-8"
23
17
  end
24
-
25
- task :default => :rcov
@@ -86,11 +86,13 @@ module Vidibus
86
86
  unless uuids = @request.params["uuids"]
87
87
  raise "Provide list of UUIDs of services to delete."
88
88
  end
89
- for uuid in uuids
90
- _service = service.where(:uuid => uuid).first
91
- next unless _service
92
- unless _service.destroy
93
- raise "Deleting service #{uuid} failed: #{_service.errors.full_messages}"
89
+
90
+ uuids.each do |uuid|
91
+ obj = service.where(:uuid => uuid).first
92
+ next unless obj
93
+ unless obj.destroy
94
+ errors = obj.errors.full_messages.join(',')
95
+ raise "Deleting service #{uuid} failed: #{errors}"
94
96
  end
95
97
  end
96
98
  response(:success => "Services have been deleted.")
@@ -161,9 +163,9 @@ module Vidibus
161
163
 
162
164
  this = service.new(data)
163
165
  this.valid?
164
- errors = this.errors.respond_to?(:messages) ? this.errors.messages : this.errors # Support Rails < 3.0.9
165
- raise ValidationError unless errors.except(:secret).empty?
166
-
166
+ unless this.errors.messages.except(:secret).empty?
167
+ raise ValidationError
168
+ end
167
169
  set_secret!(this)
168
170
  this.save or raise ValidationError
169
171
  rescue ValidationError
@@ -12,7 +12,7 @@ module Vidibus
12
12
  field :uuid
13
13
  field :function
14
14
  field :realm_uuid
15
- field :this, :type => Boolean
15
+ field :this, :type => ::Mongoid::Boolean
16
16
 
17
17
  attr_accessor :nonce
18
18
  attr_encrypted :secret
@@ -37,26 +37,6 @@ module Vidibus
37
37
  @is_connector ||= function == "connector"
38
38
  end
39
39
 
40
- # Sends a GET request to given path.
41
- def get(path, options = {})
42
- client.get(path, options)
43
- end
44
-
45
- # Sends a POST request to given path.
46
- def post(path, options = {})
47
- client.post(path, options)
48
- end
49
-
50
- # Sends a PUT request to given path.
51
- def put(path, options = {})
52
- client.put(path, options)
53
- end
54
-
55
- # Sends a DELETE request to given path.
56
- def delete(path, options = {})
57
- client.delete(path, options)
58
- end
59
-
60
40
  # Returns publicly requestable data.
61
41
  def public_data
62
42
  attributes.only(%w[uuid function url])
@@ -67,6 +47,11 @@ module Vidibus
67
47
  url.gsub(/https?:\/\//, "") if url
68
48
  end
69
49
 
50
+ # Returns a Client for current service.
51
+ def client
52
+ @client ||= Client.new(self)
53
+ end
54
+
70
55
  # Returns true if given client_secret matches signature.
71
56
  # This method is called from Vidibus' OauthServer when issuing an OAuth token.
72
57
  # To prevent sending the service's secret over the network, the ConnectorClient
@@ -79,14 +64,11 @@ module Vidibus
79
64
 
80
65
  protected
81
66
 
82
- # Returns a Client for current service.
83
- def client
84
- @client ||= Client.new(self)
85
- end
86
-
87
67
  # Sets an error if secret is given for Connector service.
88
68
  def dont_allow_secret_for_connector
89
- errors.add(:secret, :secret_not_allowed_for_connector) if connector? and secret
69
+ if connector? && secret
70
+ errors.add(:secret, :secret_not_allowed_for_connector)
71
+ end
90
72
  end
91
73
  end
92
74
 
@@ -126,7 +108,7 @@ module Vidibus
126
108
  unless realm
127
109
  raise ArgumentError.new("Please provide a valid realm to discover an appropriate service.")
128
110
  end
129
- if response = connector.get("/services/#{wanted}", :query => {:realm => realm})
111
+ if response = connector.client.get("/services/#{wanted}", :query => {:realm => realm})
130
112
  secret = response["secret"] || raise(ConnectorError.new("The Connector did not return a secret for #{wanted}. Response was: #{response.parsed_response.inspect}"))
131
113
  secret = Vidibus::Secure.decrypt(secret, this.secret)
132
114
  attributes = response.only(%w[uuid function url]).merge(:realm_uuid => realm, :secret => secret)
@@ -1,5 +1,5 @@
1
1
  module Vidibus
2
2
  module Service
3
- VERSION = "0.1.3"
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,246 +1,262 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: vidibus-service
3
- version: !ruby/object:Gem::Version
4
- hash: 29
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 3
10
- version: 0.1.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Andre Pankratz
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-09-15 00:00:00 +02:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-08-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: mongoid
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 7
30
- segments:
31
- - 2
32
- version: "2"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: vidibus-core_extensions
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
39
25
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: vidibus-core_extensions
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
47
38
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: vidibus-secure
51
39
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
53
41
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: vidibus-secure
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
61
54
  type: :runtime
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: vidibus-uuid
65
55
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
67
57
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: vidibus-uuid
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
75
70
  type: :runtime
76
- version_requirements: *id004
77
- - !ruby/object:Gem::Dependency
78
- name: vidibus-validate_uri
79
71
  prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
81
73
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: vidibus-validate_uri
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
89
86
  type: :runtime
90
- version_requirements: *id005
91
- - !ruby/object:Gem::Dependency
92
- name: httparty
93
87
  prerelease: false
94
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
95
89
  none: false
96
- requirements:
97
- - - "="
98
- - !ruby/object:Gem::Version
99
- hash: 19
100
- segments:
101
- - 0
102
- - 7
103
- - 8
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: httparty
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - '='
100
+ - !ruby/object:Gem::Version
104
101
  version: 0.7.8
105
102
  type: :runtime
106
- version_requirements: *id006
107
- - !ruby/object:Gem::Dependency
108
- name: json
109
103
  prerelease: false
110
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
111
105
  none: false
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- hash: 3
116
- segments:
117
- - 0
118
- version: "0"
106
+ requirements:
107
+ - - '='
108
+ - !ruby/object:Gem::Version
109
+ version: 0.7.8
110
+ - !ruby/object:Gem::Dependency
111
+ name: json
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
119
118
  type: :runtime
120
- version_requirements: *id007
121
- - !ruby/object:Gem::Dependency
122
- name: bundler
123
119
  prerelease: false
124
- requirement: &id008 !ruby/object:Gem::Requirement
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: bundler
128
+ requirement: !ruby/object:Gem::Requirement
125
129
  none: false
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- hash: 23
130
- segments:
131
- - 1
132
- - 0
133
- - 0
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
134
133
  version: 1.0.0
135
134
  type: :development
136
- version_requirements: *id008
137
- - !ruby/object:Gem::Dependency
138
- name: rake
139
135
  prerelease: false
140
- requirement: &id009 !ruby/object:Gem::Requirement
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: 1.0.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: rake
144
+ requirement: !ruby/object:Gem::Requirement
141
145
  none: false
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- hash: 3
146
- segments:
147
- - 0
148
- version: "0"
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
149
150
  type: :development
150
- version_requirements: *id009
151
- - !ruby/object:Gem::Dependency
152
- name: rdoc
153
151
  prerelease: false
154
- requirement: &id010 !ruby/object:Gem::Requirement
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: rdoc
160
+ requirement: !ruby/object:Gem::Requirement
155
161
  none: false
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- hash: 3
160
- segments:
161
- - 0
162
- version: "0"
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
163
166
  type: :development
164
- version_requirements: *id010
165
- - !ruby/object:Gem::Dependency
166
- name: rcov
167
167
  prerelease: false
168
- requirement: &id011 !ruby/object:Gem::Requirement
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: simplecov
176
+ requirement: !ruby/object:Gem::Requirement
169
177
  none: false
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- hash: 3
174
- segments:
175
- - 0
176
- version: "0"
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
177
182
  type: :development
178
- version_requirements: *id011
179
- - !ruby/object:Gem::Dependency
180
- name: rspec
181
183
  prerelease: false
182
- requirement: &id012 !ruby/object:Gem::Requirement
184
+ version_requirements: !ruby/object:Gem::Requirement
183
185
  none: false
184
- requirements:
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: rspec
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
185
195
  - - ~>
186
- - !ruby/object:Gem::Version
187
- hash: 7
188
- segments:
189
- - 2
190
- version: "2"
196
+ - !ruby/object:Gem::Version
197
+ version: '2'
191
198
  type: :development
192
- version_requirements: *id012
193
- - !ruby/object:Gem::Dependency
194
- name: rr
195
199
  prerelease: false
196
- requirement: &id013 !ruby/object:Gem::Requirement
200
+ version_requirements: !ruby/object:Gem::Requirement
197
201
  none: false
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- hash: 3
202
- segments:
203
- - 0
204
- version: "0"
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: '2'
206
+ - !ruby/object:Gem::Dependency
207
+ name: rr
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ! '>='
212
+ - !ruby/object:Gem::Version
213
+ version: '0'
205
214
  type: :development
206
- version_requirements: *id013
207
- - !ruby/object:Gem::Dependency
208
- name: webmock
209
215
  prerelease: false
210
- requirement: &id014 !ruby/object:Gem::Requirement
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ! '>='
220
+ - !ruby/object:Gem::Version
221
+ version: '0'
222
+ - !ruby/object:Gem::Dependency
223
+ name: webmock
224
+ requirement: !ruby/object:Gem::Requirement
211
225
  none: false
212
- requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- hash: 3
216
- segments:
217
- - 0
218
- version: "0"
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
219
230
  type: :development
220
- version_requirements: *id014
221
- - !ruby/object:Gem::Dependency
222
- name: rack-test
223
231
  prerelease: false
224
- requirement: &id015 !ruby/object:Gem::Requirement
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ! '>='
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ - !ruby/object:Gem::Dependency
239
+ name: rack-test
240
+ requirement: !ruby/object:Gem::Requirement
225
241
  none: false
226
- requirements:
227
- - - ">="
228
- - !ruby/object:Gem::Version
229
- hash: 3
230
- segments:
231
- - 0
232
- version: "0"
242
+ requirements:
243
+ - - ! '>='
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
233
246
  type: :development
234
- version_requirements: *id015
247
+ prerelease: false
248
+ version_requirements: !ruby/object:Gem::Requirement
249
+ none: false
250
+ requirements:
251
+ - - ! '>='
252
+ - !ruby/object:Gem::Version
253
+ version: '0'
235
254
  description: Enables Vidibus Services for the embedding Rails application
236
255
  email: andre@vidibus.com
237
256
  executables: []
238
-
239
257
  extensions: []
240
-
241
258
  extra_rdoc_files: []
242
-
243
- files:
259
+ files:
244
260
  - lib/vidibus/service/client.rb
245
261
  - lib/vidibus/service/connector_app.rb
246
262
  - lib/vidibus/service/controller_validations.rb
@@ -255,41 +271,32 @@ files:
255
271
  - LICENSE
256
272
  - README.md
257
273
  - Rakefile
258
- has_rdoc: true
259
274
  homepage: https://github.com/vidibus/vidibus-service
260
- licenses: []
261
-
275
+ licenses:
276
+ - MIT
262
277
  post_install_message:
263
278
  rdoc_options: []
264
-
265
- require_paths:
279
+ require_paths:
266
280
  - lib
267
- required_ruby_version: !ruby/object:Gem::Requirement
281
+ required_ruby_version: !ruby/object:Gem::Requirement
268
282
  none: false
269
- requirements:
270
- - - ">="
271
- - !ruby/object:Gem::Version
272
- hash: 3
273
- segments:
283
+ requirements:
284
+ - - ! '>='
285
+ - !ruby/object:Gem::Version
286
+ version: '0'
287
+ segments:
274
288
  - 0
275
- version: "0"
276
- required_rubygems_version: !ruby/object:Gem::Requirement
289
+ hash: -240109756340464642
290
+ required_rubygems_version: !ruby/object:Gem::Requirement
277
291
  none: false
278
- requirements:
279
- - - ">="
280
- - !ruby/object:Gem::Version
281
- hash: 23
282
- segments:
283
- - 1
284
- - 3
285
- - 6
292
+ requirements:
293
+ - - ! '>='
294
+ - !ruby/object:Gem::Version
286
295
  version: 1.3.6
287
296
  requirements: []
288
-
289
297
  rubyforge_project: vidibus-service
290
- rubygems_version: 1.6.2
298
+ rubygems_version: 1.8.24
291
299
  signing_key:
292
300
  specification_version: 3
293
301
  summary: Service handling for Vidibus applications
294
302
  test_files: []
295
-