galago-router 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d57fe2ce224db366f326e84d2f12eba38bbe6120
4
- data.tar.gz: 21925f7fdb67bfbb2766f2e862f588220c7a1eac
3
+ metadata.gz: 7ca65e8d3da9c0e6e460c0b264402285bd9d2dfa
4
+ data.tar.gz: 774adf1034c62b50bd690092cc6e1efc6e9dccaf
5
5
  SHA512:
6
- metadata.gz: 7d27054aac2da1077f7f3adb2cb6e3b631bc95291d8571f31541015b59f8b913702630b38935f74b46fbf8b386aa59e84cd05cca115f79324f255e10d1914266
7
- data.tar.gz: 69186fb89959bd9d8aa96537e0202c2c70924a5a58b3f3cf0b832ef09ff59aef7b13bfd562bc37edba2132575bf3d39861e2cf6ca87297725e59bbc6d97e195b
6
+ metadata.gz: e72781d341817aada32d6f133fecb622e6f58954491acbfdc3d5f7698301b8e8cd189addc592195478c431a9cc4cbffa4fa7539fb009baa8182eed08c25e1eeb
7
+ data.tar.gz: 8db3316782ebb5076861c3701db5ff52bd7ab6b51363d8ba87513cbf702457ec48978cf88f7f4a12badbec04571889ba7c493eef54962c33645d28c2be6a05bf
@@ -36,16 +36,10 @@ module Galago
36
36
  private
37
37
 
38
38
  def add_route(method, path, application)
39
- path_with_namespace = add_namespace_to_path(path)
39
+ path_with_namespace = Path.join(@namespace, path)
40
40
  @router.add_route(method, path_with_namespace, application)
41
41
  end
42
42
 
43
- def add_namespace_to_path(path)
44
- path = "#{@namespace}/#{path}"
45
- path = path.gsub('//', '/')
46
- path = path.gsub(/\/$/, '')
47
- path
48
- end
49
43
  end
50
44
  end
51
45
  end
@@ -2,6 +2,16 @@ module Galago
2
2
  class Router
3
3
  class Path
4
4
 
5
+ REPEATED_SLASH = /\/{1,}/
6
+ TRAILING_SLASH = /\/$/
7
+
8
+ def self.join(*paths)
9
+ path = "/#{paths.join('/')}"
10
+ path = path.gsub(REPEATED_SLASH, '/')
11
+ path = path.gsub(TRAILING_SLASH, '')
12
+ path
13
+ end
14
+
5
15
  def initialize(path)
6
16
  @path = path.to_s
7
17
  end
@@ -1,5 +1,5 @@
1
1
  module Galago
2
2
  class Router
3
- VERSION = '0.1.0'
3
+ VERSION = '0.1.1'
4
4
  end
5
5
  end
@@ -3,6 +3,23 @@ require 'spec_helper'
3
3
  module Galago
4
4
  describe Router::Path do
5
5
 
6
+ describe ".join" do
7
+ it "joins the provided segments with a '/'" do
8
+ path = Router::Path.join('foo', 'bar')
9
+ expect(path).to eql '/foo/bar'
10
+ end
11
+
12
+ it "removes repeated '/'" do
13
+ path = Router::Path.join('//foo', '///bar', '/baz')
14
+ expect(path).to eql '/foo/bar/baz'
15
+ end
16
+
17
+ it "removes trailing '/'" do
18
+ path = Router::Path.join('foo', 'bar/')
19
+ expect(path).to eql '/foo/bar'
20
+ end
21
+ end
22
+
6
23
  describe "#recognizes?" do
7
24
  it "recognizes exact matches" do
8
25
  path = Router::Path.new('/users')
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  module Galago
4
4
  describe 'Router::VERSION' do
5
5
  it "current" do
6
- expect(Router::VERSION).to eql '0.0.2'
6
+ expect(Router::VERSION).to eql '0.1.1'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: galago-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joe Karayusuf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack