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 +4 -4
- data/README.md +15 -0
- data/lib/feeligo/stickers.rb +1 -1
- data/lib/feeligo/stickers/sticker_image_tag.rb +17 -2
- data/lib/feeligo/stickers/version.rb +1 -1
- data/spec/feeligo/stickers_spec.rb +24 -0
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b7d9c4f8eff6abad587193da2ded8db88edb0258
|
|
4
|
+
data.tar.gz: ce4d18974af052088ca3df27871a79c64648eaf6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
data/lib/feeligo/stickers.rb
CHANGED
|
@@ -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
|
-
"
|
|
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
|
|
@@ -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.
|
|
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:
|
|
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.
|
|
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
|