simple_display 0.0.1.alpha2 → 0.0.1.alpha3

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: 5a5230ee3c15b91eae5578e9393f2754ec1b626c
4
- data.tar.gz: c66e2ebaf27e06dcc537e3390e25068f7683e459
3
+ metadata.gz: a585285f6b44df9e6461b0c30ce95bb2d0ab7ca7
4
+ data.tar.gz: a576706e0703d42d1758b983eda22d4e37dae390
5
5
  SHA512:
6
- metadata.gz: 624fd1904c952a353d873db696ea1c5d0b523bc4dd5c32dfd72d9c85baa07993edf1992ddabdd955eb38763a7f07db954662912c3b2799afc79d58f13053d63f
7
- data.tar.gz: 50fbb40569eeb46d7a87b75a3c7f5a33b7d6dbbd36857d2d1e3f2f79e9a18d69f94bf5b1f5862520dba1a1c8779e0fab54537916e783a139ee23f011686de6af
6
+ metadata.gz: d22ad7598d4fed31856c0f2b05f635cac5e3d05bfedb17080f088a967f37c991d97521bb5043e009bee385bed2e3409303f6c893df153069953aec14d35ccb39
7
+ data.tar.gz: 5adcc77003d897002d178f260dd62a32357ad37a5cd2f6121982b71e075249f2920e093f7a90a072f1416f57c19e0d4213b5ac8f12708426c3009c808f4c9027
data/README.md CHANGED
@@ -50,15 +50,38 @@ Or install it with:
50
50
 
51
51
  ## Usage
52
52
 
53
- *TODO: add some content here! Meanwhile, check the introduction of the README
54
- file.*
53
+ Simply install `simple_display` and start using it:
54
+
55
+ ```erb
56
+ <%= display_for @book do |d| %>
57
+ <dl>
58
+ <%= d.display :title %>
59
+ <%= d.currency :price %>
60
+ </dl>
61
+ <% end %>
62
+ ```
63
+
64
+ ### Custom displayers
65
+
66
+ You can use custom displayers. Create an `app/displayers` folder in your Rails
67
+ app and add your displayers there. For instance, if you want to create an
68
+ displayer that parses a text as markdown and outputs it as HTML using the
69
+ `Kramdown` gem, you could do this:
70
+
71
+ ```ruby
72
+ # app/displayers/markdown_displayer.rb
73
+ class MarkdownDisplayer < SimpleDisplay::Displayers:Base
74
+ def display_value(field_value, &block)
75
+ Kramdown::Document.new(field_value).to_html.html_safe
76
+ end
77
+ end
78
+ ```
55
79
 
56
80
  ## TODO
57
81
 
58
82
  * Add tests & docs (sorry!)
59
83
  * Add more displayers
60
84
  * Add more content to this README file
61
- * Let users use custom displayers
62
85
 
63
86
  ## Contributing
64
87
 
@@ -14,9 +14,9 @@ module SimpleDisplay
14
14
  end
15
15
 
16
16
  def method_missing(method, *args, &block)
17
- klass = "simple_display/displayers/#{method}_displayer".camelize
18
- if Module.const_get(klass).is_a?(Class)
19
- klass = klass.constantize
17
+ klass = "#{method}_displayer".camelize
18
+ klass = SimpleDisplay::Displayers.const_get(klass)
19
+ if klass.is_a?(Class)
20
20
  klass.new(model, helper).display(*args, &block)
21
21
  else
22
22
  super
@@ -24,8 +24,8 @@ module SimpleDisplay
24
24
  end
25
25
 
26
26
  def respond_to?(method, *args, &block)
27
- klass = "simple_display/displayers/#{method}_displayer".camelize
28
- Module.const_get(klass).is_a?(Class) || super
27
+ klass = "#{method}_displayer".camelize
28
+ klass = SimpleDisplay::Displayers.const_get(klass).is_a?(Class) || super
29
29
  end
30
30
  end
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleDisplay
2
- VERSION = "0.0.1.alpha2"
2
+ VERSION = "0.0.1.alpha3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_display
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha2
4
+ version: 0.0.1.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Riera