combo_box 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION +1 -1
  2. data/lib/combo_box/generator.rb +14 -8
  3. metadata +9 -9
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
@@ -12,6 +12,7 @@ module ComboBox
12
12
  @model = model
13
13
  @name = name.to_s
14
14
  @filter = options.delete(:filter) || "%X%"
15
+ @code = options.delete(:code)
15
16
  @interpolation_key = options.delete(:interpolation_key) || @name.gsub(/\W/, '_')
16
17
  klass = @model
17
18
  @through = (options.delete(:through) || []).collect do |reflection|
@@ -29,16 +30,20 @@ module ComboBox
29
30
  end
30
31
 
31
32
  def value_code(record='record')
32
- code = ""
33
- value = "#{record}#{'.'+@through.join('.') unless @through.empty?}.#{name}"
33
+ code = "("
34
+ value = "(#{record}#{'.'+@through.join('.') unless @through.empty?}.#{name})"
34
35
  @through.each_index do |i|
35
36
  code << "#{record}.#{@through[0..i].join('.')}.nil? ? '' : "
36
37
  end
37
- if [:date, :datetime, :timestamp].include? self.type
38
- code = "(#{code}#{value}.nil? ? '' : ::I18n.localize(#{value}))"
39
- else
40
- code = "(#{code}#{value}).to_s"
41
- end
38
+ code << if @code
39
+ @code.gsub(/RECORD/, record).gsub(/DATUM/, value)
40
+ elsif[:date, :datetime, :timestamp].include? self.type
41
+ "(#{value}.nil? ? '' : ::I18n.localize(#{value}))"
42
+ else
43
+ value
44
+ end
45
+ code << ")"
46
+ code << ".to_s" unless name.to_s == "count"
42
47
  return code
43
48
  end
44
49
 
@@ -187,13 +192,14 @@ module ComboBox
187
192
  code << " return ''\n"
188
193
  code << " end\n"
189
194
  code << "end\n"
195
+ # puts code
190
196
  return code
191
197
  end
192
198
 
193
199
  private
194
200
 
195
201
  def item_label(record, options={})
196
- return "::I18n.translate('views.combo_boxes.#{@controller.controller_name}.#{@action_name}', "+@columns.collect{|c| ":#{c.interpolation_key}=>#{c.value_code(record)}"}.join(', ')+", :default=>'"+@columns.collect{|c| "%{#{c.interpolation_key}}"}.join(', ')+"')"
202
+ return "::I18n.translate('views.combo_boxes.#{@controller.controller_name}.#{@action_name}', "+@columns.collect{|c| ":#{c.interpolation_key}=>#{c.value_code(record)}"}.join(', ')+", :default=>[:'labels.#{@action_name}', '"+@columns.collect{|c| "%{#{c.interpolation_key}}"}.join(', ')+"']).gsub(/%s/, \"\\u{00A0}\")"
197
203
  end
198
204
 
199
205
  def sanitize_conditions(value)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: combo_box
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-24 00:00:00.000000000Z
12
+ date: 2012-03-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &16108240 !ruby/object:Gem::Requirement
16
+ requirement: &23382560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *16108240
24
+ version_requirements: *23382560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &16107280 !ruby/object:Gem::Requirement
27
+ requirement: &23381940 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *16107280
35
+ version_requirements: *23381940
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &16106440 !ruby/object:Gem::Requirement
38
+ requirement: &23381300 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 1.6.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *16106440
46
+ version_requirements: *23381300
47
47
  description: Adds helpers for Rails views and controller in order to manage 'dynamic
48
48
  select'. It uses jQuery UI as support for inobtrusive use in forms. It's not the
49
49
  classic Autocompleter, its use is limited to belongs_to reflections.
@@ -82,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  version: '0'
83
83
  segments:
84
84
  - 0
85
- hash: -3255549222173850358
85
+ hash: 2856060928740621467
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  none: false
88
88
  requirements: