cloudkit 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. data/CHANGES +2 -0
  2. data/COPYING +20 -0
  3. data/README +55 -0
  4. data/Rakefile +35 -0
  5. data/TODO +22 -0
  6. data/cloudkit.gemspec +82 -0
  7. data/doc/curl.html +329 -0
  8. data/doc/images/example-code.gif +0 -0
  9. data/doc/images/json-title.gif +0 -0
  10. data/doc/images/oauth-discovery-logo.gif +0 -0
  11. data/doc/images/openid-logo.gif +0 -0
  12. data/doc/index.html +87 -0
  13. data/doc/main.css +151 -0
  14. data/doc/rest-api.html +358 -0
  15. data/examples/1.ru +3 -0
  16. data/examples/2.ru +3 -0
  17. data/examples/3.ru +6 -0
  18. data/examples/4.ru +5 -0
  19. data/examples/5.ru +10 -0
  20. data/examples/6.ru +10 -0
  21. data/examples/TOC +17 -0
  22. data/lib/cloudkit.rb +74 -0
  23. data/lib/cloudkit/flash_session.rb +22 -0
  24. data/lib/cloudkit/oauth_filter.rb +273 -0
  25. data/lib/cloudkit/oauth_store.rb +56 -0
  26. data/lib/cloudkit/openid_filter.rb +198 -0
  27. data/lib/cloudkit/openid_store.rb +101 -0
  28. data/lib/cloudkit/rack/builder.rb +120 -0
  29. data/lib/cloudkit/rack/router.rb +20 -0
  30. data/lib/cloudkit/request.rb +159 -0
  31. data/lib/cloudkit/service.rb +135 -0
  32. data/lib/cloudkit/store.rb +459 -0
  33. data/lib/cloudkit/store/adapter.rb +9 -0
  34. data/lib/cloudkit/store/extraction_view.rb +57 -0
  35. data/lib/cloudkit/store/response.rb +51 -0
  36. data/lib/cloudkit/store/response_helpers.rb +72 -0
  37. data/lib/cloudkit/store/sql_adapter.rb +36 -0
  38. data/lib/cloudkit/templates/authorize_request_token.erb +19 -0
  39. data/lib/cloudkit/templates/oauth_descriptor.erb +43 -0
  40. data/lib/cloudkit/templates/oauth_meta.erb +8 -0
  41. data/lib/cloudkit/templates/openid_login.erb +31 -0
  42. data/lib/cloudkit/templates/request_authorization.erb +23 -0
  43. data/lib/cloudkit/templates/request_token_denied.erb +18 -0
  44. data/lib/cloudkit/user_store.rb +44 -0
  45. data/lib/cloudkit/util.rb +60 -0
  46. data/test/ext_test.rb +57 -0
  47. data/test/flash_session_test.rb +22 -0
  48. data/test/helper.rb +50 -0
  49. data/test/oauth_filter_test.rb +331 -0
  50. data/test/oauth_store_test.rb +12 -0
  51. data/test/openid_filter_test.rb +54 -0
  52. data/test/openid_store_test.rb +12 -0
  53. data/test/rack_builder_test.rb +41 -0
  54. data/test/request_test.rb +197 -0
  55. data/test/service_test.rb +718 -0
  56. data/test/store_test.rb +99 -0
  57. data/test/user_store_test.rb +12 -0
  58. data/test/util_test.rb +13 -0
  59. metadata +190 -0
@@ -0,0 +1,99 @@
1
+ require 'helper'
2
+ class StoreTest < Test::Unit::TestCase
3
+
4
+ class ExposedStore < CloudKit::Store
5
+ def db; @db; end
6
+ end
7
+
8
+ context "A CloudKit::Store" do
9
+
10
+ setup do
11
+ @store = ExposedStore.new(:collections => [:items])
12
+ end
13
+
14
+ teardown do
15
+ FileUtils.rm_f('test.db')
16
+ end
17
+
18
+ should "know its version" do
19
+ assert_equal 1, @store.version
20
+ end
21
+
22
+ should "create its storage" do
23
+ store = ExposedStore.new(:collections => [:items])
24
+ table = store.db.schema[:cloudkit_json_store]
25
+ assert table
26
+ assert table.any?{|t| t[0] == :id}
27
+ assert table.any?{|t| t[0] == :uri}
28
+ assert table.any?{|t| t[0] == :etag}
29
+ assert table.any?{|t| t[0] == :collection_reference}
30
+ assert table.any?{|t| t[0] == :resource_reference}
31
+ assert table.any?{|t| t[0] == :last_modified}
32
+ assert table.any?{|t| t[0] == :remote_user}
33
+ assert table.any?{|t| t[0] == :content}
34
+ assert table.any?{|t| t[0] == :deleted}
35
+ end
36
+
37
+ should "create views when specified if they do not exist" do
38
+ view = CloudKit::ExtractionView.new(
39
+ :item_colors,
40
+ :observe => :items,
41
+ :extract => [:color, :saturation])
42
+ store = ExposedStore.new(
43
+ :collections => [:items],
44
+ :views => [view])
45
+ table = store.db.schema[:item_colors]
46
+ assert table
47
+ assert table.any?{|t| t[0] == :color}
48
+ assert table.any?{|t| t[0] == :saturation}
49
+ assert table.any?{|t| t[0] == :uri}
50
+ end
51
+
52
+ should "not create views that already exist" do
53
+ color_view = CloudKit::ExtractionView.new(
54
+ :colors,
55
+ :observe => :items,
56
+ :extract => [:color, :saturation])
57
+ weight_view = CloudKit::ExtractionView.new(
58
+ :weights,
59
+ :observe => :items,
60
+ :extract => [:weight])
61
+ store = ExposedStore.new(
62
+ :collections => [:items],
63
+ :views => [color_view, weight_view],
64
+ :adapter => CloudKit::SQLAdapter.new('sqlite://test.db'))
65
+ json = JSON.generate(:color => 'green')
66
+ store.put('/items/123', :json => json)
67
+ store.db.drop_table(:weights)
68
+ store = ExposedStore.new(
69
+ :collections => [:items],
70
+ :views => [color_view, weight_view],
71
+ :adapter => CloudKit::SQLAdapter.new('sqlite://test.db'))
72
+ assert store.db.schema[:colors]
73
+ assert store.db.schema[:weights]
74
+ result = store.get('/colors', :color => 'green')
75
+ assert_equal 200, result.status
76
+ assert_equal 1, result.parsed_content['uris'].size
77
+ end
78
+
79
+ should "filter using views" do
80
+ view = CloudKit::ExtractionView.new(
81
+ :colors,
82
+ :observe => :items,
83
+ :extract => [:color, :saturation])
84
+ store = ExposedStore.new(
85
+ :collections => [:items],
86
+ :views => [view])
87
+ json = JSON.generate(:color => 'green')
88
+ store.put('/items/123', :json => json)
89
+ json = JSON.generate(:color => 'red')
90
+ store.put('/items/456', :json => json)
91
+ result = store.get('/colors', :color => 'green')
92
+ uris = result.parsed_content['uris']
93
+ assert_equal 1, uris.size
94
+ content = store.resolve_uris(uris).first.parsed_content
95
+ assert_equal 'green', content['color']
96
+ end
97
+
98
+ end
99
+ end
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+ class UserStoreTest < Test::Unit::TestCase
3
+
4
+ context "A UserStore" do
5
+
6
+ should "know its version" do
7
+ store = CloudKit::UserStore.new
8
+ assert_equal 1, store.version
9
+ end
10
+
11
+ end
12
+ end
data/test/util_test.rb ADDED
@@ -0,0 +1,13 @@
1
+ require 'helper'
2
+ class UtilTest < Test::Unit::TestCase
3
+ include CloudKit::Util
4
+
5
+ context "CloudKit::Util" do
6
+
7
+ should "create routers" do
8
+ router = r(:get, '/path')
9
+ assert_equal Rack::Router, router.class
10
+ end
11
+
12
+ end
13
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloudkit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - Jon Crosby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-22 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rack
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "0.4"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack-config
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0.9"
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: uuid
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "="
42
+ - !ruby/object:Gem::Version
43
+ version: 2.0.1
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: sequel
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "="
52
+ - !ruby/object:Gem::Version
53
+ version: 2.6.0
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: oauth
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 0.2.7
64
+ version:
65
+ - !ruby/object:Gem::Dependency
66
+ name: ruby-openid
67
+ type: :runtime
68
+ version_requirement:
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "="
72
+ - !ruby/object:Gem::Version
73
+ version: 2.1.2
74
+ version:
75
+ - !ruby/object:Gem::Dependency
76
+ name: json
77
+ type: :runtime
78
+ version_requirement:
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "="
82
+ - !ruby/object:Gem::Version
83
+ version: 1.1.3
84
+ version:
85
+ description: An Open Web JSON Appliance.
86
+ email: jon@joncrosby.me
87
+ executables: []
88
+
89
+ extensions: []
90
+
91
+ extra_rdoc_files: []
92
+
93
+ files:
94
+ - CHANGES
95
+ - cloudkit.gemspec
96
+ - COPYING
97
+ - README
98
+ - Rakefile
99
+ - TODO
100
+ - doc/curl.html
101
+ - doc/images/example-code.gif
102
+ - doc/images/json-title.gif
103
+ - doc/images/oauth-discovery-logo.gif
104
+ - doc/images/openid-logo.gif
105
+ - doc/index.html
106
+ - doc/main.css
107
+ - doc/rest-api.html
108
+ - examples/1.ru
109
+ - examples/2.ru
110
+ - examples/3.ru
111
+ - examples/4.ru
112
+ - examples/5.ru
113
+ - examples/6.ru
114
+ - examples/TOC
115
+ - lib/cloudkit.rb
116
+ - lib/cloudkit/flash_session.rb
117
+ - lib/cloudkit/oauth_filter.rb
118
+ - lib/cloudkit/oauth_store.rb
119
+ - lib/cloudkit/openid_filter.rb
120
+ - lib/cloudkit/openid_store.rb
121
+ - lib/cloudkit/rack/builder.rb
122
+ - lib/cloudkit/rack/router.rb
123
+ - lib/cloudkit/request.rb
124
+ - lib/cloudkit/service.rb
125
+ - lib/cloudkit/store.rb
126
+ - lib/cloudkit/store/adapter.rb
127
+ - lib/cloudkit/store/extraction_view.rb
128
+ - lib/cloudkit/store/response.rb
129
+ - lib/cloudkit/store/response_helpers.rb
130
+ - lib/cloudkit/store/sql_adapter.rb
131
+ - lib/cloudkit/templates/authorize_request_token.erb
132
+ - lib/cloudkit/templates/oauth_descriptor.erb
133
+ - lib/cloudkit/templates/oauth_meta.erb
134
+ - lib/cloudkit/templates/openid_login.erb
135
+ - lib/cloudkit/templates/request_authorization.erb
136
+ - lib/cloudkit/templates/request_token_denied.erb
137
+ - lib/cloudkit/user_store.rb
138
+ - lib/cloudkit/util.rb
139
+ - test/ext_test.rb
140
+ - test/flash_session_test.rb
141
+ - test/helper.rb
142
+ - test/oauth_filter_test.rb
143
+ - test/oauth_store_test.rb
144
+ - test/openid_filter_test.rb
145
+ - test/openid_store_test.rb
146
+ - test/rack_builder_test.rb
147
+ - test/request_test.rb
148
+ - test/service_test.rb
149
+ - test/store_test.rb
150
+ - test/user_store_test.rb
151
+ - test/util_test.rb
152
+ has_rdoc: false
153
+ homepage: http://getcloudkit.com
154
+ post_install_message:
155
+ rdoc_options: []
156
+
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
+ version:
165
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: "0"
170
+ version:
171
+ requirements: []
172
+
173
+ rubyforge_project: cloudkit
174
+ rubygems_version: 1.3.1
175
+ signing_key:
176
+ specification_version: 2
177
+ summary: An Open Web JSON Appliance.
178
+ test_files:
179
+ - test/ext_test.rb
180
+ - test/flash_session_test.rb
181
+ - test/oauth_filter_test.rb
182
+ - test/oauth_store_test.rb
183
+ - test/openid_filter_test.rb
184
+ - test/openid_store_test.rb
185
+ - test/rack_builder_test.rb
186
+ - test/request_test.rb
187
+ - test/service_test.rb
188
+ - test/store_test.rb
189
+ - test/user_store_test.rb
190
+ - test/util_test.rb