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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa85f29df38bfdee0e94de4fca6da0030a33499f
4
- data.tar.gz: ffcb7f859659f16b620134fad10a395edf31538e
3
+ metadata.gz: 6cfa36df783f44be53508a1082236a1c7b53ce75
4
+ data.tar.gz: c214cf8df595001d17e1af31883ebef5481a6395
5
5
  SHA512:
6
- metadata.gz: 53808f95b0797ed1863f3e7b67e649b392f0ad1c4f8c226635acc4a5c8eb736924f66e2af59191ae46ecef61eaced361bab4b13d00d42d505681bcdcb82fb294
7
- data.tar.gz: ec5afd391712208d0faf16d9874c12abde72cc5ae17fb440a304c0a69fddb2dd29bfc2145b742654b3202f6ca77e7002dcc4e346329f0668d82d20a9fa39ebc9
6
+ metadata.gz: 81cdf5ce6fcb5c7f1daba780b4edb17e382a1f3c0d5be1b21c8ac2bb67f2e03ab012903b361de30806eced6610a88dbf777117537d45efb339b15f90e1b09606
7
+ data.tar.gz: 4e397df29f06fd1c9c43765c94ead586de5673d71c928fc0f6b31a8b0c922d7159e8799ad8f03e5fb6ba413565dfb4f208afc81c5e685f09fc0332d7d0f4a31a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.0.3
2
+
3
+ * Added si_dom_id helper
4
+
1
5
  ## v0.0.2
2
6
 
3
7
  * Added AJAX functionality through jquery.fileupload-rails
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
@@ -1,3 +1,3 @@
1
1
  module SimpleImages
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_images
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kainage