admino 0.0.7 → 0.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb9eedd24736483e6944b06a6b6b0952aeb20408
4
- data.tar.gz: a0f73747f2038acbc6faffbafc02ea4845339826
3
+ metadata.gz: 8452d6a30488e570a6db66b94321de492c261337
4
+ data.tar.gz: d45d064082c74e72675f15c85b0a1c2fbf1c2771
5
5
  SHA512:
6
- metadata.gz: 0214c1c5f397f0d75874b0e83a93f75bdb3e0afb6d292ca398b4d98457af4dc6c25c09f41edb99a33e42d2d4ba9ab3ff546fe3733f1fa001515aa4ba77bdda19
7
- data.tar.gz: bb590aa9fa115d5dbd0f91f027b4430df595a31d3675f4649232d16ec0b8e32484c4683a45ce966a818913d80d3e84d5495a059431133d46cbd7d480d4174d09
6
+ metadata.gz: 264b1621f826d1b0dd33020edb46e16b1228d5c788b2029315b524fd9f33e1e972e330968410e6518f0e6e89a1c0221e8faa55acef880b0b857338941e9c2f2f
7
+ data.tar.gz: 22ed8914aa029593876190c46ac5991155026e5bdbd4ef393ed2ec828db2e6e37d10365981347042e1704780959194aef68c291aa719d344bcae2399ae38394a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # v0.0.8
2
+
3
+ * Support a symbol column label. It will use human attribute name:
4
+
5
+ ```
6
+ = row.column :truncated_title, :title
7
+ ```
8
+
1
9
  # v0.0.7
2
10
 
3
11
  * `#scope_params` does not change request params
@@ -32,7 +32,11 @@ module Admino
32
32
  def column(*args, &block)
33
33
  attribute_name, label, html_options = parse_column_args(args)
34
34
 
35
- label ||= column_label(attribute_name)
35
+ if label.nil?
36
+ label = column_label(attribute_name)
37
+ elsif label.is_a? Symbol
38
+ label = column_label(label)
39
+ end
36
40
 
37
41
  html_options = complete_column_html_options(
38
42
  attribute_name,
@@ -18,7 +18,7 @@ module Admino
18
18
  nil
19
19
  end
20
20
 
21
- label = if args.first.is_a?(String)
21
+ label = if args.first.is_a?(String) || args.first.is_a?(Symbol)
22
22
  args.shift
23
23
  else
24
24
  nil
@@ -1,4 +1,4 @@
1
1
  module Admino
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
4
4
 
@@ -17,7 +17,7 @@ module Admino
17
17
  subject { row.to_html }
18
18
 
19
19
  context 'text' do
20
- context 'with label' do
20
+ context 'with string label' do
21
21
  before do
22
22
  row.column(:title, 'This is a title')
23
23
  end
@@ -27,26 +27,43 @@ module Admino
27
27
  end
28
28
  end
29
29
 
30
+ context 'with symbol label and I18n set up' do
31
+ before do
32
+ I18n.backend.store_translations(
33
+ :en,
34
+ activemodel: { attributes: { post: { foo: 'This is foo' } } }
35
+ )
36
+ end
37
+
38
+ before do
39
+ row.column(:title, :foo)
40
+ end
41
+
42
+ it 'generates a label with the human attribute name' do
43
+ should have_tag(:th, text: 'This is foo')
44
+ end
45
+ end
46
+
30
47
  context 'with no label' do
31
48
  before { row.column(:title) }
32
49
 
33
50
  it 'generates a label with the titleized attribute name' do
34
51
  should have_tag(:th, text: 'Title')
35
52
  end
36
- end
37
53
 
38
- context 'with I18n set up' do
39
- before do
40
- I18n.backend.store_translations(
41
- :en,
42
- activemodel: { attributes: { post: { title: 'Post title' } } }
43
- )
44
- end
54
+ context 'with I18n set up' do
55
+ before do
56
+ I18n.backend.store_translations(
57
+ :en,
58
+ activemodel: { attributes: { post: { title: 'Post title' } } }
59
+ )
60
+ end
45
61
 
46
- before { row.column(:title) }
62
+ before { row.column(:title) }
47
63
 
48
- it 'generates a label with the human attribute name' do
49
- should have_tag(:th, text: 'Post title')
64
+ it 'generates a label with the human attribute name' do
65
+ should have_tag(:th, text: 'Post title')
66
+ end
50
67
  end
51
68
  end
52
69
  end
@@ -29,11 +29,16 @@ module Admino
29
29
  it { should eq [nil, 'Title', {}] }
30
30
  end
31
31
 
32
- context 'with a string and a symbol param' do
32
+ context 'with a symbol and string param' do
33
33
  let(:arguments) { [:title, 'Title'] }
34
34
  it { should eq [:title, 'Title', {}] }
35
35
  end
36
36
 
37
+ context 'with two symbol params' do
38
+ let(:arguments) { [:title, :foo] }
39
+ it { should eq [:title, :foo, {}] }
40
+ end
41
+
37
42
  context 'with options' do
38
43
  let(:arguments) { [{ foo: 'bar' }] }
39
44
  it { should eq [nil, nil, { foo: 'bar' }] }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admino
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-23 00:00:00.000000000 Z
11
+ date: 2014-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: showcase