sinatra-presence 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +2 -0
- data/lib/sinatra/presence.rb +17 -0
- data/lib/sinatra/presence/version.rb +5 -0
- data/sinatra-presence.gemspec +27 -0
- data/spec/app/test_app.rb +14 -0
- data/spec/extension_spec.rb +16 -0
- data/spec/spec_helper.rb +43 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16920214b89c864b292b445fec645cbf76eaef13
|
4
|
+
data.tar.gz: e7724d6960d34238b13c62b404a9229e3cc0c20a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 183fe9402413cd35e80dc1dae6043c8c06e44737aaeca48802a442e9a71ec48878460d86d356b27f83494aa06a46a49597ade9c45183033d7228c532109145e1
|
7
|
+
data.tar.gz: d6b50108d31ccf140f680e175d46d17f7db087701ed362ba537b57e4a18d842d6edcd5b0b7b264a52fc00078b0fc0c43190123013495cdc021780ffd6f60f2e3
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Patrick Farrell
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Sinatra::Presence
|
2
|
+
|
3
|
+
A Sinatra extension that will recognize if your request could be redirected to a local network location.
|
4
|
+
|
5
|
+
Why?
|
6
|
+
|
7
|
+
Let's say you run applications on your home network... why use the infrastructure of the internet when
|
8
|
+
your requests could be serviced locally?
|
9
|
+
|
10
|
+
Why, indeed...
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
gem 'sinatra-presence'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install sinatra-presence
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
Register like a typical Sinatra extension
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it ( https://github.com/pfarrell/presence/fork )
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
module Sinatra
|
4
|
+
module Presence
|
5
|
+
|
6
|
+
def self.registered(app)
|
7
|
+
app.set :local_authority, '127.0.0.1:9292' # http://en.wikipedia.org/wiki/URI_scheme
|
8
|
+
|
9
|
+
app.get '/local' do
|
10
|
+
new_url = request.url.gsub("#{request.host_with_port}", "#{settings.local_authority}")
|
11
|
+
.gsub("/local", "")
|
12
|
+
redirect to(new_url)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sinatra/presence/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sinatra-presence"
|
8
|
+
spec.version = Sinatra::Presence::VERSION
|
9
|
+
spec.authors = ["Patrick Farrell"]
|
10
|
+
spec.email = ["mr.pfarrell@gmail.com"]
|
11
|
+
spec.summary = %q{Adds ability to redirect an application to a local ip}
|
12
|
+
spec.description = %q{Sinatra extension for allowing an application to auto-redirect to
|
13
|
+
to a local ip address when it's possible.}
|
14
|
+
spec.homepage = "https://github.com/pfarrell/sinatra-presence"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'sinatra', '~> 1.3'
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.3"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
26
|
+
spec.add_development_dependency "rack-test", "~> 0.6"
|
27
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
class TestApp < Sinatra::Base
|
4
|
+
register Sinatra::Presence
|
5
|
+
|
6
|
+
#set :views, File.join(File.dirname(__FILE__), 'views')
|
7
|
+
#set :public_folder, File.join(File.dirname(__FILE__), 'public')
|
8
|
+
#set :show_exceptions, false
|
9
|
+
|
10
|
+
get '/' do
|
11
|
+
puts "Hellocal"
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Sinatra::Presence do
|
4
|
+
it "should initialize with :local_authority set to 127.0.0.1" do
|
5
|
+
expect(TestApp.local_authority).to eq('127.0.0.1:9292')
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should respond to '/local'" do
|
9
|
+
get '/local'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should redirect requests to '/local'" do
|
13
|
+
get '/local'
|
14
|
+
expect(last_response).to be_redirect
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'rspec'
|
4
|
+
require 'rack/test'
|
5
|
+
|
6
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'sinatra', 'presence')
|
7
|
+
require File.join(File.dirname(__FILE__), 'app', 'test_app')
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
=begin
|
11
|
+
config.expect_with :rspec do |expectations|
|
12
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
13
|
+
end
|
14
|
+
|
15
|
+
config.mock_with :rspec do |mocks|
|
16
|
+
mocks.verify_partial_doubles = true
|
17
|
+
end
|
18
|
+
|
19
|
+
begin
|
20
|
+
config.filter_run :focus
|
21
|
+
config.run_all_when_everything_filtered = true
|
22
|
+
config.disable_monkey_patching!
|
23
|
+
config.warnings = true
|
24
|
+
if config.files_to_run.one?
|
25
|
+
config.default_formatter = 'doc'
|
26
|
+
end
|
27
|
+
|
28
|
+
config.profile_examples = 10
|
29
|
+
|
30
|
+
config.order = :random
|
31
|
+
|
32
|
+
Kernel.srand config.seed
|
33
|
+
end
|
34
|
+
=end
|
35
|
+
def app
|
36
|
+
@app ||= ::Rack::Builder.new do
|
37
|
+
run ::TestApp
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
config.include ::Rack::Test::Methods
|
42
|
+
end
|
43
|
+
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-presence
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patrick Farrell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sinatra
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.6'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.6'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rack-test
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.6'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.6'
|
83
|
+
description: |-
|
84
|
+
Sinatra extension for allowing an application to auto-redirect to
|
85
|
+
to a local ip address when it's possible.
|
86
|
+
email:
|
87
|
+
- mr.pfarrell@gmail.com
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- ".gitignore"
|
93
|
+
- ".rspec"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- lib/sinatra/presence.rb
|
99
|
+
- lib/sinatra/presence/version.rb
|
100
|
+
- sinatra-presence.gemspec
|
101
|
+
- spec/app/test_app.rb
|
102
|
+
- spec/extension_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
homepage: https://github.com/pfarrell/sinatra-presence
|
105
|
+
licenses:
|
106
|
+
- MIT
|
107
|
+
metadata: {}
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
requirements: []
|
123
|
+
rubyforge_project:
|
124
|
+
rubygems_version: 2.2.2
|
125
|
+
signing_key:
|
126
|
+
specification_version: 4
|
127
|
+
summary: Adds ability to redirect an application to a local ip
|
128
|
+
test_files:
|
129
|
+
- spec/app/test_app.rb
|
130
|
+
- spec/extension_spec.rb
|
131
|
+
- spec/spec_helper.rb
|