material_raingular 0.0.2.4.999999999 → 0.0.2.5

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: 4b64cdf69541832ba67bf4f1494a7fab16134962
4
- data.tar.gz: 1c4af212c5e30459d72b4f2435614ad501eb99e3
3
+ metadata.gz: 125a7e255ed4e92d524c6e6e0b53bac6d66fffaf
4
+ data.tar.gz: 699bf72e9ee0574492759883f917b6f193b04b97
5
5
  SHA512:
6
- metadata.gz: da89052a9ab9a76b93574456fea937cbefe35a6c6fa3c53f1827af0855de7370fbfce9251a2714504562ba63211e554175a81763e76b23e8f0b26981ad61c2e7
7
- data.tar.gz: c2c05fe63212d9e24600b45e56df707ddcfe45ca29d73dfd7eb9e92c51c10c1b62ad615387d109369c7c23432e703001d247ed3de7c3274ad0d5b63ae01c7c81
6
+ metadata.gz: d446c1e3b4eaff3dd36a496b00811efd454f43e7576592bbfedd0462558f755c4765ea371cd193b1196357989b19a7d89a90923a1f7e16d5998d99064679b0cc
7
+ data.tar.gz: 498591693acdcc0c493598fec41a64d403efd166569fec633833ac8cebd00ed4dfbc2a19fbe0d24065c9eb5aa37948c0e78573530b83b686c63f64017e55b8bc
@@ -1,3 +1,3 @@
1
1
  module MaterialRaingular
2
- VERSION = "0.0.2.4.999999999"
2
+ VERSION = "0.0.2.5"
3
3
  end
@@ -7,19 +7,27 @@ namespace :material_raingular do
7
7
  controllers = HashWithIndifferentAccess.new
8
8
  Rails.application.routes.routes.each do |route|
9
9
  unless route.constraints[:request_method].nil? || route.defaults[:controller].nil? || (route.app.constraints.present? rescue false)
10
- controllers[route.defaults[:controller]] ||= {}
11
- controllers[route.defaults[:controller]][:parent_model_name_and_format_symbol] ||= []
12
- controllers[route.defaults[:controller]][:parent_model_name_and_format_symbol] |= route.parts
10
+ controller = route.defaults[:controller]
11
+ controllers[controller] ||= {}
12
+ controllers[controller][:parent_model_name_and_format_symbol] ||= []
13
+ controllers[controller][:parent_model_name_and_format_symbol] |= route.parts
13
14
  (route.parts - [:id, :format]).each do |parent|
14
15
  action = route.defaults[:action].to_sym
15
16
  method = [:index, :show].include?(action) ? '' : "#{action}_"
16
- method += route.defaults[:controller].send(action == :index ? :pluralize : :singularize).gsub(/[^0-9A-Za-z]/, '_')
17
+ method += controller.send(action == :index ? :pluralize : :singularize).gsub(/[^0-9A-Za-z]/, '_')
17
18
  controllers[parent[0..-4].pluralize] ||= {}
18
19
  controllers[parent[0..-4].pluralize][:parent_model_name_and_format_symbol] ||= []
19
20
  controllers[parent[0..-4].pluralize][:parent_model_name_and_format_symbol] |= route.parts
21
+ controllers[parent[0..-4].pluralize][method] ||= {}
20
22
  controllers[parent[0..-4].pluralize][method] = {url: route.path.spec.to_s.gsub('(.:format)',''), method: route.constraints[:request_method].inspect.delete('/^$')}
21
23
  end
22
- controllers[route.defaults[:controller]][route.defaults[:action].gsub(/[^0-9A-Za-z]/, '_')] = {url: route.path.spec.to_s.gsub('(.:format)',''), method: route.constraints[:request_method].inspect.delete('/^$')}
24
+ action = route.defaults[:action].gsub(/[^0-9A-Za-z]/, '_')
25
+ controllers[controller][action] ||= {}
26
+ current_url = controllers[controller][action][:url]
27
+ proposed_url = route.path.spec.to_s.gsub('(.:format)','')
28
+ if current_url.nil? || (current_url.to_s.length > proposed_url.length)
29
+ controllers[controller][action] = {url: proposed_url, method: route.constraints[:request_method].inspect.delete('/^$')}
30
+ end
23
31
  end
24
32
  end
25
33
  controllers.each do |controller,routes|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: material_raingular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2.4.999999999
4
+ version: 0.0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Moody
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-17 00:00:00.000000000 Z
11
+ date: 2015-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler