king_views 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
@@ -262,7 +262,6 @@ module KingForm
262
262
  if fieldname.is_a?(Hash) && options.empty? # Short call without fieldname
263
263
  options = fieldname
264
264
  fieldname = nil
265
-
266
265
  # Value and title are needed
267
266
  raise ArgumentError unless options[:title]
268
267
  raise ArgumentError unless options[:value]
@@ -30,7 +30,8 @@ module KingFormat
30
30
  def formatted_value(object, fieldname, value=nil, opts={})
31
31
  # If no value given, call fieldname on object to get the current value
32
32
  value ||= if object.respond_to?(fieldname)
33
- object.send(fieldname) || '' #return the content or if no content an empty string
33
+ #return the content(a pointer it) or an empty string.
34
+ object.send(fieldname) || ''
34
35
  else #field is not available in object
35
36
  nil
36
37
  end
@@ -38,7 +39,6 @@ module KingFormat
38
39
  # Autodetect value type
39
40
  if value.nil?
40
41
  nil
41
-
42
42
  elsif value.is_a?(Symbol) # enum value from acts_as_enum
43
43
  translated_enum_value(object, fieldname, value)
44
44
  elsif value.is_a?(DateTime) || value.is_a?(Time) #|| value.is_a?(Date)
@@ -58,28 +58,32 @@ module KingFormat
58
58
  number_to_currency(value, settings.merge({:locale => I18n.locale}))
59
59
  elsif ( value.is_a?(Date) || (object.class.is_date_field?(fieldname) rescue nil) || opts[:date] ) #field is defined as date field OR date options are passed in
60
60
  return value if value.blank? # blank value can occur when a is_date_field is empty
61
- # get date from opts or company or fallback into i18n
62
- format = opts[:date] || default_date_format
63
- format.blank? ? ::I18n.localize(value) : value.strftime(format)
61
+ # get date from opts or company or fallback into i18n
62
+ format = opts[:date] || default_date_format
63
+ format.blank? ? ::I18n.localize(value) : value.strftime(format)
64
64
  else
65
65
  if opts[:format] == :html
66
66
  # Change HTML tag characters to entities
67
67
  ERB::Util.html_escape(value)
68
68
  else
69
- value
69
+ #Copy->val.dup because obj.send(fieldname) returns pointer, and subsequent calls
70
+ #may then alter the real value f.ex val = formatted_value(yx) + "info text"
71
+ value.blank? ? value : value.dup
70
72
  end
71
73
  end
72
74
  end #formatted
73
75
 
74
76
  # Returns the default date formatting.
75
77
  # The returned string is passed to strftime(format)
78
+ # TODO: NoGo since one cannot expect a company to be present
76
79
  # === Returns
77
80
  # <String>:: strftime compatible string
78
81
  def default_date_format
79
82
  Company.current.date_format rescue nil
80
83
  end
81
84
 
82
- # Returns the default currency formatting.
85
+ # Returns the default currency formatting from Company.current => Thread var
86
+ # TODO: NoGo since one cannot expect a company to be present
83
87
  # The returned hash is used in rails number_to_currency helper
84
88
  # === Returns
85
89
  # <Hash>:: number_to_currency compatible options hash
data/king_views.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{king_views}
8
- s.version = "1.0.2"
8
+ s.version = "1.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Georg Leciejewski"]
12
- s.date = %q{2010-05-02}
12
+ s.date = %q{2010-07-27}
13
13
  s.description = %q{Clean up your Forms using king_form for dl or labeled forms. Use king_list for an easy markup of tables in your lists and dl-enabled listings in your detail views. }
14
14
  s.email = %q{gl@salesking.eu}
15
15
  s.extra_rdoc_files = [
@@ -70,14 +70,14 @@ Gem::Specification.new do |s|
70
70
  s.homepage = %q{http://github.com/salesking/king_views}
71
71
  s.rdoc_options = ["--charset=UTF-8"]
72
72
  s.require_paths = ["lib"]
73
- s.rubygems_version = %q{1.3.6}
73
+ s.rubygems_version = %q{1.3.7}
74
74
  s.summary = %q{Ultraclean haml views with list and forms helpers for rails}
75
75
 
76
76
  if s.respond_to? :specification_version then
77
77
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
78
78
  s.specification_version = 3
79
79
 
80
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
80
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
81
81
  else
82
82
  end
83
83
  else
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: king_views
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease: false
5
6
  segments:
6
7
  - 1
7
8
  - 0
8
- - 2
9
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Georg Leciejewski
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-02 00:00:00 +02:00
18
+ date: 2010-07-27 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -87,23 +88,27 @@ rdoc_options:
87
88
  require_paths:
88
89
  - lib
89
90
  required_ruby_version: !ruby/object:Gem::Requirement
91
+ none: false
90
92
  requirements:
91
93
  - - ">="
92
94
  - !ruby/object:Gem::Version
95
+ hash: 3
93
96
  segments:
94
97
  - 0
95
98
  version: "0"
96
99
  required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
97
101
  requirements:
98
102
  - - ">="
99
103
  - !ruby/object:Gem::Version
104
+ hash: 3
100
105
  segments:
101
106
  - 0
102
107
  version: "0"
103
108
  requirements: []
104
109
 
105
110
  rubyforge_project:
106
- rubygems_version: 1.3.6
111
+ rubygems_version: 1.3.7
107
112
  signing_key:
108
113
  specification_version: 3
109
114
  summary: Ultraclean haml views with list and forms helpers for rails