social-url 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +6 -1
- data/lib/social_url/version.rb +1 -1
- data/lib/social_url.rb +2 -1
- data/test/lib/social_url/pinterest_test.rb +23 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 382bc516fb895000ad278ae48561ff9d814a2118
|
4
|
+
data.tar.gz: 92dde830fec2519dd536d5719f710f30dcd921c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82be3aa78314a4b6d72fd686b410e355c402b9774e17e439049cd2d7534b8e3617fd6255a4637b3d33d7523eba81d8c162a8f4e2ad7eb0cac249e2425163bdcd
|
7
|
+
data.tar.gz: a1499e19fddcaef083ea5dd7599abe42d33acc337ee6ac5e7dc00ca564f44962d1d3b7c07f509e6a39b11a9b72670de179d471aae7294f530e2ddd7e852ce059
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -26,7 +26,7 @@ Run the `bundle install` in your terminal command to install it.
|
|
26
26
|
The gem exposes two classes `SocialUrl` and `SocialUrl::Message`. The `SocialUrl` class provides normalization functionality for URL parameters and exposes the available networks:
|
27
27
|
|
28
28
|
```ruby
|
29
|
-
SocialUrl.networks #=> [:twitter]
|
29
|
+
SocialUrl.networks #=> [:facebook, :google, :twitter, ...]
|
30
30
|
|
31
31
|
SocialUrl.normalize_string('Hello World') #=> 'Hello%20World'
|
32
32
|
SocialUrl.normalize_array(%w(nature sunset)) #=> 'nature,sunset'
|
@@ -46,17 +46,22 @@ message = SocialUrl::Message.new({
|
|
46
46
|
|
47
47
|
message.twitter_url #=> 'https://twitter.com/intent/tweet/?text=Hello%20World&url=http%3A%2F%2Fexample.com&hashtags=nature,sunset'
|
48
48
|
message.facebook_url #=> 'https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fexample.com'
|
49
|
+
...
|
49
50
|
```
|
50
51
|
|
51
52
|
### Available networks
|
52
53
|
|
54
|
+
- Google+
|
53
55
|
- Facebook
|
56
|
+
- Pinterest
|
54
57
|
- Twitter
|
55
58
|
|
56
59
|
## TODO
|
57
60
|
|
58
61
|
This gem is a work-in-progress. Planned features:
|
59
62
|
|
63
|
+
- Raise on missing required network parameters
|
64
|
+
- Merge keys for networks (e.g. url, u)
|
60
65
|
- Ruby on Rails ActionView helpers
|
61
66
|
|
62
67
|
## Contributing
|
data/lib/social_url/version.rb
CHANGED
data/lib/social_url.rb
CHANGED
@@ -3,13 +3,14 @@ require 'social_url/version'
|
|
3
3
|
require 'social_url/message'
|
4
4
|
require 'social_url/facebook'
|
5
5
|
require 'social_url/google'
|
6
|
+
require 'social_url/pinterest'
|
6
7
|
require 'social_url/twitter'
|
7
8
|
|
8
9
|
module SocialUrl
|
9
10
|
include ERB::Util
|
10
11
|
|
11
12
|
class << self
|
12
|
-
NETWORKS = [:twitter]
|
13
|
+
NETWORKS = [:facebook, :google, :pinterest, :twitter]
|
13
14
|
|
14
15
|
def networks
|
15
16
|
NETWORKS
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module SocialUrl
|
4
|
+
class PinterestTest < Minitest::Test
|
5
|
+
def setup
|
6
|
+
@options = {
|
7
|
+
url: 'http://www.flickr.com/photos/kentbrew/6851755809/',
|
8
|
+
media: 'http://farm8.staticflickr.com/7027/6851755809_df5b2051c9_z.jpg',
|
9
|
+
description: 'Next stop: Pinterest'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_url
|
14
|
+
opts = SocialUrl.normalize(@options)
|
15
|
+
url = ['https://www.pinterest.com/pin/create/button/',
|
16
|
+
'?url=http%3A%2F%2Fwww.flickr.com%2Fphotos%2Fkentbrew%2F6851755809%2F',
|
17
|
+
'&media=http%3A%2F%2Ffarm8.staticflickr.com%2F7027%2F6851755809_df5b2051c9_z.jpg',
|
18
|
+
'&description=Next%20stop%3A%20Pinterest'].join
|
19
|
+
|
20
|
+
assert_equal url, Pinterest.new(opts).url
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: social-url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Venneman
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- test/lib/social_url/facebook_test.rb
|
107
107
|
- test/lib/social_url/google_test.rb
|
108
108
|
- test/lib/social_url/message_test.rb
|
109
|
+
- test/lib/social_url/pinterest_test.rb
|
109
110
|
- test/lib/social_url/twitter_test.rb
|
110
111
|
- test/lib/social_url_test.rb
|
111
112
|
- test/test_helper.rb
|
@@ -137,6 +138,7 @@ test_files:
|
|
137
138
|
- test/lib/social_url/facebook_test.rb
|
138
139
|
- test/lib/social_url/google_test.rb
|
139
140
|
- test/lib/social_url/message_test.rb
|
141
|
+
- test/lib/social_url/pinterest_test.rb
|
140
142
|
- test/lib/social_url/twitter_test.rb
|
141
143
|
- test/lib/social_url_test.rb
|
142
144
|
- test/test_helper.rb
|