sinatra-cross_origin 0.1.0 → 0.2.0

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.
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2007, 2008, 2009 Brit Gardner
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,68 @@
1
+ ## About
2
+ A simple Sinatra extension to enable Cross Domain Resource Sharing (CORS)
3
+ To see more on cross domain resource sharing, see https://developer.mozilla.org/En/HTTP_access_control
4
+
5
+ ## Installation
6
+ sudo gem install sinatra-cross_origin
7
+
8
+ ## Examples
9
+
10
+ To enable cross origin requests for all routes:
11
+
12
+ require 'sinatra'
13
+ require 'sinatra/cross_origin'
14
+
15
+ configure do
16
+ enable :cross_origin
17
+ end
18
+
19
+ To only enable cross origin requests for certain routes:
20
+
21
+ get '/cross_origin' do
22
+ cross_origin
23
+ "This is available to cross-origin javascripts"
24
+ end
25
+
26
+ ## Global Configuration
27
+
28
+ You can set global options via the normal Sinatra set method:
29
+
30
+ set :allow_origin, :any
31
+ set :allow_methods, [:get, :post, :options]
32
+ set :allow_credentials, true
33
+ set :max_age, "1728000"
34
+
35
+ You can change configuration options on the fly within routes with:
36
+
37
+ get '/custom' do
38
+ cross_origin :allow_origin => 'http://example.com',
39
+ :allow_methods => [:get],
40
+ :allow_credentials => false,
41
+ :max_age => "60"
42
+
43
+ "My custom cross origin response"
44
+ end
45
+
46
+ ## License
47
+ Copyright (c) 2007, 2008, 2009 Brit Gardner
48
+
49
+ Permission is hereby granted, free of charge, to any person
50
+ obtaining a copy of this software and associated documentation
51
+ files (the "Software"), to deal in the Software without
52
+ restriction, including without limitation the rights to use,
53
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
54
+ copies of the Software, and to permit persons to whom the
55
+ Software is furnished to do so, subject to the following
56
+ conditions:
57
+
58
+ The above copyright notice and this permission notice shall be
59
+ included in all copies or substantial portions of the Software.
60
+
61
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
62
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
63
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
64
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
65
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
66
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
67
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
68
+ OTHER DEALINGS IN THE SOFTWARE.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -27,15 +27,15 @@ module Sinatra
27
27
  # as a hash
28
28
  def cross_origin(hash=nil)
29
29
  return unless request.env['HTTP_ORIGIN']
30
- options.set hash if hash
30
+ settings.set hash if hash
31
31
 
32
- origin = options.allow_origin == :any ? request.env['HTTP_ORIGIN'] : options.allow_origin
33
- methods = options.allow_methods.map{ |m| m.to_s.upcase! }.join(', ')
32
+ origin = settings.allow_origin == :any ? request.env['HTTP_ORIGIN'] : settings.allow_origin
33
+ methods = settings.allow_methods.map{ |m| m.to_s.upcase! }.join(', ')
34
34
 
35
35
  headers 'Access-Control-Allow-Origin' => origin,
36
36
  'Access-Control-Allow-Methods' => methods,
37
- 'Access-Control-Allow-Credentials' => options.allow_credentials.to_s,
38
- 'Access-Control-Max-Age' => options.max_age.to_s
37
+ 'Access-Control-Allow-Credentials' => settings.allow_credentials.to_s,
38
+ 'Access-Control-Max-Age' => settings.max_age.to_s
39
39
  end
40
40
  end
41
41
 
@@ -51,10 +51,12 @@ module Sinatra
51
51
 
52
52
 
53
53
  app.before do
54
- cross_origin if options.cross_origin
54
+ cross_origin if settings.cross_origin
55
55
  end
56
56
 
57
57
  end
58
58
  end
59
59
 
60
+ register CrossOrigin
61
+
60
62
  end
