coffee_routes 1.1.0 → 1.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40262f6745bf348669431b6771ba298cee984d4d
|
4
|
+
data.tar.gz: 2cc66fef2c8668b68c1e24016b998bf6390e3e1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bec9bca43fba06a7f6f470a7d6088911f40c7b35f55cbc985a75b6756e1b97e8c01710e9633e32e1b9d3b108437e1984dece96ce39696f164c7923cb678bde0e
|
7
|
+
data.tar.gz: 6cbe9913dd06c2300d2f4b2d09ad5def7ed5e83c3cec955d9f6b9152f3939dd1436518c541adc0542cb0881f72f47434aa5dd5256b989f529aa61e6025acf184
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# CoffeeRoutes
|
2
2
|
|
3
|
-
Access your Rails named routes from coffeescript.
|
3
|
+
Access your Rails named routes from coffeescript. Read about the making of [here](http://darkphnx.com/2014/10/23/coffeeroutes-named-routes-in-coffeescript/).
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -53,4 +53,4 @@ You can also get the HTTP verb that should be used with the named route.
|
|
53
53
|
```coffee
|
54
54
|
CoffeeRoutes.method('project_item')
|
55
55
|
=> "GET"
|
56
|
-
```
|
56
|
+
```
|
data/lib/coffee_routes.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "coffee_routes/version"
|
2
|
-
require '
|
2
|
+
require 'coffee_routes/json_formatter'
|
3
3
|
|
4
4
|
module CoffeeRoutes
|
5
5
|
module Rails
|
@@ -10,6 +10,6 @@ module CoffeeRoutes
|
|
10
10
|
def self.routes(controller=nil)
|
11
11
|
all_routes = ::Rails.application.routes.routes
|
12
12
|
inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
|
13
|
-
inspector.format(
|
13
|
+
inspector.format(CoffeeRoutes::JSONFormatter.new, controller)
|
14
14
|
end
|
15
15
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# ActionDispatch::Routing::RoutesInspector says people shouldn't use
|
2
|
+
# it, but lets pretend we didn't see it.
|
3
|
+
|
4
|
+
|
5
|
+
module CoffeeRoutes
|
6
|
+
class JSONFormatter
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@buffer = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
# Serialize the buffer has as json
|
13
|
+
def result
|
14
|
+
ActiveSupport::JSON.encode(@buffer)
|
15
|
+
end
|
16
|
+
|
17
|
+
# No need for a title, we only want the data
|
18
|
+
def section_title(title)
|
19
|
+
end
|
20
|
+
|
21
|
+
def section(routes)
|
22
|
+
@buffer.merge! draw_section(routes)
|
23
|
+
end
|
24
|
+
|
25
|
+
# No need for a header, we only want data
|
26
|
+
def header(routes)
|
27
|
+
end
|
28
|
+
|
29
|
+
# No routes will be represented by an empty object
|
30
|
+
def no_routes
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def draw_section(routes)
|
36
|
+
routes.each_with_object({}) do |r, hash|
|
37
|
+
hash[r[:name]] = {:path => r[:path], :verb => r[:verb]}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coffee_routes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Wentworth
|
@@ -64,8 +64,8 @@ files:
|
|
64
64
|
- README.md
|
65
65
|
- Rakefile
|
66
66
|
- coffee_routes.gemspec
|
67
|
-
- lib/action_dispatch/routing/json_formatter.rb
|
68
67
|
- lib/coffee_routes.rb
|
68
|
+
- lib/coffee_routes/json_formatter.rb
|
69
69
|
- lib/coffee_routes/version.rb
|
70
70
|
- vendor/assets/javascripts/coffee_routes.coffee.erb
|
71
71
|
homepage: http://darkphnx.com
|
@@ -1,44 +0,0 @@
|
|
1
|
-
# ActionDispatch::Routing::RoutesInspector says people shouldn't use
|
2
|
-
# it, but lets pretend we didn't see it.
|
3
|
-
|
4
|
-
|
5
|
-
module ActionDispatch
|
6
|
-
module Routing
|
7
|
-
class JSONFormatter
|
8
|
-
|
9
|
-
def initialize
|
10
|
-
@buffer = {}
|
11
|
-
end
|
12
|
-
|
13
|
-
# Serialize the buffer has as json
|
14
|
-
def result
|
15
|
-
ActiveSupport::JSON.encode(@buffer)
|
16
|
-
end
|
17
|
-
|
18
|
-
# No need for a title, we only want the data
|
19
|
-
def section_title(title)
|
20
|
-
end
|
21
|
-
|
22
|
-
def section(routes)
|
23
|
-
@buffer.merge! draw_section(routes)
|
24
|
-
end
|
25
|
-
|
26
|
-
# No need for a header, we only want data
|
27
|
-
def header(routes)
|
28
|
-
end
|
29
|
-
|
30
|
-
# No routes will be represented by an empty object
|
31
|
-
def no_routes
|
32
|
-
end
|
33
|
-
|
34
|
-
private
|
35
|
-
|
36
|
-
def draw_section(routes)
|
37
|
-
routes.each_with_object({}) do |r, hash|
|
38
|
-
hash[r[:name]] = {:path => r[:path], :verb => r[:verb]}
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|