feeligo-stickers 0.1.3 → 0.1.4

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: 6ea51f40d7f7228e235da0bbb5e136bb666c25ac
4
- data.tar.gz: 7e8c6f95041409cd0284f3240dccc52f83d636d8
3
+ metadata.gz: b7d9c4f8eff6abad587193da2ded8db88edb0258
4
+ data.tar.gz: ce4d18974af052088ca3df27871a79c64648eaf6
5
5
  SHA512:
6
- metadata.gz: 13eb8d56d1cc4f706fe6074471dce66e5701cf4a6f4b79a20784f0ac5b811d966fec5fb7a68c9e0636cf592b18fe7605d63db3e8eedb362c3a404df4d73b92a2
7
- data.tar.gz: b0fd91bc5dbe07aaeba49f160e016ec4cd21a9f1f8be5d4b96b89a3b3378daad28b7a06538124a4a933cd777b7cd8aaa4ad8d9ce01beb68e80b3ba56a3686629
6
+ metadata.gz: 01d6e567ab87162c23284a9565c6d2aa239ec1f00ff69ab24fd04ab230c8029d157c984b54d21f56a53ed14aa79f2a41d408b630685da4733f9ea0cb5ee8e0a2
7
+ data.tar.gz: fa780e27ab13528872f20871dfebfb3bd4e610eb9a91abd8ea487bac55e398e98a169e0aced9e45cbbe372794a649557b3597504119efc78ac7f0f08a7405c31
data/README.md CHANGED
@@ -37,6 +37,21 @@ Where `user_id` is the id of the authenticated user.
37
37
  The `user_id` should be a non-blank String or a non-zero integer. When no
38
38
  user is authenticated, it should be set to `nil`.
39
39
 
40
+ Use `replace_sticker_tags` to replace a string message that contains sticker tags (`[s:PATH]`) into HTML `<img>` tags
41
+
42
+ ```rb
43
+ Feeligo::Stickers.replace_sticker_tags(string, opts)
44
+ ```
45
+
46
+ > By default images are hosted over `HTTP` at `stkr.es`
47
+ > if available, you can override either the scheme or host domain or both settings using the opts parameter
48
+
49
+ ```rb
50
+ # src: https://flg.stkr.fr/PATH
51
+ opts = {scheme: 'https', host: 'flg.stkr.fr'}
52
+ ```
53
+
54
+
40
55
 
41
56
  ## Contributing
42
57
 
@@ -5,7 +5,7 @@ require "feeligo/stickers/sticker_image_tag"
5
5
 
6
6
  module Feeligo
7
7
  module Stickers
8
-
8
+
9
9
  # Returns a <script> tag which can be added to a View to load the Feeligo
10
10
  # Stickers module.
11
11
  # The <script> tag should be inserted right after the opening <body> tag
@@ -39,18 +39,33 @@ protected
39
39
  attrs = {}
40
40
  @opts.each_pair{|k, v| attrs[k.to_s] = v.to_s}
41
41
  attrs["src"] = image_url
42
- attrs
42
+ attrs.reject{|k,v| %w(host scheme).include? k.to_s}
43
43
  end
44
44
 
45
45
 
46
46
  # The URL of the image
47
47
  def image_url
48
48
  return "" if @path.nil? || @path.empty?
49
- "http://stkr.es/" << if m = /^(p3w|p7s|p)\/(.*)$/.match(@path)
49
+ "#{images_scheme}://#{images_host}/" << if m = /^(pv4|pfk|p7s|p6o|p3w|p7s|p)\/(.*)$/.match(@path)
50
50
  "p/" << m[2]
51
51
  else
52
52
  @path
53
53
  end
54
54
  end
55
55
 
56
+
57
+ def images_scheme
58
+ @opts[:scheme] || "http"
59
+ end
60
+
61
+
62
+ def images_host
63
+ return @opts[:host] if @opts[:host]
64
+ if @opts[:scheme] == "https"
65
+ "ssl.stkr.es"
66
+ else
67
+ "stkr.es"
68
+ end
69
+ end
70
+
56
71
  end
@@ -1,5 +1,5 @@
1
1
  module Feeligo
2
2
  module Stickers
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
@@ -106,6 +106,30 @@ describe Feeligo::Stickers do
106
106
  let(:string){"Hello [s:] world"}
107
107
  it_behaves_like "with no tags"
108
108
  end
109
+ context "when the images scheme is overriden" do
110
+ let(:opts){{scheme: 'https'}}
111
+ let(:string){"Hello [s:PATH] world"}
112
+ it "correctly replaces the tag" do
113
+ expect(Feeligo::Stickers.replace_sticker_tags(string, opts)).to eq(
114
+ 'Hello <img src="https://ssl.stkr.es/PATH"/> world')
115
+ end
116
+ end
117
+ context "when the images host is overriden" do
118
+ let(:opts){{host: 'flg.stkr.fr'}}
119
+ let(:string){"Hello [s:PATH] world"}
120
+ it "correctly replaces the tag" do
121
+ expect(Feeligo::Stickers.replace_sticker_tags(string, opts)).to eq(
122
+ 'Hello <img src="http://flg.stkr.fr/PATH"/> world')
123
+ end
124
+ end
125
+ context "when both the images host and scheme are overriden" do
126
+ let(:opts){{host: 'flg.stkr.fr', scheme: 'https'}}
127
+ let(:string){"Hello [s:PATH] world"}
128
+ it "correctly replaces the tag" do
129
+ expect(Feeligo::Stickers.replace_sticker_tags(string, opts)).to eq(
130
+ 'Hello <img src="https://flg.stkr.fr/PATH"/> world')
131
+ end
132
+ end
109
133
  end
110
134
 
111
135
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feeligo-stickers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Feeligo Tech
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-31 00:00:00.000000000 Z
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.2.2
94
+ rubygems_version: 2.4.8
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Easily add the Feeligo Stickers app to your site