@@ -1,46 +1,41 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{sinatra-cross_origin}
8
- s.version = "0.1.0"
7
+ s.name = "sinatra-cross_origin"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Brit Gardner"]
12
- s.date = %q{2009-12-28}
13
- s.description = %q{Cross Origin Resource Sharing helper for Sinatra}
14
- s.email = %q{brit@britg.com}
12
+ s.date = "2012-07-19"
13
+ s.description = "Cross Origin Resource Sharing helper for Sinatra"
14
+ s.email = "brit@britg.com"
15
15
  s.extra_rdoc_files = [
16
- "README"
16
+ "LICENSE",
17
+ "README.markdown"
17
18
  ]
18
19
  s.files = [
19
- "README",
20
- "Rakefile",
21
- "VERSION",
22
- "lib/sinatra/cross_origin.rb",
23
- "sinatra-cross_origin.gemspec",
24
- "test/app/test_app.rb",
25
- "test/test_all.rb",
26
- "test/test_helper.rb"
27
- ]
28
- s.homepage = %q{http://github.com/britg/sinatra-cross_origin}
29
- s.rdoc_options = ["--charset=UTF-8"]
30
- s.require_paths = ["lib"]
31
- s.rubygems_version = %q{1.3.5}
32
- s.summary = %q{Cross Origin Resource Sharing helper for Sinatra}
33
- s.test_files = [
20
+ "LICENSE",
21
+ "README.markdown",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/sinatra/cross_origin.rb",
25
+ "sinatra-cross_origin.gemspec",
34
26
  "test/app/test_app.rb",
35
- "test/test_all.rb",
36
- "test/test_helper.rb"
27
+ "test/test_all.rb",
28
+ "test/test_helper.rb"
37
29
  ]
30
+ s.homepage = "http://github.com/britg/sinatra-cross_origin"
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = "1.8.11"
33
+ s.summary = "Cross Origin Resource Sharing helper for Sinatra"
38
34
 
39
35
  if s.respond_to? :specification_version then
40
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
36
  s.specification_version = 3
42
37
 
43
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
38
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
39
  else
45
40
  end
46
41
  else
metadata CHANGED
@@ -1,28 +1,26 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sinatra-cross_origin
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Brit Gardner
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2009-12-28 00:00:00 -06:00
13
- default_executable:
12
+ date: 2012-07-19 00:00:00.000000000Z
14
13
  dependencies: []
15
-
16
14
  description: Cross Origin Resource Sharing helper for Sinatra
17
15
  email: brit@britg.com
18
16
  executables: []
19
-
20
17
  extensions: []
21
-
22
- extra_rdoc_files:
23
- - README
24
- files:
25
- - README
18
+ extra_rdoc_files:
19
+ - LICENSE
20
+ - README.markdown
21
+ files:
22
+ - LICENSE
23
+ - README.markdown
26
24
  - Rakefile
27
25
  - VERSION
28
26
  - lib/sinatra/cross_origin.rb
@@ -30,35 +28,28 @@ files:
30
28
  - test/app/test_app.rb
31
29
  - test/test_all.rb
32
30
  - test/test_helper.rb
33
- has_rdoc: true
34
31
  homepage: http://github.com/britg/sinatra-cross_origin
35
32
  licenses: []
36
-
37
33
  post_install_message:
38
- rdoc_options:
39
- - --charset=UTF-8
40
- require_paths:
34
+ rdoc_options: []
35
+ require_paths:
41
36
  - lib
42
- required_ruby_version: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: "0"
47
- version:
48
- required_rubygems_version: !ruby/object:Gem::Requirement
49
- requirements:
50
- - - ">="
51
- - !ruby/object:Gem::Version
52
- version: "0"
53
- version:
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
54
49
  requirements: []
55
-
56
50
  rubyforge_project:
57
- rubygems_version: 1.3.5
51
+ rubygems_version: 1.8.11
58
52
  signing_key:
59
53
  specification_version: 3
60
54
  summary: Cross Origin Resource Sharing helper for Sinatra
61
- test_files:
62
- - test/app/test_app.rb
63
- - test/test_all.rb
64
- - test/test_helper.rb
55
+ test_files: []
data/README DELETED
File without changes