cloudkit-jruby 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/CHANGES +47 -0
  2. data/COPYING +20 -0
  3. data/README +84 -0
  4. data/Rakefile +42 -0
  5. data/TODO +21 -0
  6. data/cloudkit.gemspec +89 -0
  7. data/doc/curl.html +388 -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 +90 -0
  13. data/doc/main.css +151 -0
  14. data/doc/rest-api.html +467 -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 +9 -0
  20. data/examples/6.ru +11 -0
  21. data/examples/TOC +17 -0
  22. data/lib/cloudkit.rb +92 -0
  23. data/lib/cloudkit/constants.rb +34 -0
  24. data/lib/cloudkit/exceptions.rb +10 -0
  25. data/lib/cloudkit/flash_session.rb +20 -0
  26. data/lib/cloudkit/oauth_filter.rb +266 -0
  27. data/lib/cloudkit/oauth_store.rb +48 -0
  28. data/lib/cloudkit/openid_filter.rb +236 -0
  29. data/lib/cloudkit/openid_store.rb +100 -0
  30. data/lib/cloudkit/rack/builder.rb +120 -0
  31. data/lib/cloudkit/rack/router.rb +20 -0
  32. data/lib/cloudkit/request.rb +177 -0
  33. data/lib/cloudkit/service.rb +162 -0
  34. data/lib/cloudkit/store.rb +349 -0
  35. data/lib/cloudkit/store/memory_table.rb +99 -0
  36. data/lib/cloudkit/store/resource.rb +269 -0
  37. data/lib/cloudkit/store/response.rb +52 -0
  38. data/lib/cloudkit/store/response_helpers.rb +84 -0
  39. data/lib/cloudkit/templates/authorize_request_token.erb +19 -0
  40. data/lib/cloudkit/templates/oauth_descriptor.erb +43 -0
  41. data/lib/cloudkit/templates/oauth_meta.erb +8 -0
  42. data/lib/cloudkit/templates/openid_login.erb +31 -0
  43. data/lib/cloudkit/templates/request_authorization.erb +23 -0
  44. data/lib/cloudkit/templates/request_token_denied.erb +18 -0
  45. data/lib/cloudkit/uri.rb +88 -0
  46. data/lib/cloudkit/user_store.rb +37 -0
  47. data/lib/cloudkit/util.rb +25 -0
  48. data/spec/ext_spec.rb +76 -0
  49. data/spec/flash_session_spec.rb +20 -0
  50. data/spec/memory_table_spec.rb +86 -0
  51. data/spec/oauth_filter_spec.rb +326 -0
  52. data/spec/oauth_store_spec.rb +10 -0
  53. data/spec/openid_filter_spec.rb +81 -0
  54. data/spec/openid_store_spec.rb +101 -0
  55. data/spec/rack_builder_spec.rb +39 -0
  56. data/spec/request_spec.rb +191 -0
  57. data/spec/resource_spec.rb +310 -0
  58. data/spec/service_spec.rb +1039 -0
  59. data/spec/spec_helper.rb +32 -0
  60. data/spec/store_spec.rb +10 -0
  61. data/spec/uri_spec.rb +93 -0
  62. data/spec/user_store_spec.rb +10 -0
  63. data/spec/util_spec.rb +11 -0
  64. metadata +180 -0
