hashbrowns 0.2.3 → 0.2.4

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
data/hashbrowns.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hashbrowns}
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{crimsonknave}]
@@ -1,6 +1,6 @@
1
1
  module HashBrowns
2
2
  class Configuration
3
- attr_accessor :link_hash, :link_for_id, :links, :link_parents, :key_fields, :parent_overrides, :status_hash, :table_styles, :key_fields, :pretty_names, :important, :ignore_important_case
3
+ attr_accessor :link_hash, :link_for_id, :links, :link_parents, :key_fields, :parent_overrides, :status_hash, :table_styles, :key_fields, :pretty_names, :important, :ignore_important_case, :table_with_header_styles, :header_styles
4
4
 
5
5
  VALID_STATUSES = %w(success info warning error)
6
6
 
@@ -21,6 +21,11 @@ module HashBrowns
21
21
  }
22
22
 
23
23
  @table_styles = Set.new
24
+ @table_with_header_styles = Set.new
25
+ @header_styles = Hash.new
26
+ @header_styles.default_proc = proc do |h,k|
27
+ h[k] = Set.new
28
+ end
24
29
  @key_fields = Hash.new
25
30
  @parent_overrides = Set.new
26
31
 
@@ -31,12 +36,24 @@ module HashBrowns
31
36
  @status_hash[name] = status
32
37
  end
33
38
 
39
+ def add_table_with_header_style(style)
40
+ @table_with_header_styles.add(style)
41
+ end
42
+ def add_table_with_header_styles(*styles)
43
+ @table_with_header_styles.merge(styles)
44
+ end
34
45
  def add_table_style(style)
35
46
  @table_styles.add(style)
36
47
  end
37
48
  def add_table_styles(*styles)
38
49
  @table_styles.merge(styles)
39
50
  end
51
+ def add_header_style(header, style)
52
+ @header_styles[header].add(style)
53
+ end
54
+ def add_header_styles(header, *styles)
55
+ @header_styles[header].merge(styles)
56
+ end
40
57
 
41
58
  def add_parent_overrides(*parents)
42
59
  @parent_overrides.merge(parents)
@@ -61,7 +78,7 @@ module HashBrowns
61
78
  value, status = value.to_s, status.to_s
62
79
  value = value.downcase if @ignore_important_case && value.kind_of?(String)
63
80
  return false unless status
64
- status = @status_hash[status] if @status_hash.has_key?(status)
81
+ #status = @status_hash[status] if @status_hash.has_key?(status)
65
82
 
66
83
  @important[name] = Hash.new unless @important.has_key?(name)
67
84
  @important[name][value] = status
@@ -5,15 +5,29 @@ module HashBrowns
5
5
  return HashBrowns.conf.table_styles.to_a.join(" ")
6
6
  end
7
7
 
8
+ def table_with_header_styles
9
+ return HashBrowns.conf.table_with_header_styles.to_a.join(" ")
10
+ end
11
+
12
+ def header_styles(header)
13
+ return HashBrowns.conf.header_styles[header].to_a.join(" ")
14
+ end
15
+
8
16
  def importantize(key, value)
9
17
  value = value.downcase if HashBrowns.conf.ignore_important_case && value.kind_of?(String)
10
18
  #puts "k: #{key}, v: #{value}"
11
19
  return "nil key" if key.nil?
12
20
  return "nil value" if value.nil?
13
21
  return "#{key} not important" unless HashBrowns.conf.important.has_key?(key)
14
- return "#{HashBrowns.conf.important[key].call(value)}" if HashBrowns.conf.important[key].kind_of?(Proc)
22
+ return "#{convert_status(HashBrowns.conf.important[key].call(value))}" if HashBrowns.conf.important[key].kind_of?(Proc)
15
23
  return "#{value} not important for #{key}" unless HashBrowns.conf.important[key].has_key?(value)
16
- return "#{HashBrowns.conf.important[key][value]}"
24
+ return "#{convert_status(HashBrowns.conf.important[key][value])}"
25
+ end
26
+
27
+ def convert_status(value)
28
+ value = value.to_s
29
+ return HashBrowns.conf.status_hash[value] if HashBrowns.conf.status_hash.has_key?(value)
30
+ return value
17
31
  end
18
32
 
19
33
  def display_name(name, table)
@@ -8,7 +8,7 @@ module HashBrowns
8
8
  text = value if text
9
9
  return link_to(text, HashBrowns.conf.link_parents[parent][key]+value).html_safe if parent && HashBrowns.conf.link_parents.has_key?(parent) && HashBrowns.conf.link_parents[parent].has_key?(key)
10
10
  return link_to(text, HashBrowns.conf.link_hash[key]+value).html_safe if HashBrowns.conf.link_hash.has_key?(key)
11
- return link_to(text, value).html_safe if HashBrowns.conf.links.include?(key)
11
+ return link_to(text, value, :target => "_blank").html_safe if HashBrowns.conf.links.include?(key)
12
12
  return link_to(text, HashBrowns.conf.link_parents[parent]["id"]+id).html_safe if id && parent && HashBrowns.conf.link_for_id.has_key?(key) && HashBrowns.conf.link_for_id[key].include?(parent)
13
13
  return value
14
14
  end
@@ -1,8 +1,11 @@
1
- %table{:class => table_styles}
1
+ %table{:class => "#{table_styles}#{" #{table_with_header_styles}" if object.kind_of?(Array)}"}
2
2
  - if object.kind_of?(Array)
3
- %tr
3
+ %thead
4
4
  - overview_fields(type).each do |k, path|
5
- %th= k.to_s.humanize
5
+ - if header_styles(k)
6
+ %th{:class => header_styles(k)}= k.to_s.humanize
7
+ - else
8
+ %th= k.to_s.humanize
6
9
  - object.each do |o|
7
10
  %tr
8
11
  - overview_fields(type).each do |k, path|
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hashbrowns
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.3
5
+ version: 0.2.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - crimsonknave