sinatra-rake-routes 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d5ce5982072c93d1f8ea2a3f091e1a0dab7effd
4
- data.tar.gz: 455143d3f9b4908901fe57bb8bcc12d4e36b1960
3
+ metadata.gz: 20a8a6eb82256cc8d036ce1ed352f4d8594f047e
4
+ data.tar.gz: d59ebfe726be080845da89cb1836018e9bc082fb
5
5
  SHA512:
6
- metadata.gz: 15bb3d4f668108a439caa03d78edde3f515085595f9960cb649c9d8f866919c5e841debbaf6859aca19495ebbd4484005e1414378c65496d026188559792da35
7
- data.tar.gz: 099ee3bfed991ead6f90a05e5d17c1eec290577182ac2e64428b3d6ad5022c811bdec214df20661b0c47696405833b5cf55f965762a7ce08e4a4e428c5f54d16
6
+ metadata.gz: 36cfdde45a9cdc8eb31f07a90c39105d8e799ba30a723aabd66ebe13d7159c9d6c390479a9378adfc5175f95649dbe7bb992d0beb46bb35cc5a96d794d4eaedb
7
+ data.tar.gz: 04a45094da7de351568798efc787d150a484d4fd2a7ecc9e9e207353ccfa5ad9c9b1845c7ca4da462ecab74bd9e67618eac8f2644f0a94ed06d687a647f9f384
data/README.md CHANGED
@@ -31,23 +31,23 @@ require "sinatra-rake-routes/tasks"
31
31
  bundle exec rake routes
32
32
 
33
33
  POST
34
- A/users/:user_id/messages\
35
- A/users\
34
+ /users
35
+ /users/:user_id/messages
36
36
 
37
37
  GET
38
- A/users/:user_id/messages/:message_id\
39
- A/users/:user_id/messages\
40
- A/users/:user_id\
38
+ /users/:user_id
39
+ /users/:user_id/messages
40
+ /users/:user_id/messages/:message_id
41
41
 
42
42
  HEAD
43
- A/users/:user_id/messages/:message_id\
44
- A/users/:user_id/messages\
45
- A/users/:user_id\
43
+ /users/:user_id
44
+ /users/:user_id/messages
45
+ /users/:user_id/messages/:message_id
46
46
 
47
47
  PUT
48
- A/users/:user_id/messages/:message_id\
49
- A/users/:user_id\
48
+ /users/:user_id
49
+ /users/:user_id/messages/:message_id
50
50
 
51
51
  DELETE
52
- A/users/:user_id\
52
+ /users/:user_id
53
53
  ```
@@ -0,0 +1,9 @@
1
+ dependencies:
2
+ override:
3
+ - 'rvm-exec 1.9.3-p551 bundle install'
4
+ - 'rvm-exec 2.3.0 bundle install'
5
+
6
+ test:
7
+ override:
8
+ - 'rvm-exec 1.9.3-p551 bundle exec rspec'
9
+ - 'rvm-exec 2.3.0 bundle exec rspec'
@@ -4,6 +4,14 @@ require 'sinatra-rake-routes/version'
4
4
  class SinatraRakeRoutes
5
5
  @@app_class = nil
6
6
 
7
+ # Sinatra compiles routes into regexes. See below link for how this works:
8
+ # https://github.com/sinatra/sinatra/blob/4c7d38eb1b2cc02ce51029f28e0c3c34ca12ccfd/lib/sinatra/base.rb#L1618
9
+ # The below regexes cover some of the common cases.
10
+ HYPHEN_REGEX = /(?:\-|%2[Dd])/
11
+ NAMED_PARAM_REGEX_SOURCE = "([^\/?#]+)"
12
+ PERIOD_REGEX = /(?:\.|%2[Ee])/
13
+ SPLAT_REGEX = /(.*?)/
14
+
7
15
  def self.set_app_class(klass)
8
16
  if klass.respond_to?(:routes) && klass.routes.is_a?(Hash)
9
17
  @@app_class = klass
@@ -19,15 +27,18 @@ class SinatraRakeRoutes
19
27
  def self.output
20
28
  str = []
21
29
  app_routes = app_class.routes
22
- app_routes.each_with_index do |(http_method, routes_list), i|
30
+ app_routes.each do |http_method, routes_list|
23
31
  str << http_method
24
32
  routes = []
25
33
  routes_list.each do |item|
26
34
  source = item[0].source
35
+ source.gsub!(HYPHEN_REGEX.source, "-")
36
+ source.gsub!(PERIOD_REGEX.source, ".")
37
+ source.gsub!(SPLAT_REGEX.source, "*")
27
38
  item[1].each do |s|
28
- source.sub!(/\(.+?\)/, ':'+s)
39
+ source.sub!(NAMED_PARAM_REGEX_SOURCE, ":#{s}")
29
40
  end
30
- routes << source[1...-1]
41
+ routes << source[2...-2]
31
42
  end
32
43
  str << routes.sort.join("\n") + "\n"
33
44
  end
@@ -1,3 +1,3 @@
1
1
  class SinatraRakeRoutes
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -23,4 +23,5 @@ Gem::Specification.new do |gem|
23
23
  gem.add_development_dependency "rspec-collection_matchers"
24
24
  gem.add_development_dependency "rspec-its"
25
25
  gem.add_development_dependency "sinatra"
26
+ gem.add_development_dependency "rspec_junit_formatter"
26
27
  end
@@ -1,20 +1,24 @@
1
1
  POST
2
- A/users/:user_id/messages\
3
- A/users\
2
+ /test-hyphenated/:test_id/something
3
+ /users
4
+ /users/*/splat/*
5
+ /users/:user_id/messages
4
6
 
5
7
  GET
6
- A/users/:user_id/messages/:message_id\
7
- A/users/:user_id/messages\
8
- A/users/:user_id\
8
+ /users.tar.gz
9
+ /users/:user_id
10
+ /users/:user_id/messages
11
+ /users/:user_id/messages/:message_id
9
12
 
10
13
  HEAD
11
- A/users/:user_id/messages/:message_id\
12
- A/users/:user_id/messages\
13
- A/users/:user_id\
14
+ /users.tar.gz
15
+ /users/:user_id
16
+ /users/:user_id/messages
17
+ /users/:user_id/messages/:message_id
14
18
 
15
19
  PUT
16
- A/users/:user_id/messages/:message_id\
17
- A/users/:user_id\
20
+ /users/:user_id
21
+ /users/:user_id/messages/:message_id
18
22
 
19
23
  DELETE
20
- A/users/:user_id\
24
+ /users/:user_id
@@ -9,12 +9,4 @@ require './lib/sinatra-rake-routes'
9
9
  RSpec.configure do |config|
10
10
  config.filter_run :focus
11
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
12
  end
@@ -3,8 +3,14 @@ require 'sinatra'
3
3
  class SampleApp < Sinatra::Base
4
4
  post '/users' do
5
5
  end
6
+ post '/users/*/splat/*' do
7
+ end
8
+ post '/test-hyphenated/:test_id/something' do
9
+ end
6
10
  post '/users/:user_id/messages' do
7
11
  end
12
+ get '/users.tar.gz' do
13
+ end
8
14
  get '/users/:user_id' do
9
15
  end
10
16
  get '/users/:user_id/messages' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra-rake-routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Graham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-10 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Rails' `rake routes` command for Sinatra applications
84
98
  email: peter@wealthsimple.com
85
99
  executables: []
@@ -91,6 +105,7 @@ files:
91
105
  - Gemfile
92
106
  - LICENSE
93
107
  - README.md
108
+ - circle.yml
94
109
  - lib/sinatra-rake-routes.rb
95
110
  - lib/sinatra-rake-routes/tasks.rb
96
111
  - lib/sinatra-rake-routes/version.rb