@@ -0,0 +1,32 @@
1
+ $:.unshift File.expand_path(File.dirname(__FILE__)) + '/../lib'
2
+ require 'cloudkit'
3
+ require 'rexml/document'
4
+
5
+ TEST_REMOTE_USER = '/cloudkit_users/abcdef'.freeze
6
+ VALID_TEST_AUTH = {CLOUDKIT_AUTH_KEY => TEST_REMOTE_USER}.freeze
7
+
8
+ def echo_text(text)
9
+ lambda {|env| [200, app_headers(text), [text]]}
10
+ end
11
+
12
+ def echo_env(key)
13
+ lambda {|env| [200, app_headers(env[key] || ''), [env[key] || '']]}
14
+ end
15
+
16
+ def app_headers(content)
17
+ {'Content-Type' => 'text/html', 'Content-Length' => content.length.to_s}
18
+ end
19
+
20
+ module Rack
21
+ class Config
22
+ def initialize(app, &block)
23
+ @app = app
24
+ @block = block
25
+ end
26
+
27
+ def call(env)
28
+ @block.call(env)
29
+ @app.call(env)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "A CloudKit::Store" do
4
+
5
+ it "should know its version" do
6
+ store = CloudKit::Store.new(:collections => [:items])
7
+ store.version.should == 1
8
+ end
9
+
10
+ end
@@ -0,0 +1,93 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "A URI" do
4
+
5
+ it "should know its string form" do
6
+ CloudKit::URI.new('/items/123').string.should == '/items/123'
7
+ end
8
+
9
+ it "should know its parent resource collection" do
10
+ ['/items', '/items/123', '/items/123/versions', '/items/123/versions/abc'].each { |uri|
11
+ CloudKit::URI.new(uri).collection_uri_fragment.should == '/items'
12
+ }
13
+ end
14
+
15
+ it "should split itself into components" do
16
+ CloudKit::URI.new('/items/123/versions/abc').components.should == ['items', '123', 'versions', 'abc']
17
+ end
18
+
19
+ it "should know its collection type" do
20
+ ['/items', '/items/123', '/items/123/versions', '/items/123/versions/abc'].each { |uri|
21
+ CloudKit::URI.new(uri).collection_type.should == :items
22
+ }
23
+ end
24
+
25
+ it "should know the URI of its current version" do
26
+ ['/items/123', '/items/123/versions', '/items/123/versions/abc'].each { |uri|
27
+ CloudKit::URI.new(uri).current_resource_uri.should == '/items/123'
28
+ }
29
+ end
30
+
31
+ it "should know if it is a meta URI" do
32
+ ['/items', '/items/123', '/items/123/versions', '/items/123/versions/abc'].each { |uri|
33
+ CloudKit::URI.new(uri).should_not be_meta_uri
34
+ }
35
+ CloudKit::URI.new('/cloudkit-meta').should be_meta_uri
36
+ end
37
+
38
+ it "should know if it is a resource collection URI" do
39
+ ['/cloudkit-meta', '/items/123', '/items/123/versions', '/items/123/versions/abc'].each { |uri|
40
+ CloudKit::URI.new(uri).should_not be_resource_collection_uri
41
+ }
42
+ CloudKit::URI.new('/items').should be_resource_collection_uri
43
+ end
44
+
45
+ it "should know if it is a resolved resource collection URI" do
46
+ ['/items', '/items/123', '/items/123/versions', '/items/123/versions/_resolved', '/items/123/versions/abc'].each { |uri|
47
+ CloudKit::URI.new(uri).should_not be_resolved_resource_collection_uri
48
+ }
49
+ CloudKit::URI.new('/items/_resolved').should be_resolved_resource_collection_uri
50
+ end
51
+
52
+ it "should know if it is a resource URI" do
53
+ ['/items', '/items/_resolved', '/items/123/versions', '/items/123/versions/_resolved', '/items/123/versions/abc'].each { |uri|
54
+ CloudKit::URI.new(uri).should_not be_resource_uri
55
+ }
56
+ CloudKit::URI.new('/items/123').should be_resource_uri
57
+ end
58
+
59
+ it "should know if it is a version collection URI" do
60
+ ['/items', '/items/_resolved', '/items/123', '/items/123/versions/_resolved', '/items/123/versions/abc'].each { |uri|
61
+ CloudKit::URI.new(uri).should_not be_version_collection_uri
62
+ }
63
+ CloudKit::URI.new('/items/123/versions').should be_version_collection_uri
64
+ end
65
+
66
+ it "should know if it is a resolved version collection URI" do
67
+ ['/items', '/items/_resolved', '/items/123', '/items/123/versions', '/items/123/versions/abc'].each { |uri|
68
+ CloudKit::URI.new(uri).should_not be_resolved_version_collection_uri
69
+ }
70
+ CloudKit::URI.new('/items/123/versions/_resolved').should be_resolved_version_collection_uri
71
+ end
72
+
73
+ it "should know if it is a resource version URI" do
74
+ ['/items', '/items/_resolved', '/items/123', '/items/123/versions', '/items/123/versions/_resolved'].each { |uri|
75
+ CloudKit::URI.new(uri).should_not be_resource_version_uri
76
+ }
77
+ CloudKit::URI.new('/items/123/versions/abc').should be_resource_version_uri
78
+ end
79
+
80
+ it "should know its cannonical URI string" do
81
+ CloudKit::URI.new('/items/123').cannonical_uri_string.should == '/items/123'
82
+ end
83
+
84
+ it "should generate its cannonical URI string when needed" do
85
+ CloudKit::URI.new('/items').cannonical_uri_string.should match(/\/items\/.+/)
86
+ end
87
+
88
+ it "should fail when attempting to generate a cannonical URI string for versioned resources" do
89
+ lambda {
90
+ CloudKit::URI.new('/items/123/versions/abc').cannonical_uri_string
91
+ }.should raise_error(CloudKit::InvalidURIFormat)
92
+ end
93
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "A UserStore" do
4
+
5
+ it "should know its version" do
6
+ store = CloudKit::UserStore.new
7
+ store.version.should == 1
8
+ end
9
+
10
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ include CloudKit::Util
3
+
4
+ describe "CloudKit::Util" do
5
+
6
+ it "should create routers" do
7
+ router = r(:get, '/path')
8
+ router.class.should == Rack::Router
9
+ end
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,180 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cloudkit-jruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.11.2
5
+ platform: ruby
6
+ authors:
7
+ - Jon Crosby
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-05 00:00:00 +03: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: "1.0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: uuid
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.1
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: oauth
37
+ type: :runtime
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: "0.3"
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: ruby-openid
47
+ type: :runtime
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: "2.1"
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ type: :runtime
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ~>
62
+ - !ruby/object:Gem::Version
63
+ version: "1.1"
64
+ version:
65
+ description: An Open Web JSON Appliance.
66
+ email: jon@joncrosby.me
67
+ executables: []
68
+
69
+ extensions: []
70
+
71
+ extra_rdoc_files: []
72
+
73
+ files:
74
+ - CHANGES
75
+ - COPYING
76
+ - README
77
+ - Rakefile
78
+ - TODO
79
+ - cloudkit.gemspec
80
+ - doc/curl.html
81
+ - doc/images/example-code.gif
82
+ - doc/images/json-title.gif
83
+ - doc/images/oauth-discovery-logo.gif
84
+ - doc/images/openid-logo.gif
85
+ - doc/index.html
86
+ - doc/main.css
87
+ - doc/rest-api.html
88
+ - examples/1.ru
89
+ - examples/2.ru
90
+ - examples/3.ru
91
+ - examples/4.ru
92
+ - examples/5.ru
93
+ - examples/6.ru
94
+ - examples/TOC
95
+ - lib/cloudkit.rb
96
+ - lib/cloudkit/constants.rb
97
+ - lib/cloudkit/exceptions.rb
98
+ - lib/cloudkit/flash_session.rb
99
+ - lib/cloudkit/oauth_filter.rb
100
+ - lib/cloudkit/oauth_store.rb
101
+ - lib/cloudkit/openid_filter.rb
102
+ - lib/cloudkit/openid_store.rb
103
+ - lib/cloudkit/rack/builder.rb
104
+ - lib/cloudkit/rack/router.rb
105
+ - lib/cloudkit/request.rb
106
+ - lib/cloudkit/service.rb
107
+ - lib/cloudkit/store.rb
108
+ - lib/cloudkit/store/memory_table.rb
109
+ - lib/cloudkit/store/resource.rb
110
+ - lib/cloudkit/store/response.rb
111
+ - lib/cloudkit/store/response_helpers.rb
112
+ - lib/cloudkit/templates/authorize_request_token.erb
113
+ - lib/cloudkit/templates/oauth_descriptor.erb
114
+ - lib/cloudkit/templates/oauth_meta.erb
115
+ - lib/cloudkit/templates/openid_login.erb
116
+ - lib/cloudkit/templates/request_authorization.erb
117
+ - lib/cloudkit/templates/request_token_denied.erb
118
+ - lib/cloudkit/uri.rb
119
+ - lib/cloudkit/user_store.rb
120
+ - lib/cloudkit/util.rb
121
+ - spec/ext_spec.rb
122
+ - spec/flash_session_spec.rb
123
+ - spec/memory_table_spec.rb
124
+ - spec/oauth_filter_spec.rb
125
+ - spec/oauth_store_spec.rb
126
+ - spec/openid_filter_spec.rb
127
+ - spec/openid_store_spec.rb
128
+ - spec/rack_builder_spec.rb
129
+ - spec/request_spec.rb
130
+ - spec/resource_spec.rb
131
+ - spec/service_spec.rb
132
+ - spec/spec_helper.rb
133
+ - spec/store_spec.rb
134
+ - spec/uri_spec.rb
135
+ - spec/user_store_spec.rb
136
+ - spec/util_spec.rb
137
+ has_rdoc: true
138
+ homepage: http://getcloudkit.com
139
+ licenses: []
140
+
141
+ post_install_message:
142
+ rdoc_options: []
143
+
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: "0"
151
+ version:
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: "0"
157
+ version:
158
+ requirements: []
159
+
160
+ rubyforge_project: cloudkit
161
+ rubygems_version: 1.3.5
162
+ signing_key:
163
+ specification_version: 2
164
+ summary: An Open Web JSON Appliance.
165
+ test_files:
166
+ - spec/ext_spec.rb
167
+ - spec/flash_session_spec.rb
168
+ - spec/memory_table_spec.rb
169
+ - spec/oauth_filter_spec.rb
170
+ - spec/oauth_store_spec.rb
171
+ - spec/openid_filter_spec.rb
172
+ - spec/openid_store_spec.rb
173
+ - spec/rack_builder_spec.rb
174
+ - spec/request_spec.rb
175
+ - spec/resource_spec.rb
176
+ - spec/service_spec.rb
177
+ - spec/store_spec.rb
178
+ - spec/uri_spec.rb
179
+ - spec/user_store_spec.rb
180
+ - spec/util_spec.rb