sinatra-rake-routes 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 +36 -0
- data/.rspec +3 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +53 -0
- data/lib/sinatra-rake-routes.rb +36 -0
- data/lib/sinatra-rake-routes/tasks.rb +8 -0
- data/lib/sinatra-rake-routes/version.rb +3 -0
- data/sinatra-rake-routes.gemspec +26 -0
- data/spec/fixtures/sample_app_output.txt +20 -0
- data/spec/sinatra_rake_routes_spec.rb +26 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/support/sample_app.rb +20 -0
- data/spec/version_spec.rb +5 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1d5ce5982072c93d1f8ea2a3f091e1a0dab7effd
|
4
|
+
data.tar.gz: 455143d3f9b4908901fe57bb8bcc12d4e36b1960
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 15bb3d4f668108a439caa03d78edde3f515085595f9960cb649c9d8f866919c5e841debbaf6859aca19495ebbd4484005e1414378c65496d026188559792da35
|
7
|
+
data.tar.gz: 099ee3bfed991ead6f90a05e5d17c1eec290577182ac2e64428b3d6ad5022c811bdec214df20661b0c47696405833b5cf55f965762a7ce08e4a4e428c5f54d16
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalization:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
Gemfile.lock
|
32
|
+
.ruby-version
|
33
|
+
.ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Wealthsimple
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# sinatra-rake-routes [](https://circleci.com/gh/wealthsimple/sinatra-rake-routes)
|
2
|
+
|
3
|
+
`rake routes` command for Sinatra applications
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Install by adding the following to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'sinatra-rake-routes'
|
11
|
+
```
|
12
|
+
|
13
|
+
Add the below code to your Rakefile. Make sure to require `sinatra-rake-routes/tasks` *after* the `:configure_routes` task is defined, otherwise it won't be picked up correctly.
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
# Rakefile
|
17
|
+
|
18
|
+
task :configure_routes do
|
19
|
+
require "sinatra-rake-routes"
|
20
|
+
# Tell SinatraRakeRoutes what your Sinatra::Base application class is called:
|
21
|
+
require './my_app'
|
22
|
+
SinatraRakeRoutes.set_app_class(MyApp)
|
23
|
+
end
|
24
|
+
|
25
|
+
require "sinatra-rake-routes/tasks"
|
26
|
+
```
|
27
|
+
|
28
|
+
## Example output
|
29
|
+
|
30
|
+
```
|
31
|
+
bundle exec rake routes
|
32
|
+
|
33
|
+
POST
|
34
|
+
A/users/:user_id/messages\
|
35
|
+
A/users\
|
36
|
+
|
37
|
+
GET
|
38
|
+
A/users/:user_id/messages/:message_id\
|
39
|
+
A/users/:user_id/messages\
|
40
|
+
A/users/:user_id\
|
41
|
+
|
42
|
+
HEAD
|
43
|
+
A/users/:user_id/messages/:message_id\
|
44
|
+
A/users/:user_id/messages\
|
45
|
+
A/users/:user_id\
|
46
|
+
|
47
|
+
PUT
|
48
|
+
A/users/:user_id/messages/:message_id\
|
49
|
+
A/users/:user_id\
|
50
|
+
|
51
|
+
DELETE
|
52
|
+
A/users/:user_id\
|
53
|
+
```
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'sinatra-rake-routes/version'
|
3
|
+
|
4
|
+
class SinatraRakeRoutes
|
5
|
+
@@app_class = nil
|
6
|
+
|
7
|
+
def self.set_app_class(klass)
|
8
|
+
if klass.respond_to?(:routes) && klass.routes.is_a?(Hash)
|
9
|
+
@@app_class = klass
|
10
|
+
else
|
11
|
+
raise "#{klass} does not appear to be a valid Sinatra Application"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.app_class
|
16
|
+
@@app_class
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.output
|
20
|
+
str = []
|
21
|
+
app_routes = app_class.routes
|
22
|
+
app_routes.each_with_index do |(http_method, routes_list), i|
|
23
|
+
str << http_method
|
24
|
+
routes = []
|
25
|
+
routes_list.each do |item|
|
26
|
+
source = item[0].source
|
27
|
+
item[1].each do |s|
|
28
|
+
source.sub!(/\(.+?\)/, ':'+s)
|
29
|
+
end
|
30
|
+
routes << source[1...-1]
|
31
|
+
end
|
32
|
+
str << routes.sort.join("\n") + "\n"
|
33
|
+
end
|
34
|
+
str.join("\n")
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "sinatra-rake-routes/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = %q{sinatra-rake-routes}
|
8
|
+
gem.version = SinatraRakeRoutes::VERSION
|
9
|
+
gem.author = "Peter Graham"
|
10
|
+
gem.summary = %q{`rake routes` command for Sinatra applications}
|
11
|
+
gem.email = %q{peter@wealthsimple.com}
|
12
|
+
gem.description = %q{Rails' `rake routes` command for Sinatra applications}
|
13
|
+
gem.homepage = %q{https://github.com/wealthsimple}
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
gem.licenses = ["MIT"]
|
19
|
+
|
20
|
+
gem.add_dependency "rake"
|
21
|
+
|
22
|
+
gem.add_development_dependency "rspec"
|
23
|
+
gem.add_development_dependency "rspec-collection_matchers"
|
24
|
+
gem.add_development_dependency "rspec-its"
|
25
|
+
gem.add_development_dependency "sinatra"
|
26
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
POST
|
2
|
+
A/users/:user_id/messages\
|
3
|
+
A/users\
|
4
|
+
|
5
|
+
GET
|
6
|
+
A/users/:user_id/messages/:message_id\
|
7
|
+
A/users/:user_id/messages\
|
8
|
+
A/users/:user_id\
|
9
|
+
|
10
|
+
HEAD
|
11
|
+
A/users/:user_id/messages/:message_id\
|
12
|
+
A/users/:user_id/messages\
|
13
|
+
A/users/:user_id\
|
14
|
+
|
15
|
+
PUT
|
16
|
+
A/users/:user_id/messages/:message_id\
|
17
|
+
A/users/:user_id\
|
18
|
+
|
19
|
+
DELETE
|
20
|
+
A/users/:user_id\
|
@@ -0,0 +1,26 @@
|
|
1
|
+
describe SinatraRakeRoutes do
|
2
|
+
describe ".set_app_class" do
|
3
|
+
context "with valid Sinatra::Base subclass" do
|
4
|
+
it "sets app class" do
|
5
|
+
expect(described_class.app_class).to be_nil
|
6
|
+
|
7
|
+
described_class.set_app_class(SampleApp)
|
8
|
+
expect(described_class.app_class).to eq(SampleApp)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
context "with an invalid class supplied" do
|
13
|
+
it "raises an error" do
|
14
|
+
expect { described_class.set_app_class(Array) }.
|
15
|
+
to raise_error("Array does not appear to be a valid Sinatra Application")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe ".output" do
|
21
|
+
it "outputs routes" do
|
22
|
+
described_class.set_app_class(SampleApp)
|
23
|
+
expect(described_class.output).to eq(File.read('./spec/fixtures/sample_app_output.txt'))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'rspec/collection_matchers'
|
3
|
+
require 'rspec/its'
|
4
|
+
|
5
|
+
Dir["./spec/support/**/*.rb"].each { |f| require f }
|
6
|
+
|
7
|
+
require './lib/sinatra-rake-routes'
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.filter_run :focus
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
|
13
|
+
config.expect_with :rspec do |expectations|
|
14
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
15
|
+
end
|
16
|
+
|
17
|
+
config.mock_with :rspec do |mocks|
|
18
|
+
mocks.verify_partial_doubles = true
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
|
3
|
+
class SampleApp < Sinatra::Base
|
4
|
+
post '/users' do
|
5
|
+
end
|
6
|
+
post '/users/:user_id/messages' do
|
7
|
+
end
|
8
|
+
get '/users/:user_id' do
|
9
|
+
end
|
10
|
+
get '/users/:user_id/messages' do
|
11
|
+
end
|
12
|
+
get '/users/:user_id/messages/:message_id' do
|
13
|
+
end
|
14
|
+
put '/users/:user_id/messages/:message_id' do
|
15
|
+
end
|
16
|
+
put '/users/:user_id' do
|
17
|
+
end
|
18
|
+
delete '/users/:user_id' do
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-rake-routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Graham
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-collection_matchers
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sinatra
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: Rails' `rake routes` command for Sinatra applications
|
84
|
+
email: peter@wealthsimple.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- ".gitignore"
|
90
|
+
- ".rspec"
|
91
|
+
- Gemfile
|
92
|
+
- LICENSE
|
93
|
+
- README.md
|
94
|
+
- lib/sinatra-rake-routes.rb
|
95
|
+
- lib/sinatra-rake-routes/tasks.rb
|
96
|
+
- lib/sinatra-rake-routes/version.rb
|
97
|
+
- sinatra-rake-routes.gemspec
|
98
|
+
- spec/fixtures/sample_app_output.txt
|
99
|
+
- spec/sinatra_rake_routes_spec.rb
|
100
|
+
- spec/spec_helper.rb
|
101
|
+
- spec/support/sample_app.rb
|
102
|
+
- spec/version_spec.rb
|
103
|
+
homepage: https://github.com/wealthsimple
|
104
|
+
licenses:
|
105
|
+
- MIT
|
106
|
+
metadata: {}
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubyforge_project:
|
123
|
+
rubygems_version: 2.5.1
|
124
|
+
signing_key:
|
125
|
+
specification_version: 4
|
126
|
+
summary: "`rake routes` command for Sinatra applications"
|
127
|
+
test_files:
|
128
|
+
- spec/fixtures/sample_app_output.txt
|
129
|
+
- spec/sinatra_rake_routes_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
- spec/support/sample_app.rb
|
132
|
+
- spec/version_spec.rb
|