sinatra-rake-routes 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/sinatra-rake-routes.rb +18 -14
- data/lib/sinatra-rake-routes/tasks.rb +1 -1
- data/lib/sinatra-rake-routes/version.rb +1 -1
- data/sinatra-rake-routes.gemspec +7 -8
- data/spec/sinatra_rake_routes_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -2
- metadata +16 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 407b7955269b5c168134db5d9281869200d38d11
|
4
|
+
data.tar.gz: d5e39656762c0dede87e9589aa7cfe0fb76164e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1a174a8a372d2bbae676ea191e2c5e3d74d8cd8a063c5c5552958eb893ebab0c5c6bbb85a32162da3c32659d4e4973915972370a5ecc197e447ff054738a512
|
7
|
+
data.tar.gz: 3294f3f0b7be56e948258183e5ef34c7432d1621faca77493173adf02738e022677bd6d34a770ea694661f1c697d1c2d8dcd3882d4b8dcefc81b5e2c73591fe5
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# sinatra-rake-routes [![Circle CI](https://circleci.com/gh/wealthsimple/sinatra-rake-routes.svg?style=svg)](https://circleci.com/gh/wealthsimple/sinatra-rake-routes)
|
2
2
|
|
3
|
-
`rake routes` command for Sinatra applications
|
3
|
+
`rake routes` command for Sinatra applications for printing out all defined routes.
|
4
4
|
|
5
5
|
## Usage
|
6
6
|
|
data/lib/sinatra-rake-routes.rb
CHANGED
@@ -24,24 +24,28 @@ class SinatraRakeRoutes
|
|
24
24
|
@@app_class
|
25
25
|
end
|
26
26
|
|
27
|
-
def
|
27
|
+
def to_s
|
28
28
|
str = []
|
29
|
-
|
30
|
-
app_routes.each do |http_method, routes_list|
|
29
|
+
self.class.app_class.routes.each do |http_method, routes|
|
31
30
|
str << http_method
|
32
|
-
routes =
|
33
|
-
routes_list.each do |item|
|
34
|
-
source = item[0].source
|
35
|
-
source.gsub!(HYPHEN_REGEX.source, "-")
|
36
|
-
source.gsub!(PERIOD_REGEX.source, ".")
|
37
|
-
source.gsub!(SPLAT_REGEX.source, "*")
|
38
|
-
item[1].each do |s|
|
39
|
-
source.sub!(NAMED_PARAM_REGEX_SOURCE, ":#{s}")
|
40
|
-
end
|
41
|
-
routes << source[2...-2]
|
42
|
-
end
|
31
|
+
routes = routes.map { |route| decompile_route(route) }
|
43
32
|
str << routes.sort.join("\n") + "\n"
|
44
33
|
end
|
45
34
|
str.join("\n")
|
46
35
|
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def decompile_route(route)
|
40
|
+
source = route[0].source
|
41
|
+
params = route[1]
|
42
|
+
source.gsub!(HYPHEN_REGEX.source, "-")
|
43
|
+
source.gsub!(PERIOD_REGEX.source, ".")
|
44
|
+
source.gsub!(SPLAT_REGEX.source, "*")
|
45
|
+
params.each do |param|
|
46
|
+
source.sub!(NAMED_PARAM_REGEX_SOURCE, ":#{param}")
|
47
|
+
end
|
48
|
+
# Remove leading "\A" and trailing "\z"
|
49
|
+
source[2...-2]
|
50
|
+
end
|
47
51
|
end
|
data/sinatra-rake-routes.gemspec
CHANGED
@@ -9,19 +9,18 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.author = "Peter Graham"
|
10
10
|
gem.summary = %q{`rake routes` command for Sinatra applications}
|
11
11
|
gem.email = %q{peter@wealthsimple.com}
|
12
|
-
gem.description = %q{
|
13
|
-
gem.homepage = %q{https://github.com/wealthsimple}
|
12
|
+
gem.description = %q{Rake command for printing out all defined routes in Sinatra applications}
|
13
|
+
gem.homepage = %q{https://github.com/wealthsimple/sinatra-rake-routes}
|
14
14
|
gem.files = `git ls-files`.split("\n")
|
15
15
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
16
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
17
|
gem.require_paths = ["lib"]
|
18
18
|
gem.licenses = ["MIT"]
|
19
19
|
|
20
|
-
gem.
|
20
|
+
gem.required_ruby_version = ">= 1.9.3"
|
21
|
+
gem.add_dependency "rake", ">= 0"
|
21
22
|
|
22
|
-
gem.add_development_dependency "rspec"
|
23
|
-
gem.add_development_dependency "
|
24
|
-
gem.add_development_dependency "
|
25
|
-
gem.add_development_dependency "sinatra"
|
26
|
-
gem.add_development_dependency "rspec_junit_formatter"
|
23
|
+
gem.add_development_dependency "rspec", "~> 3.4"
|
24
|
+
gem.add_development_dependency "sinatra", "~> 1.4"
|
25
|
+
gem.add_development_dependency "rspec_junit_formatter", "~> 0.2"
|
27
26
|
end
|
@@ -17,10 +17,10 @@ describe SinatraRakeRoutes do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe "
|
20
|
+
describe "#to_s" do
|
21
21
|
it "outputs routes" do
|
22
22
|
described_class.set_app_class(SampleApp)
|
23
|
-
expect(described_class.
|
23
|
+
expect(described_class.new.to_s).to eq(File.read('./spec/fixtures/sample_app_output.txt'))
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-rake-routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Graham
|
@@ -28,73 +28,45 @@ dependencies:
|
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
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
|
-
- - ">="
|
31
|
+
- - "~>"
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '3.4'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - "
|
38
|
+
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
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'
|
40
|
+
version: '3.4'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
42
|
name: sinatra
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
|
-
- - "
|
45
|
+
- - "~>"
|
74
46
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
47
|
+
version: '1.4'
|
76
48
|
type: :development
|
77
49
|
prerelease: false
|
78
50
|
version_requirements: !ruby/object:Gem::Requirement
|
79
51
|
requirements:
|
80
|
-
- - "
|
52
|
+
- - "~>"
|
81
53
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
54
|
+
version: '1.4'
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
56
|
name: rspec_junit_formatter
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
|
-
- - "
|
59
|
+
- - "~>"
|
88
60
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
61
|
+
version: '0.2'
|
90
62
|
type: :development
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
|
-
- - "
|
66
|
+
- - "~>"
|
95
67
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
description:
|
68
|
+
version: '0.2'
|
69
|
+
description: Rake command for printing out all defined routes in Sinatra applications
|
98
70
|
email: peter@wealthsimple.com
|
99
71
|
executables: []
|
100
72
|
extensions: []
|
@@ -115,7 +87,7 @@ files:
|
|
115
87
|
- spec/spec_helper.rb
|
116
88
|
- spec/support/sample_app.rb
|
117
89
|
- spec/version_spec.rb
|
118
|
-
homepage: https://github.com/wealthsimple
|
90
|
+
homepage: https://github.com/wealthsimple/sinatra-rake-routes
|
119
91
|
licenses:
|
120
92
|
- MIT
|
121
93
|
metadata: {}
|
@@ -127,7 +99,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
99
|
requirements:
|
128
100
|
- - ">="
|
129
101
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
102
|
+
version: 1.9.3
|
131
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
104
|
requirements:
|
133
105
|
- - ">="
|