cloudkit 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +7 -1
- data/TODO +0 -2
- data/cloudkit.gemspec +4 -4
- data/doc/index.html +1 -1
- data/lib/cloudkit.rb +9 -5
- data/lib/cloudkit/openid_filter.rb +1 -1
- data/lib/cloudkit/rack/router.rb +1 -1
- data/lib/cloudkit/store.rb +2 -1
- data/lib/cloudkit/store/extraction_view.rb +1 -1
- data/lib/cloudkit/store/response.rb +1 -1
- data/test/ext_test.rb +19 -0
- data/test/service_test.rb +22 -3
- metadata +6 -6
data/CHANGES
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.10.1
|
2
|
+
- Updated oauth and sequel gem dependencies
|
3
|
+
- Fixed 410 responses for stale PUT operations
|
4
|
+
- Fixed MySQL content encoding (Harry Weppner)
|
5
|
+
- Various fixes for filter_merge!, rekey!, and excluding (Cameron Walters)
|
6
|
+
|
1
7
|
0.10.0
|
2
8
|
- Updated for Rack 0.9
|
3
9
|
- Added batch URI resolution for resource collections
|
@@ -12,4 +18,4 @@
|
|
12
18
|
- Updated documentation
|
13
19
|
|
14
20
|
0.9.0
|
15
|
-
- First public gem release
|
21
|
+
- First public gem release
|
data/TODO
CHANGED
data/cloudkit.gemspec
CHANGED
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
|
|
2
2
|
s.specification_version = 2 if s.respond_to? :specification_version=
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
s.name = "cloudkit"
|
5
|
-
s.version = "0.10.
|
6
|
-
s.date = "2008-01-
|
5
|
+
s.version = "0.10.1"
|
6
|
+
s.date = "2008-01-27"
|
7
7
|
s.summary = "An Open Web JSON Appliance."
|
8
8
|
s.description = "An Open Web JSON Appliance."
|
9
9
|
s.authors = ["Jon Crosby"]
|
@@ -76,8 +76,8 @@ Gem::Specification.new do |s|
|
|
76
76
|
s.add_dependency 'rack', '~> 0.9'
|
77
77
|
s.add_dependency 'rack-config', '>= 0.9'
|
78
78
|
s.add_dependency 'uuid', '= 2.0.1'
|
79
|
-
s.add_dependency 'sequel', '
|
80
|
-
s.add_dependency 'oauth', '
|
79
|
+
s.add_dependency 'sequel', '~> 2.9'
|
80
|
+
s.add_dependency 'oauth', '~> 0.3'
|
81
81
|
s.add_dependency 'ruby-openid', '= 2.1.2'
|
82
82
|
s.add_dependency 'json', '= 1.1.3'
|
83
83
|
s.add_dependency 'sqlite3-ruby', '= 1.2.4'
|
data/doc/index.html
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
</div>
|
25
25
|
<div class="meta">
|
26
26
|
<p class="wrapper">
|
27
|
-
Version 0.10.
|
27
|
+
Version 0.10.1 released. Install with <em>gem install cloudkit</em>.
|
28
28
|
</p>
|
29
29
|
</div>
|
30
30
|
<div class="wrapper intro-row">
|
data/lib/cloudkit.rb
CHANGED
@@ -3,7 +3,6 @@ require 'erb'
|
|
3
3
|
require 'json'
|
4
4
|
require 'md5'
|
5
5
|
require 'openid'
|
6
|
-
gem 'sequel', '=2.6.0'
|
7
6
|
require 'sequel'
|
8
7
|
require 'time'
|
9
8
|
require 'uuid'
|
@@ -36,7 +35,7 @@ require 'cloudkit/user_store'
|
|
36
35
|
include CloudKit::Constants
|
37
36
|
|
38
37
|
module CloudKit
|
39
|
-
VERSION = '0.10.
|
38
|
+
VERSION = '0.10.1'
|
40
39
|
end
|
41
40
|
|
42
41
|
class Object
|
@@ -52,21 +51,25 @@ class Hash
|
|
52
51
|
# For each key in 'other' that has a non-nil value, merge it into the current
|
53
52
|
# Hash.
|
54
53
|
def filter_merge!(other={})
|
55
|
-
other.each_pair{|k,v| self.merge!(k => v)
|
54
|
+
other.each_pair{|k,v| self.merge!(k => v) unless v.nil?}
|
55
|
+
|
56
56
|
self
|
57
57
|
end
|
58
58
|
|
59
59
|
# Change the key 'oldkey' to 'newkey'
|
60
60
|
def rekey!(oldkey, newkey)
|
61
|
-
if self
|
61
|
+
if self.has_key? oldkey
|
62
62
|
self[newkey] = self.delete(oldkey)
|
63
63
|
end
|
64
|
+
|
65
|
+
nil
|
64
66
|
end
|
65
67
|
|
66
68
|
# Return a new Hash, excluding the specified list of keys.
|
67
69
|
def excluding(*keys)
|
68
70
|
trimmed = self.dup
|
69
71
|
keys.each{|k| trimmed.delete(k)}
|
72
|
+
|
70
73
|
trimmed
|
71
74
|
end
|
72
75
|
end
|
@@ -76,6 +79,7 @@ class Array
|
|
76
79
|
# Return a new Array, excluding the specified list of values.
|
77
80
|
def excluding(*keys)
|
78
81
|
trimmed = self.dup
|
79
|
-
|
82
|
+
|
83
|
+
trimmed - keys
|
80
84
|
end
|
81
85
|
end
|
data/lib/cloudkit/rack/router.rb
CHANGED
@@ -3,7 +3,7 @@ module Rack #:nodoc:
|
|
3
3
|
# A minimal router providing just what is needed for the OAuth and OpenID
|
4
4
|
# filters.
|
5
5
|
class Router
|
6
|
-
|
6
|
+
|
7
7
|
# Create an instance of Router to match on method, path and params.
|
8
8
|
def initialize(method, path, params=[])
|
9
9
|
@method = method.to_s.upcase; @path = path; @params = params
|
data/lib/cloudkit/store.rb
CHANGED
@@ -114,6 +114,7 @@ module CloudKit
|
|
114
114
|
return data_required unless options[:json]
|
115
115
|
current_resource = resource(uri, options.excluding(:json, :etag, :remote_user))
|
116
116
|
return update_resource(uri, options) if current_resource.status == 200
|
117
|
+
return current_resource if current_resource.status == 410
|
117
118
|
create_resource(uri, options)
|
118
119
|
end
|
119
120
|
|
@@ -303,7 +304,7 @@ module CloudKit
|
|
303
304
|
# Clear all contents of the store. Used mostly for testing.
|
304
305
|
def reset!
|
305
306
|
@db.schema.keys.each do |table|
|
306
|
-
@db[table].delete
|
307
|
+
@db[table.gsub('`','').to_sym].delete
|
307
308
|
end
|
308
309
|
end
|
309
310
|
|
@@ -24,7 +24,7 @@ module CloudKit
|
|
24
24
|
# Translate to the standard Rack representation: [status, headers, content]
|
25
25
|
def to_rack
|
26
26
|
meta['Content-Length'] = content.length.to_s
|
27
|
-
[status, meta, [content]]
|
27
|
+
[status, meta, [content.to_s]]
|
28
28
|
end
|
29
29
|
|
30
30
|
# Parse and return the JSON content
|
data/test/ext_test.rb
CHANGED
@@ -10,6 +10,14 @@ class ExtTest < Test::Unit::TestCase
|
|
10
10
|
x.rekey!(:d, :b)
|
11
11
|
assert x == {:a => 1, :c => 2}
|
12
12
|
end
|
13
|
+
|
14
|
+
should "re-key false and nil values" do
|
15
|
+
x = {:a => false, :b => nil}
|
16
|
+
x.rekey!(:b, :c)
|
17
|
+
assert x == {:a => false, :c => nil}
|
18
|
+
x.rekey!(:d, :b)
|
19
|
+
assert x == {:a => false, :c => nil}
|
20
|
+
end
|
13
21
|
|
14
22
|
should "merge conditionally" do
|
15
23
|
x = {:a => 1}
|
@@ -22,6 +30,17 @@ class ExtTest < Test::Unit::TestCase
|
|
22
30
|
assert x == {:a => 1}
|
23
31
|
end
|
24
32
|
|
33
|
+
should "merge false values correctly" do
|
34
|
+
x = {:a => 1}
|
35
|
+
y = {:b => 2}
|
36
|
+
x.filter_merge!(:c => false)
|
37
|
+
assert x == {:a => 1, :c => false}
|
38
|
+
x.filter_merge!(:c => y[:b])
|
39
|
+
assert x == {:a => 1, :c => 2}
|
40
|
+
x = {}.filter_merge!(:a => false)
|
41
|
+
assert x == {:a => false}
|
42
|
+
end
|
43
|
+
|
25
44
|
should "exclude pairs using a single key" do
|
26
45
|
x = {:a => 1, :b => 2}
|
27
46
|
y = x.excluding(:b)
|
data/test/service_test.rb
CHANGED
@@ -655,6 +655,25 @@ class ServiceTest < Test::Unit::TestCase
|
|
655
655
|
assert_equal 'thing', JSON.parse(result.body)['this']
|
656
656
|
end
|
657
657
|
|
658
|
+
should "not create new resources using deleted resource URIs" do
|
659
|
+
# This situation occurs when a stale client attempts to update
|
660
|
+
# a resource that has been removed. This test verifies that CloudKit
|
661
|
+
# does not attempt to create a new item with a URI equal to the
|
662
|
+
# removed item.
|
663
|
+
etag = JSON.parse(@response.body)['etag'];
|
664
|
+
@request.delete(
|
665
|
+
'/items/abc',
|
666
|
+
'HTTP_IF_MATCH' => etag,
|
667
|
+
CLOUDKIT_AUTH_KEY => TEST_REMOTE_USER)
|
668
|
+
json = JSON.generate(:foo => 'bar')
|
669
|
+
response = @request.put(
|
670
|
+
'/items/abc',
|
671
|
+
:input => json,
|
672
|
+
'HTTP_IF_MATCH' => etag,
|
673
|
+
CLOUDKIT_AUTH_KEY => TEST_REMOTE_USER)
|
674
|
+
assert_equal 410, response.status
|
675
|
+
end
|
676
|
+
|
658
677
|
should "update the document if it already exists" do
|
659
678
|
assert_equal 200, @response.status
|
660
679
|
result = @request.get('/items/abc', VALID_TEST_AUTH)
|
@@ -723,9 +742,9 @@ class ServiceTest < Test::Unit::TestCase
|
|
723
742
|
json = JSON.generate(:this => 'updated')
|
724
743
|
response = @request.put(
|
725
744
|
'/items/abc',
|
726
|
-
:input
|
727
|
-
'HTTP_IF_MATCH'
|
728
|
-
CLOUDKIT_AUTH_KEY
|
745
|
+
:input => json,
|
746
|
+
'HTTP_IF_MATCH' => @json['etag'],
|
747
|
+
CLOUDKIT_AUTH_KEY => TEST_REMOTE_USER)
|
729
748
|
assert_equal 200, response.status
|
730
749
|
etag = JSON.parse(response.body)['etag']
|
731
750
|
json = JSON.generate(:this => 'updated again')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Crosby
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-01-
|
12
|
+
date: 2008-01-27 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -48,9 +48,9 @@ dependencies:
|
|
48
48
|
version_requirement:
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
53
|
+
version: "2.9"
|
54
54
|
version:
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: oauth
|
@@ -58,9 +58,9 @@ dependencies:
|
|
58
58
|
version_requirement:
|
59
59
|
version_requirements: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ~>
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version: 0.
|
63
|
+
version: "0.3"
|
64
64
|
version:
|
65
65
|
- !ruby/object:Gem::Dependency
|
66
66
|
name: ruby-openid
|