i18n_rails_helpers 0.13.0 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,4 +1,11 @@
1
1
  # coding: utf-8
2
+ require 'rubygems'
3
+ begin
4
+ require 'bundler/setup'
5
+ rescue LoadError
6
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7
+ end
8
+
2
9
  require 'rake'
3
10
  require 'rake/testtask'
4
11
  require 'rake/rdoctask'
@@ -1,12 +1,13 @@
1
1
  module ContextualLinkHelpers
2
2
  # CRUD helpers
3
- def icon_link_to(action, url, options = {})
3
+ def icon_link_to(action, url = nil, options = {})
4
+ url ||= {:action => action}
4
5
  options.merge!(:class => "icon icon-#{action}")
5
6
 
6
- link_to(t_action(action), url, options)
7
+ link_to(t_action(action), url_for(url), options)
7
8
  end
8
9
 
9
- def contextual_link_to(action, resource_or_model = nil)
10
+ def contextual_link_to(action, resource_or_model = nil, options = {})
10
11
  # Handle both symbols and strings
11
12
  action = action.to_s
12
13
 
@@ -22,21 +23,37 @@ module ContextualLinkHelpers
22
23
  model_name = model.to_s.underscore
23
24
 
24
25
  # No link if CanCan is used and current user isn't authorized to call this action
25
- return if respond_to?(:can?) and ! can?(action.to_sym, model)
26
+ return if respond_to?(:can?) and cannot?(action.to_sym, model)
26
27
 
27
- # Link generation
28
+ # Option generation
28
29
  case action
29
- when 'new'
30
- return icon_link_to(action, send("new_#{model_name}_path"))
31
- when 'show'
32
- return icon_link_to(action, send("#{model_name}_path", resource))
33
- when 'edit'
34
- return icon_link_to(action, send("edit_#{model_name}_path", resource))
35
30
  when 'delete'
36
- return icon_link_to(action, send("#{model_name}_path", resource), :confirm => t_confirm_delete(resource), :method => :delete)
31
+ options.merge!(:confirm => t_confirm_delete(resource), :method => :delete)
32
+ end
33
+
34
+ # Path generation
35
+ case action
37
36
  when 'index'
38
- return icon_link_to(action, send("#{model_name.pluralize}_path"))
37
+ if model
38
+ path = polymorphic_path(model)
39
+ else
40
+ path = url_for(:action => nil)
41
+ end
42
+ when 'show', 'delete'
43
+ if resource
44
+ path = polymorphic_path(resource)
45
+ else
46
+ return
47
+ end
48
+ else
49
+ if resource_or_model
50
+ path = polymorphic_path(resource_or_model, :action => action)
51
+ else
52
+ path = url_for(:action => action)
53
+ end
39
54
  end
55
+
56
+ return icon_link_to(action, path, options)
40
57
  end
41
58
 
42
59
  def contextual_links_for(action = nil, resource_or_model = nil)
@@ -29,7 +29,7 @@ module ListLinkHelpers
29
29
  model_name = model.to_s.underscore
30
30
 
31
31
  # No link if CanCan is used and current user isn't authorized to call this action
32
- return if respond_to?(:can?) and ! can?(action.to_sym, model)
32
+ return if respond_to?(:can?) and cannot?(action.to_sym, model)
33
33
 
34
34
  # Link generation
35
35
  case action
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_rails_helpers
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 39
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
- - 13
8
+ - 14
8
9
  - 0
9
- version: 0.13.0
10
+ version: 0.14.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - "Simon H\xC3\xBCrlimann"
@@ -14,33 +15,81 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-04-12 00:00:00 +02:00
18
+ date: 2011-04-16 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: activerecord
22
+ name: i18n_rails_helpers
23
+ version_requirements: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ prerelease: false
33
+ type: :runtime
34
+ requirement: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rails
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 7
43
+ segments:
44
+ - 3
45
+ - 0
46
+ - 0
47
+ version: 3.0.0
22
48
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
49
+ type: :runtime
50
+ requirement: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: jeweler
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ none: false
24
55
  requirements:
25
56
  - - ">="
26
57
  - !ruby/object:Gem::Version
58
+ hash: 3
27
59
  segments:
28
60
  - 0
29
61
  version: "0"
62
+ prerelease: false
63
+ type: :development
64
+ requirement: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: activerecord
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ prerelease: false
30
77
  type: :runtime
31
- version_requirements: *id001
78
+ requirement: *id004
32
79
  - !ruby/object:Gem::Dependency
33
80
  name: i18n
34
- prerelease: false
35
- requirement: &id002 !ruby/object:Gem::Requirement
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ none: false
36
83
  requirements:
37
84
  - - ">="
38
85
  - !ruby/object:Gem::Version
86
+ hash: 3
39
87
  segments:
40
88
  - 0
41
89
  version: "0"
90
+ prerelease: false
42
91
  type: :runtime
43
- version_requirements: *id002
92
+ requirement: *id005
44
93
  description: Rails i18n view helpers for things like crud actions, models and and attributes.
45
94
  email: simon.huerlimann@cyt.ch
46
95
  executables: []
@@ -73,23 +122,27 @@ rdoc_options: []
73
122
  require_paths:
74
123
  - lib
75
124
  required_ruby_version: !ruby/object:Gem::Requirement
125
+ none: false
76
126
  requirements:
77
127
  - - ">="
78
128
  - !ruby/object:Gem::Version
129
+ hash: 3
79
130
  segments:
80
131
  - 0
81
132
  version: "0"
82
133
  required_rubygems_version: !ruby/object:Gem::Requirement
134
+ none: false
83
135
  requirements:
84
136
  - - ">="
85
137
  - !ruby/object:Gem::Version
138
+ hash: 3
86
139
  segments:
87
140
  - 0
88
141
  version: "0"
89
142
  requirements: []
90
143
 
91
144
  rubyforge_project:
92
- rubygems_version: 1.3.6
145
+ rubygems_version: 1.5.2
93
146
  signing_key:
94
147
  specification_version: 3
95
148
  summary: Rails i18n view helpers for things like crud actions, models and and attributes.