app-routes 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.
Files changed (2) hide show
  1. data/lib/app-routes.rb +8 -2
  2. metadata +1 -1
@@ -19,16 +19,20 @@ class AppRoutes
19
19
  result = nil
20
20
 
21
21
  @route.each do |key, block|
22
+ p 'key : ' + key.inspect
22
23
  match = request.match(key)
23
24
 
24
25
  if match then
25
26
 
26
27
  args = match.captures
28
+ p args
27
29
  @params[:captures] = *args
28
30
 
29
31
  if @route[key][:s] then
30
32
  raw_params = @route[key][:s].gsub(':','').match(key).captures
31
- @params.merge!(Hash[raw_params.map(&:to_sym).zip(args)])
33
+ splat, raw_params2 = raw_params.each_with_index.partition {|x,i| x == '/*'}
34
+ @params[:splat] = splat.map {|x,i| v = args[i]; args.delete_at(i); v}
35
+ @params.merge!(Hash[raw_params2.map{|x,i| x.to_sym}.zip(args)])
32
36
  end
33
37
 
34
38
  result = @route[key][:block].call *args
@@ -45,8 +49,10 @@ class AppRoutes
45
49
  send (methodx[arg.class.to_s.to_sym]), arg, &block
46
50
  end
47
51
 
52
+ private
53
+
48
54
  def string_get(raw_s, &block)
49
- s = raw_s.gsub(/\:\w+/,'(\w+)')
55
+ s = raw_s.gsub(/\:\w+/,'(\w+)').gsub(/\/\*/,'(.*)')
50
56
  @route[Regexp.new s] = {s: raw_s, block: block}
51
57
  end
52
58
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app-routes
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