api_taster 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/api_taster.rb +2 -3
- data/lib/api_taster/route.rb +6 -6
- data/lib/api_taster/version.rb +1 -1
- data/spec/route_spec.rb +7 -0
- metadata +3 -3
data/README.md
CHANGED
@@ -81,7 +81,7 @@ Instead of manually finding out which route definitions you need, API Taster pro
|
|
81
81
|
|
82
82
|
APIs evolve - especially during the development stage. To keep `ApiTaster.routes` in sync with your route definitions, API Taster provides a warning page that shows you the definitions that are obsolete/mismatched therefore you could correct or remove them.
|
83
83
|
|
84
|
-
![](http://i.imgur.com/
|
84
|
+
![](http://i.imgur.com/qK7g5.png)
|
85
85
|
|
86
86
|
### Use with an Engine
|
87
87
|
|
data/lib/api_taster.rb
CHANGED
@@ -8,11 +8,10 @@ module ApiTaster
|
|
8
8
|
def self.routes(&block)
|
9
9
|
Route.route_set = Rails.application.routes
|
10
10
|
Route.inputs = {}
|
11
|
-
Route.missing_definitions = []
|
12
11
|
Route.obsolete_definitions = []
|
13
12
|
|
14
13
|
Mapper.instance_eval(&block)
|
15
|
-
|
16
|
-
Route.calculate_missing_definitions
|
17
14
|
end
|
15
|
+
|
16
|
+
class Exception < ::Exception; end
|
18
17
|
end
|
data/lib/api_taster/route.rb
CHANGED
@@ -10,6 +10,10 @@ module ApiTaster
|
|
10
10
|
_routes = []
|
11
11
|
i = -1
|
12
12
|
|
13
|
+
unless route_set.respond_to?(:routes)
|
14
|
+
raise ApiTaster::Exception.new('Route definitions are missing, have you defined ApiTaster.routes?')
|
15
|
+
end
|
16
|
+
|
13
17
|
route_set.routes.each do |route|
|
14
18
|
next if route.app.is_a?(Sprockets::Environment)
|
15
19
|
next if route.app == ApiTaster::Engine
|
@@ -51,12 +55,8 @@ module ApiTaster
|
|
51
55
|
inputs[route[:id]].collect { |input| split_input(input, route) }
|
52
56
|
end
|
53
57
|
|
54
|
-
def
|
55
|
-
routes.
|
56
|
-
if undefined_route?(route)
|
57
|
-
self.missing_definitions << route
|
58
|
-
end
|
59
|
-
end
|
58
|
+
def missing_definitions
|
59
|
+
routes.select { |route| undefined_route?(route) }
|
60
60
|
end
|
61
61
|
|
62
62
|
private
|
data/lib/api_taster/version.rb
CHANGED
data/spec/route_spec.rb
CHANGED
@@ -33,6 +33,13 @@ module ApiTaster
|
|
33
33
|
Route.routes.first.should == app_home_route
|
34
34
|
end
|
35
35
|
|
36
|
+
context "undefined ApiTaster.routes" do
|
37
|
+
it "errors out" do
|
38
|
+
Route.route_set = nil
|
39
|
+
expect { Route.routes }.to raise_exception(ApiTaster::Exception)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
36
43
|
it "#grouped_routes" do
|
37
44
|
Route.grouped_routes.has_key?('application').should == true
|
38
45
|
Route.grouped_routes.has_key?('users').should == true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_taster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -354,7 +354,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
354
354
|
version: '0'
|
355
355
|
segments:
|
356
356
|
- 0
|
357
|
-
hash: -
|
357
|
+
hash: -2192023684559152796
|
358
358
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
359
359
|
none: false
|
360
360
|
requirements:
|
@@ -363,7 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
363
363
|
version: '0'
|
364
364
|
segments:
|
365
365
|
- 0
|
366
|
-
hash: -
|
366
|
+
hash: -2192023684559152796
|
367
367
|
requirements: []
|
368
368
|
rubyforge_project:
|
369
369
|
rubygems_version: 1.8.24
|