cheveret 2.0.0.rc2 → 2.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
data/cheveret.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cheveret}
8
- s.version = "2.0.0.rc2"
8
+ s.version = "2.0.0.rc3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ben Caldwell"]
12
- s.date = %q{2010-10-01}
12
+ s.date = %q{2010-10-05}
13
13
  s.description = %q{Generating HTML tables of data in the views of your Rails
14
14
  application is not very DRY even for the simpler of cases. Cheveret allows you to more
15
15
  clearly separate logic and templating and reduce the amount of code in your views.}
@@ -27,15 +27,16 @@ module Cheveret
27
27
  #
28
28
  # @param [Hash] new_config
29
29
  # a hash of configuration options. gets merged with any existing config
30
- def config(new_config)
31
- if @config then @config.merge!(new_config) else @config = new_config.dup end
30
+ def config(new_config=nil)
31
+ return @config ||= {} if new_config.nil?
32
+ config.merge!(new_config)
32
33
  end
33
34
 
34
35
  [ :render, :header, :body, :rows ].each do |renderer|
35
36
  class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
36
37
  def #{renderer}(*args)
37
- config = @config.merge(args.extract_options!)
38
- super(*args << config)
38
+ options = config(args.extract_options!)
39
+ super(*args << options)
39
40
  end
40
41
  RUBY_EVAL
41
42
  end
@@ -23,7 +23,9 @@
23
23
 
24
24
  module Cheveret
25
25
  module Filtering
26
- def config(new_config)
26
+ def config(new_config=nil)
27
+ return super if new_config.nil?
28
+
27
29
  except, only = new_config.delete(:except), new_config.delete(:only)
28
30
  if (except || only)
29
31
  @columns.reject! { |k, v| !only.include?(k) } if only
@@ -67,7 +67,10 @@ module Cheveret
67
67
  # @option options [Array,String] :class
68
68
  # @option options [Integer] :width
69
69
  def row(object, options={})
70
- content_tag(:div, :class => 'tr') do
70
+ alt = cycle('', 'alt', :name => 'cheveret')
71
+ options[:class] = [ 'tr', alt, options[:class]].flatten.join(' ').strip
72
+
73
+ content_tag(:div, options) do
71
74
  @columns.values.map do |column|
72
75
  cell(:td, column) { send(:"data_for_#{column.name}", object) rescue nil }
73
76
  end
@@ -40,7 +40,9 @@ module Cheveret
40
40
  resize!
41
41
  end
42
42
 
43
- def config(new_config={})
43
+ def config(new_config=nil)
44
+ return super if new_config.nil?
45
+
44
46
  self.width = new_config.delete(:width) || self.width
45
47
  super
46
48
  end
@@ -26,7 +26,7 @@ module Cheveret
26
26
  MAJOR = 2
27
27
  MINOR = 0
28
28
  PATCH = 0
29
- BUILD = 'rc2'
29
+ BUILD = 'rc3'
30
30
 
31
31
  STRING = [ MAJOR, MINOR, PATCH, BUILD ].join('.')
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheveret
3
3
  version: !ruby/object:Gem::Version
4
- hash: 977940591
4
+ hash: 977940588
5
5
  prerelease: true
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
9
  - 0
10
- - rc2
11
- version: 2.0.0.rc2
10
+ - rc3
11
+ version: 2.0.0.rc3
12
12
  platform: ruby
13
13
  authors:
14
14
  - Ben Caldwell
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-01 00:00:00 +10:00
19
+ date: 2010-10-05 00:00:00 +11:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency