simple_display 0.0.1.alpha → 0.0.1.alpha2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca2b12251ad6518748638eef041b252158550248
4
- data.tar.gz: 4fa6413876069b53ca43c9c264329c24c59c2a56
3
+ metadata.gz: 5a5230ee3c15b91eae5578e9393f2754ec1b626c
4
+ data.tar.gz: c66e2ebaf27e06dcc537e3390e25068f7683e459
5
5
  SHA512:
6
- metadata.gz: 44788351ca7d6ae2b78d17a5ad434bd0bf595841a3f8126ef520cc049d2cbc713402dd9fb91e36a669f1cb156f7deca407f11e3b37b95a67bbac5ca6a8adf0cc
7
- data.tar.gz: 8b044500cf8e51a91c050d91577a936d25aa634db50d33e264e8aee86d8acc7e7de21618ed666b3fd2c4235c4df80adad65de7737c609ec8cb8cfca372907ebc
6
+ metadata.gz: 624fd1904c952a353d873db696ea1c5d0b523bc4dd5c32dfd72d9c85baa07993edf1992ddabdd955eb38763a7f07db954662912c3b2799afc79d58f13053d63f
7
+ data.tar.gz: 50fbb40569eeb46d7a87b75a3c7f5a33b7d6dbbd36857d2d1e3f2f79e9a18d69f94bf5b1f5862520dba1a1c8779e0fab54537916e783a139ee23f011686de6af
data/README.md CHANGED
@@ -9,12 +9,12 @@ attribute and methods, so you can move from this:
9
9
  <dl>
10
10
  <% if @book.title.present? %>
11
11
  <dt>Title</dt>
12
- <dd><%= @example.title %></dd>
12
+ <dd><%= @book.title %></dd>
13
13
  <% end %>
14
14
 
15
- <% if @example.price.present? %>
15
+ <% if @book.price.present? %>
16
16
  <dt>Price</dt>
17
- <dd><%= number_with_currency @example.price %></dd>
17
+ <dd><%= number_with_currency @book.price %></dd>
18
18
  <% end %>
19
19
  </dl>
20
20
  ```
@@ -22,7 +22,7 @@ attribute and methods, so you can move from this:
22
22
  To this:
23
23
 
24
24
  ```erb
25
- <%= display_for @example do |d| %>
25
+ <%= display_for @book do |d| %>
26
26
  <dl>
27
27
  <%= d.display :title %>
28
28
  <%= d.currency :price %>
@@ -31,7 +31,7 @@ To this:
31
31
  ```
32
32
 
33
33
  This gem was inspired by [this
34
- post](http://quickleft.com/blog/drying-your-views-with-dsl-s?utm_source=rubyweekly&utm_medium=email)
34
+ post](http://quickleft.com/blog/drying-your-views-with-dsl-s)
35
35
  by Ben West in the Quick Left blog. Thank you! <3
36
36
 
37
37
  ## Installation
@@ -44,6 +44,10 @@ And then execute:
44
44
 
45
45
  $ bundle
46
46
 
47
+ Or install it with:
48
+
49
+ $ gem install simple_display --pre
50
+
47
51
  ## Usage
48
52
 
49
53
  *TODO: add some content here! Meanwhile, check the introduction of the README
@@ -17,7 +17,7 @@ module SimpleDisplay
17
17
  klass = "simple_display/displayers/#{method}_displayer".camelize
18
18
  if Module.const_get(klass).is_a?(Class)
19
19
  klass = klass.constantize
20
- klass.new(model, helper).display(*args)
20
+ klass.new(model, helper).display(*args, &block)
21
21
  else
22
22
  super
23
23
  end
@@ -11,20 +11,24 @@ module SimpleDisplay
11
11
  def display(field, label = nil, &block)
12
12
  field_value = model.send(field)
13
13
  if field_value.present?
14
- content = value(field_value, &block)
14
+ content = display_value(field_value, &block)
15
15
 
16
- line(disp_label(field, label), content.to_s)
16
+ line(display_label(field, label), content.to_s)
17
17
  end
18
18
  end
19
19
 
20
20
  private
21
21
 
22
+ def display_value(field_value, &block)
23
+ value(field_value, &block)
24
+ end
25
+
22
26
  def value(field_value, &block)
23
27
  return helper.capture(field_value, &block) if block_given?
24
28
  field_value
25
29
  end
26
30
 
27
- def disp_label(field, label)
31
+ def display_label(field, label)
28
32
  label || model.class.human_attribute_name(field)
29
33
  end
30
34
 
@@ -1,11 +1,8 @@
1
1
  module SimpleDisplay
2
2
  module Displayers
3
3
  class CurrencyDisplayer < Base
4
- def display(field, label = nil, &block)
5
- super(field, label) do |f|
6
- currency = helper.number_to_currency value(model.send(field), &block)
7
- helper.content_tag(:strong, currency)
8
- end
4
+ def display_value(field_value, &block)
5
+ helper.number_to_currency value(field_value, &block)
9
6
  end
10
7
  end
11
8
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleDisplay
2
- VERSION = "0.0.1.alpha"
2
+ VERSION = "0.0.1.alpha2"
3
3
  end
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = SimpleDisplay::VERSION
9
9
  spec.authors = ["Marc Riera"]
10
10
  spec.email = ["mrc2407@gmail.com"]
11
- spec.description = %q{Write a gem description}
12
- spec.summary = %q{Write a gem summary}
13
- spec.homepage = ""
11
+ spec.description = %q{Display your Rails models easily}
12
+ spec.summary = %q{Display your Rails models easily}
13
+ spec.homepage = "https://github.com/mrcasals/simple_display"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,51 +1,51 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_display
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha
4
+ version: 0.0.1.alpha2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Riera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-25 00:00:00.000000000 Z
11
+ date: 2014-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- description: Write a gem description
41
+ description: Display your Rails models easily
42
42
  email:
43
43
  - mrc2407@gmail.com
44
44
  executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .gitignore
48
+ - ".gitignore"
49
49
  - Gemfile
50
50
  - LICENSE.txt
51
51
  - README.md
@@ -59,7 +59,7 @@ files:
59
59
  - lib/simple_display/railtie.rb
60
60
  - lib/simple_display/version.rb
61
61
  - simple_display.gemspec
62
- homepage: ''
62
+ homepage: https://github.com/mrcasals/simple_display
63
63
  licenses:
64
64
  - MIT
65
65
  metadata: {}
@@ -69,19 +69,18 @@ require_paths:
69
69
  - lib
70
70
  required_ruby_version: !ruby/object:Gem::Requirement
71
71
  requirements:
72
- - - '>='
72
+ - - ">="
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  requirements:
77
- - - '>'
77
+ - - ">"
78
78
  - !ruby/object:Gem::Version
79
79
  version: 1.3.1
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 2.0.3
82
+ rubygems_version: 2.2.0
83
83
  signing_key:
84
84
  specification_version: 4
85
- summary: Write a gem summary
85
+ summary: Display your Rails models easily
86
86
  test_files: []
87
- has_rdoc: