roda-route_list 1.0.0 → 2.0.0

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: 22860ddac7c2f5805445a274c59217bfd1b829f1
4
- data.tar.gz: 75976d49b266e7f6a4783ba4a4e8376ce7807873
3
+ metadata.gz: 745db7ba79ed2650b068c20e5665ab0c7b96e78b
4
+ data.tar.gz: 963dbb5cf8bc7da828ebd287522f7e562e05a4e3
5
5
  SHA512:
6
- metadata.gz: 676bb12a6726a91ea0c782e18bcb7f0d4c925748129e706abec2ae0e3d3a4b19c14c1aa52125b11c10fbd01a3240dbc3899a93fb29caec8de6370f2f15f46cdf
7
- data.tar.gz: f026084da9cd254125f26abd4e3efe7b45703cdbd1ed0436669c9ef10aac413a0c8f57a727630fab3b4f2ba0561d45d53cbd6a2869fdfe228ceab45406e68c1e
6
+ metadata.gz: ec654b9fa1c3e65b62b238870e15b4d3824f4017d35f21d5a034e91cc23a74be5af3ea53a42d8c13e0ef1e4d69fb45b46b0681f37a5c40b4b5827f6b269393a5
7
+ data.tar.gz: 9c689b0166f9a48b417d3906ae4b15e9da3ba292a94a50ece93289f996532c316d4fe16a524f53846699330169072c62635078b42250f16878bfa1f36b5f4f8e
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ = 2.0.0 (2016-02-24)
2
+
3
+ * Use Roda.listed_route instead of Road.named_route to not conflict with multi_route plugin (jeremyevans) (#1)
4
+
1
5
  = 1.0.0 (2015-03-08)
2
6
 
3
7
  * Initial public release
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2015 Jeremy Evans
1
+ Copyright (c) 2015-2016 Jeremy Evans
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -49,15 +49,15 @@ get route information:
49
49
  route_list # => [{:path=>'/path/to/foo', :methods=>['GET', 'POST']}]
50
50
 
51
51
  # path for the route with the given name
52
- named_route(:route_name) # => '/path/to/foo'
52
+ listed_route(:route_name) # => '/path/to/foo'
53
53
 
54
54
  # path for the route with the given name, supplying hash for placeholders
55
- named_route(:foo, :foo_id=>3) # => '/path/to/foo/3'
55
+ listed_route(:foo, :foo_id=>3) # => '/path/to/foo/3'
56
56
 
57
57
  # path for the route with the given name, supplying array for placeholders
58
- named_route(:foo, [3]) # => '/path/to/foo/3'
58
+ listed_route(:foo, [3]) # => '/path/to/foo/3'
59
59
 
60
- The +named_route+ method is also available at the instance level to make it
60
+ The +listed_route+ method is also available at the instance level to make it
61
61
  easier to use inside the route block.
62
62
 
63
63
  === Automatically Updating the Routes Metadata
data/Rakefile CHANGED
@@ -10,36 +10,14 @@ end
10
10
 
11
11
  ### Specs
12
12
 
13
- begin
14
- begin
15
- # RSpec 1
16
- require "spec/rake/spectask"
17
- spec_class = Spec::Rake::SpecTask
18
- spec_files_meth = :spec_files=
19
- rescue LoadError
20
- # RSpec 2
21
- require "rspec/core/rake_task"
22
- spec_class = RSpec::Core::RakeTask
23
- spec_files_meth = :pattern=
24
- end
25
-
26
- spec = lambda do |name, files, d|
27
- lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'lib')
28
- ENV['RUBYLIB'] ? (ENV['RUBYLIB'] += ":#{lib_dir}") : (ENV['RUBYLIB'] = lib_dir)
29
- desc d
30
- spec_class.new(name) do |t|
31
- ENV['RUBY'] = FileUtils::RUBY
32
- t.send(spec_files_meth, files)
33
- end
34
- end
35
-
36
- task :default => [:spec]
37
- spec.call("spec", Dir["spec/*_spec.rb"], "Run specs")
38
- rescue LoadError
39
- task :default do
40
- puts "Must install rspec to run the default task (which runs specs)"
41
- end
13
+ desc "Build roda-route_list gem"
14
+ task :spec do |p|
15
+ ENV['RUBY'] = FileUtils::RUBY
16
+ ENV['RUBYLIB'] = "ENV['RUBYLIB']:lib"
17
+ ENV['RUBYOPT'] = "-rubygems"
18
+ sh %{#{FileUtils::RUBY} spec/roda-route_list_spec.rb }
42
19
  end
20
+ task :default=>:spec
43
21
 
44
22
  ### RDoc
45
23
 
@@ -41,15 +41,15 @@ class Roda
41
41
  # route_list # => [{:path=>'/path/to/foo', :methods=>['GET', 'POST']}]
42
42
  #
43
43
  # # path for the route with the given name
44
- # named_route(:route_name) # => '/path/to/foo'
44
+ # listed_route(:route_name) # => '/path/to/foo'
45
45
  #
46
46
  # # path for the route with the given name, supplying hash for placeholders
47
- # named_route(:foo, :foo_id=>3) # => '/path/to/foo/3'
47
+ # listed_route(:foo, :foo_id=>3) # => '/path/to/foo/3'
48
48
  #
49
49
  # # path for the route with the given name, supplying array for placeholders
50
- # named_route(:foo, [3]) # => '/path/to/foo/3'
50
+ # listed_route(:foo, [3]) # => '/path/to/foo/3'
51
51
  #
52
- # The +named_route+ method is also available at the instance level to make it
52
+ # The +listed_route+ method is also available at the instance level to make it
53
53
  # easier to use inside the route block.
54
54
  module RouteList
55
55
  # Set the file to load the routes metadata from. Options:
@@ -68,7 +68,7 @@ class Roda
68
68
  # values in the path are replaced with the matching values in args.
69
69
  # If args is an array, placeholder values are taken from the array
70
70
  # in order.
71
- def named_route(name, args=nil)
71
+ def listed_route(name, args=nil)
72
72
  unless path = @route_list_names[name]
73
73
  raise RodaError, "no route exists with the name: #{name.inspect}"
74
74
  end
@@ -112,7 +112,7 @@ class Roda
112
112
  route = {:path=>path}
113
113
 
114
114
  if methods = r['methods']
115
- route[:methods] = methods.map{|x| x.to_sym}
115
+ route[:methods] = methods.map(&:to_sym)
116
116
  end
117
117
 
118
118
  if name = r['name']
@@ -131,11 +131,11 @@ class Roda
131
131
  end
132
132
 
133
133
  module InstanceMethods
134
- # Calls the app's named_route method. If the app's :add_script_name option
134
+ # Calls the app's listed_route method. If the app's :add_script_name option
135
135
  # has been setting, prefixes the resulting path with the script name.
136
- def named_route(name, args=nil)
136
+ def listed_route(name, args=nil)
137
137
  app = self.class
138
- path = app.named_route(name, args)
138
+ path = app.listed_route(name, args)
139
139
  path = request.script_name.to_s + path if app.opts[:add_script_name]
140
140
  path
141
141
  end
@@ -1,16 +1,6 @@
1
1
  require 'roda'
2
2
  require 'json'
3
-
4
- if defined?(RSpec)
5
- require 'rspec/version'
6
- if RSpec::Version::STRING >= '2.11.0'
7
- RSpec.configure do |config|
8
- config.expect_with :rspec do |c|
9
- c.syntax = :should
10
- end
11
- end
12
- end
13
- end
3
+ require 'minitest/autorun'
14
4
 
15
5
  describe 'roda-route_list plugin' do
16
6
  def req(path='/', env={})
@@ -36,7 +26,7 @@ describe 'roda-route_list plugin' do
36
26
  @app = Class.new(Roda)
37
27
  @app.plugin :route_list, :file=>'spec/routes.json'
38
28
  @app.route do |r|
39
- named_route(env['PATH_INFO'].to_sym)
29
+ listed_route(env['PATH_INFO'].to_sym)
40
30
  end
41
31
  @app
42
32
  end
@@ -46,7 +36,7 @@ describe 'roda-route_list plugin' do
46
36
  end
47
37
 
48
38
  it "should correctly parse the routes from the json file" do
49
- @app.route_list.should == [
39
+ @app.route_list.must_equal [
50
40
  {:path=>'/foo'},
51
41
  {:path=>'/foo/bar', :name=>:bar},
52
42
  {:path=>'/foo/baz', :methods=>[:GET]},
@@ -58,51 +48,51 @@ describe 'roda-route_list plugin' do
58
48
  @app = Class.new(Roda)
59
49
  @app.opts[:root] = 'spec'
60
50
  @app.plugin :route_list, :file=>'routes2.json'
61
- @app.route_list.should == [{:path=>'/foo'}]
51
+ @app.route_list.must_equal [{:path=>'/foo'}]
62
52
  end
63
53
 
64
- it ".named_route should return path for route" do
65
- @app.named_route(:bar).should == '/foo/bar'
66
- @app.named_route(:quux).should == '/foo/baz/quux/:quux_id'
54
+ it ".listed_route should return path for route" do
55
+ @app.listed_route(:bar).must_equal '/foo/bar'
56
+ @app.listed_route(:quux).must_equal '/foo/baz/quux/:quux_id'
67
57
  end
68
58
 
69
- it ".named_route should return path for route when given a values hash" do
70
- @app.named_route(:quux, :quux_id=>3).should == '/foo/baz/quux/3'
59
+ it ".listed_route should return path for route when given a values hash" do
60
+ @app.listed_route(:quux, :quux_id=>3).must_equal '/foo/baz/quux/3'
71
61
  end
72
62
 
73
- it ".named_route should return path for route when given a values array" do
74
- @app.named_route(:quux, [3]).should == '/foo/baz/quux/3'
63
+ it ".listed_route should return path for route when given a values array" do
64
+ @app.listed_route(:quux, [3]).must_equal '/foo/baz/quux/3'
75
65
  end
76
66
 
77
- it ".named_route should raise RodaError if there is no matching route" do
78
- proc{@app.named_route(:foo)}.should raise_error(Roda::RodaError)
67
+ it ".listed_route should raise RodaError if there is no matching route" do
68
+ proc{@app.listed_route(:foo)}.must_raise(Roda::RodaError)
79
69
  end
80
70
 
81
- it ".named_route should raise RodaError if there is no matching value when using a values hash" do
82
- proc{@app.named_route(:quux, {})}.should raise_error(Roda::RodaError)
71
+ it ".listed_route should raise RodaError if there is no matching value when using a values hash" do
72
+ proc{@app.listed_route(:quux, {})}.must_raise(Roda::RodaError)
83
73
  end
84
74
 
85
- it ".named_route should raise RodaError if there is no matching value when using a values array" do
86
- proc{@app.named_route(:quux, [])}.should raise_error(Roda::RodaError)
75
+ it ".listed_route should raise RodaError if there is no matching value when using a values array" do
76
+ proc{@app.listed_route(:quux, [])}.must_raise(Roda::RodaError)
87
77
  end
88
78
 
89
- it ".named_route should raise RodaError if there are too many values when using a values array" do
90
- proc{@app.named_route(:quux, [3, 1])}.should raise_error(Roda::RodaError)
79
+ it ".listed_route should raise RodaError if there are too many values when using a values array" do
80
+ proc{@app.listed_route(:quux, [3, 1])}.must_raise(Roda::RodaError)
91
81
  end
92
82
 
93
83
  it "should allow parsing routes from a separate file" do
94
84
  @app.plugin :route_list, :file=>'spec/routes2.json'
95
- @app.route_list.should == [{:path=>'/foo'}]
85
+ @app.route_list.must_equal [{:path=>'/foo'}]
96
86
  end
97
87
 
98
- it "#named_route should work" do
99
- body('bar').should == '/foo/bar'
88
+ it "#listed_route should work" do
89
+ body('bar').must_equal '/foo/bar'
100
90
  end
101
91
 
102
- it "#named_route should respect :add_script_name option" do
92
+ it "#listed_route should respect :add_script_name option" do
103
93
  @app.opts[:add_script_name] = true
104
- body('bar').should == '/foo/bar'
105
- body('bar', 'SCRIPT_NAME'=>'/a').should == '/a/foo/bar'
94
+ body('bar').must_equal '/foo/bar'
95
+ body('bar', 'SCRIPT_NAME'=>'/a').must_equal '/a/foo/bar'
106
96
  end
107
97
  end
108
98
 
@@ -112,8 +102,8 @@ describe 'roda-route_parser executable' do
112
102
  end
113
103
 
114
104
  it "should correctly parse the routes" do
115
- system(ENV['RUBY'], "bin/roda-parse_routes", "-f", "spec/routes-example.json", "spec/routes.example")
116
- File.file?("spec/routes-example.json").should == true
117
- JSON.parse(File.read('spec/routes-example.json')).should == JSON.parse(File.read('spec/routes.json'))
105
+ system(ENV['RUBY'] || 'ruby', "bin/roda-parse_routes", "-f", "spec/routes-example.json", "spec/routes.example")
106
+ File.file?("spec/routes-example.json").must_equal true
107
+ JSON.parse(File.read('spec/routes-example.json')).must_equal JSON.parse(File.read('spec/routes.json'))
118
108
  end
119
109
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-route_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-09 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roda
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.3'
40
+ version: '0'
41
41
  description: |
42
42
  Roda, like other routing tree web frameworks, doesn't have the ability
43
43
  to introspect routes. roda-route_list offers a way to specify a json
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.4.5
92
+ rubygems_version: 2.5.1
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: List routes when using Roda