simple_images 0.0.2 → 0.0.3
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +11 -0
- data/app/helpers/simple_images_helper.rb +10 -0
- data/lib/simple_images/version.rb +1 -1
- data/spec/helpers/simple_images_helper_spec.rb +30 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cfa36df783f44be53508a1082236a1c7b53ce75
|
4
|
+
data.tar.gz: c214cf8df595001d17e1af31883ebef5481a6395
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81cdf5ce6fcb5c7f1daba780b4edb17e382a1f3c0d5be1b21c8ac2bb67f2e03ab012903b361de30806eced6610a88dbf777117537d45efb339b15f90e1b09606
|
7
|
+
data.tar.gz: 4e397df29f06fd1c9c43765c94ead586de5673d71c928fc0f6b31a8b0c922d7159e8799ad8f03e5fb6ba413565dfb4f208afc81c5e685f09fc0332d7d0f4a31a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -153,6 +153,17 @@ In your views you can call the following methods:
|
|
153
153
|
|
154
154
|
which should be pretty straight forward.
|
155
155
|
|
156
|
+
There is a helper ```si_dom_id``` to help you make a unique id (or class) to
|
157
|
+
push items to upon successful upload. It can be the simple_image, or the imageable:
|
158
|
+
|
159
|
+
```ruby
|
160
|
+
si_dom_id(@simple_image)
|
161
|
+
=> si_article_12
|
162
|
+
|
163
|
+
si_dom_id(@article)
|
164
|
+
=> si_article_12
|
165
|
+
```
|
166
|
+
|
156
167
|
### Creating Images
|
157
168
|
|
158
169
|
Simply click on the 'Add Image' Button and select a file to upload.
|
@@ -17,4 +17,14 @@ module SimpleImagesHelper
|
|
17
17
|
def render_simple_images_form_for(imageable)
|
18
18
|
render 'simple_images/form', imageable: imageable
|
19
19
|
end
|
20
|
+
|
21
|
+
def si_dom_id(image_or_imageable)
|
22
|
+
if image_or_imageable.is_a?(SimpleImage)
|
23
|
+
'si_' + image_or_imageable.imageable.class.to_s.underscore + '_' +
|
24
|
+
image_or_imageable.imageable.id.to_s
|
25
|
+
else
|
26
|
+
'si_' + image_or_imageable.class.to_s.underscore + '_' +
|
27
|
+
image_or_imageable.id.to_s
|
28
|
+
end
|
29
|
+
end
|
20
30
|
end
|
@@ -43,4 +43,34 @@ describe SimpleImagesHelper do
|
|
43
43
|
)
|
44
44
|
end
|
45
45
|
end
|
46
|
+
|
47
|
+
describe "si_dom_id" do
|
48
|
+
context "when imageable" do
|
49
|
+
it "should include imageable class lowercase and underscored" do
|
50
|
+
expect(helper.si_dom_id(@article)).to match(/article/)
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should include imageable id" do
|
54
|
+
expect(helper.si_dom_id(@article)).to match(/#{@article.id}/)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should match expected outcome" do
|
58
|
+
expect(helper.si_dom_id(@article)).to match(/si_article_#{@article.id}/)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "when simple image" do
|
63
|
+
it "should include imageable class lowercase and underscored" do
|
64
|
+
expect(helper.si_dom_id(@simple_image)).to match(/article/)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should include imageable id" do
|
68
|
+
expect(helper.si_dom_id(@simple_image)).to match(/#{@article.id}/)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should match expected outcome" do
|
72
|
+
expect(helper.si_dom_id(@simple_image)).to match(/si_article_#{@article.id}/)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
46
76
|
end
|