quince_sinatra 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +56 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/quince_sinatra/version.rb +5 -0
- data/lib/quince_sinatra.rb +64 -0
- data/quince_sinatra.gemspec +36 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 83300afa45413ec5d43b491f3996b3f97f6563f1f3d3e39c22b304be3b7565d1
|
4
|
+
data.tar.gz: 4ef116e48228ceb69554f6ba2a512b49d6c145c4d45f2c1eb1fe5b8e9b06c0b4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8676aadd4fec7243135b1adcb1d153a2d3b0bfbf4d54a5d5bed096e47a5b4c1c65693361ccfd8e0478637ce710bdc14f5f83ad7e43216a73d6de855db934ad58
|
7
|
+
data.tar.gz: b8ee8de24e71e6411d276fa921a3a554ca10e3a615cd277de3c37f62ac5a26a777bf1d5572fcb226fc94160edee60080e393eafafccf4bab3485d8ead2727d9f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
quince_sinatra (0.1.0)
|
5
|
+
quince (~> 0.1)
|
6
|
+
sinatra (~> 2.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.4.4)
|
12
|
+
mustermann (1.1.1)
|
13
|
+
ruby2_keywords (~> 0.0.1)
|
14
|
+
oj (3.13.5)
|
15
|
+
quince (0.1.0)
|
16
|
+
oj (~> 3.13)
|
17
|
+
typed_struct (>= 0.1.4)
|
18
|
+
rack (2.2.3)
|
19
|
+
rack-protection (2.1.0)
|
20
|
+
rack
|
21
|
+
rake (13.0.6)
|
22
|
+
rbs (1.6.2)
|
23
|
+
rspec (3.10.0)
|
24
|
+
rspec-core (~> 3.10.0)
|
25
|
+
rspec-expectations (~> 3.10.0)
|
26
|
+
rspec-mocks (~> 3.10.0)
|
27
|
+
rspec-core (3.10.1)
|
28
|
+
rspec-support (~> 3.10.0)
|
29
|
+
rspec-expectations (3.10.1)
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
+
rspec-support (~> 3.10.0)
|
32
|
+
rspec-mocks (3.10.2)
|
33
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
+
rspec-support (~> 3.10.0)
|
35
|
+
rspec-support (3.10.2)
|
36
|
+
ruby2_keywords (0.0.5)
|
37
|
+
sinatra (2.1.0)
|
38
|
+
mustermann (~> 1.0)
|
39
|
+
rack (~> 2.2)
|
40
|
+
rack-protection (= 2.1.0)
|
41
|
+
tilt (~> 2.0)
|
42
|
+
tilt (2.0.10)
|
43
|
+
typed_struct (0.1.4)
|
44
|
+
rbs (~> 1.0)
|
45
|
+
|
46
|
+
PLATFORMS
|
47
|
+
ruby
|
48
|
+
x86_64-darwin-19
|
49
|
+
|
50
|
+
DEPENDENCIES
|
51
|
+
quince_sinatra!
|
52
|
+
rake (~> 13.0)
|
53
|
+
rspec (~> 3.0)
|
54
|
+
|
55
|
+
BUNDLED WITH
|
56
|
+
2.2.8
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Joseph Johansen
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# QuinceSinatra
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/quince_sinatra`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'quince_sinatra'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install quince_sinatra
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/quince_sinatra.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "quince_sinatra"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
ENV["RACK_ENV"] ||= "development"
|
4
|
+
|
5
|
+
require_relative "quince_sinatra/version"
|
6
|
+
require "sinatra/base"
|
7
|
+
require "sinatra/reloader" if ENV["RACK_ENV"] == "development"
|
8
|
+
require "rack/contrib"
|
9
|
+
require "quince"
|
10
|
+
|
11
|
+
module Quince
|
12
|
+
class SinatraMiddleware
|
13
|
+
def initialize
|
14
|
+
Quince.underlying_app = Class.new(Sinatra::Base) do
|
15
|
+
configure :development do
|
16
|
+
if Object.const_defined? "Sinatra::Reloader"
|
17
|
+
register Sinatra::Reloader
|
18
|
+
dont_reload __FILE__
|
19
|
+
also_reload $0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
use Rack::JSONBodyParser
|
23
|
+
set :public_folder, File.join(File.dirname(File.expand_path($0)), "public")
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_route_handler(verb:, route:, component: nil, &blck)
|
28
|
+
meth = case verb
|
29
|
+
when :POST, :post
|
30
|
+
:post
|
31
|
+
when :GET, :get
|
32
|
+
:get
|
33
|
+
else
|
34
|
+
raise "invalid verb"
|
35
|
+
end
|
36
|
+
handler = component ? ->(_) { component } : blck
|
37
|
+
Quince::SinatraMiddleware.send(:routes)[[verb, route]] = handler
|
38
|
+
|
39
|
+
Quince.underlying_app.public_send meth, route do
|
40
|
+
handler = Quince::SinatraMiddleware.send(:routes)[[verb, route]]
|
41
|
+
Quince.to_html(handler.call(params))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
private_class_method def self.routes
|
46
|
+
@routes ||= {}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Quince.middleware = Quince::SinatraMiddleware.new
|
52
|
+
|
53
|
+
at_exit do
|
54
|
+
if Object.const_defined? "Sinatra::Reloader"
|
55
|
+
app_dir = Pathname(File.expand_path($0)).dirname.to_s
|
56
|
+
$LOADED_FEATURES.each do |f|
|
57
|
+
next unless f.start_with? app_dir
|
58
|
+
|
59
|
+
Quince.underlying_app.also_reload f
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
Quince.underlying_app.run!
|
64
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/quince_sinatra/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "quince_sinatra"
|
7
|
+
spec.version = QuinceSinatra::VERSION
|
8
|
+
spec.authors = ["Joseph Johansen"]
|
9
|
+
spec.email = ["joe@stotles.com"]
|
10
|
+
|
11
|
+
spec.summary = "A sinatra-based adapter for Quince"
|
12
|
+
spec.homepage = "https://github.com/johansenja/quince_sinatra"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
15
|
+
|
16
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
# Uncomment to register a new dependency of your gem
|
31
|
+
spec.add_dependency "sinatra", "~> 2.1"
|
32
|
+
spec.add_dependency "quince", "~> 0.1"
|
33
|
+
|
34
|
+
# For more information and examples about making a new gem, checkout our
|
35
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: quince_sinatra
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joseph Johansen
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-09-09 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: '2.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: quince
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.1'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- joe@stotles.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- Gemfile
|
51
|
+
- Gemfile.lock
|
52
|
+
- LICENSE.txt
|
53
|
+
- README.md
|
54
|
+
- Rakefile
|
55
|
+
- bin/console
|
56
|
+
- bin/setup
|
57
|
+
- lib/quince_sinatra.rb
|
58
|
+
- lib/quince_sinatra/version.rb
|
59
|
+
- quince_sinatra.gemspec
|
60
|
+
homepage: https://github.com/johansenja/quince_sinatra
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata:
|
64
|
+
allowed_push_host: https://rubygems.org
|
65
|
+
homepage_uri: https://github.com/johansenja/quince_sinatra
|
66
|
+
source_code_uri: https://github.com/johansenja/quince_sinatra
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.4.0
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubygems_version: 3.1.2
|
83
|
+
signing_key:
|
84
|
+
specification_version: 4
|
85
|
+
summary: A sinatra-based adapter for Quince
|
86
|
+
test_files: []
|