just_share 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a675643203352c0a085354a6fe5cbf3d2d300b03
4
- data.tar.gz: 54298e3d193bd13e2b3a39f4edb1ff63e5d62050
3
+ metadata.gz: 1ea6c057971aba6f9931e17c943c5975a5df9565
4
+ data.tar.gz: 2b4b04e9c3f9c5c9ce6354c5c9a941e115b39d48
5
5
  SHA512:
6
- metadata.gz: 0a98745b5f48f01e4b165632e215c36760e89e2880aec2a748e9f8cd3c11a2734b3c016a5a380d32909708e71de780a3a83becc9bb439f71a4fbe836e53f5c53
7
- data.tar.gz: eaad38152ce711a3b6f925eeb8056db411f4e3811860b59cb5649888a53122abfee69e0b1f5862a498448632b0b3dee02d2a65bc2ecc7a16073e324a6193a3a1
6
+ metadata.gz: 53b474afdf8d3209e96f48a237a718d66574f2c1ca420b05d9b846cd609424c612542c7398a9d48830a645c7fd6603cf09333d67a74947a32de40bb64c6b6e3d
7
+ data.tar.gz: 17f8577cc2c3621679bb230587bf89731af52f487c66fae3ecefa93b0cacddb748c26cb163385b270a4780324f1e7dffd68c374dfb58fe8b05b130bbd1a3626d
@@ -1,2 +1,16 @@
1
- class JustShare::Delicious
1
+ class JustShare::Delicious < JustShare::SocialLinker
2
+ def setup_attrs
3
+ # Base URL
4
+ self.domain='https://delicious.com'
5
+ self.path='save'
6
+
7
+ # Params (for twitter it is possible set more params on URL, but to more style check it tags documentation)
8
+ url_param = "url=#{self.link}"
9
+ title_param = "title=#{self.title}"
10
+ tags_param = "tags=#{JustShare.array_to_str_params self.hash_tags}"
11
+ text_param = "note=#{self.message}"
12
+
13
+ # build the params
14
+ self.params = "mini=true&#{url_param}&#{title_param}&#{tags_param}&#{text_param}"
15
+ end
2
16
  end
@@ -0,0 +1,16 @@
1
+ class JustShare::LinkedIn < JustShare::SocialLinker
2
+ def setup_attrs
3
+ # Base URL
4
+ self.domain='https://www.linkedin.com'
5
+ self.path='shareArticle'
6
+
7
+ # Params (for twitter it is possible set more params on URL, but to more style check it tags documentation)
8
+ url_param = "url=#{self.link}"
9
+ title_param = "title=#{self.title}"
10
+ text_param = "summary=#{self.message}"
11
+ image_param = "source=#{self.image_url}"
12
+
13
+ # build the params
14
+ self.params = "mini=true&#{url_param}&#{title_param}&#{text_param}&#{image_param}"
15
+ end
16
+ end
@@ -3,6 +3,7 @@ require 'cgi'
3
3
  # ParentClass which have the attrs to create the links
4
4
  class JustShare::SocialLinker
5
5
  # Attrs accessor for it classes
6
+ attr_accessor :title # title on the message
6
7
  attr_accessor :message # Base Message (like from the Ad.social_message)
7
8
  attr_accessor :aux_link # The redirect link on the post
8
9
  attr_accessor :via # The app which post like: PageRenter
@@ -19,6 +20,7 @@ class JustShare::SocialLinker
19
20
  # SetUp the attrs
20
21
  self.via=params[:via] || self.via=JustShare.via
21
22
  self.aux_link=params[:link] || self.aux_link=JustShare.link
23
+ self.title=params[:title] || self.message=JustShare.title
22
24
  self.message=params[:message] || self.message=JustShare.message
23
25
  self.hash_tags=params[:hash_tags] || self.hash_tags=JustShare.hash_tags
24
26
  self.image_url=params[:image_url] || self.hash_tags=JustShare.image_url
@@ -34,7 +36,7 @@ class JustShare::SocialLinker
34
36
 
35
37
  # Overwriting the link getter to return it encoded as HTTP uses
36
38
  def link
37
- CGI::escape(self.aux_link)
39
+ CGI::escape(self.aux_link) unless self.aux_link.nil?
38
40
  end
39
41
 
40
42
  # Method to be implemented on it children!
@@ -1,6 +1,6 @@
1
1
  module JustShare
2
2
  MAJOR = 1
3
3
  MINOR = 0
4
- PATCH = 0
4
+ PATCH = 1
5
5
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
6
6
  end
data/lib/just_share.rb CHANGED
@@ -3,13 +3,19 @@ require 'json'
3
3
  require 'rest_client'
4
4
 
5
5
  # Gem files
6
- [:version, :string, :social_linker, :blogger, :delicious, :facebook, :google_plus, :pinterest, :tumblr, :twitter].each { |lib| require "just_share/#{lib}" }
6
+ files = [
7
+ :version, :string, :social_linker, :blogger,
8
+ :facebook, :google_plus, :linked_in, :pinterest,
9
+ :twitter, :delicious, :tumblr
10
+ ]
11
+ files.each { |lib| require "just_share/#{lib}" }
7
12
 
8
13
  # Module to have "global accessible vars to it gem scope"
9
14
  module JustShare
10
15
  # Attrs to ConfigThe Module & reuse those attrs
11
16
  @via
12
17
  @link
18
+ @title
13
19
  @message
14
20
  @hash_tags
15
21
  @image_url
@@ -44,6 +50,10 @@ module JustShare
44
50
  @link=link
45
51
  end
46
52
 
53
+ def self.title=(title)
54
+ @title=title
55
+ end
56
+
47
57
  def self.message=(message)
48
58
  @message=message
49
59
  end
@@ -58,14 +68,22 @@ module JustShare
58
68
  @via
59
69
  end
60
70
 
61
- def self.link_url
71
+ def self.link
62
72
  @link
63
73
  end
64
-
74
+
75
+ def self.title
76
+ @title
77
+ end
78
+
65
79
  def self.message
66
80
  @message
67
81
  end
68
82
 
83
+ def self.image_url
84
+ @image_url
85
+ end
86
+
69
87
  def self.hash_tags
70
88
  @hash_tags.nil? ? @hash_tags=[] : @hash_tags
71
89
  end
@@ -4,24 +4,26 @@ describe JustShare do
4
4
  describe 'Links write spelled & accessible' do
5
5
  # SetUp for all tests
6
6
  before(:all) do
7
- # TODO REFACTOR THE COUNTER, IT IS BEING RESETED
8
- via = 'PageRenter'
9
- link = 'http://google.com'
10
- message = 'Partiu compartilhar!'
11
- hash_tags = ['partiu','partiu2']
12
- url_image = 'https://avatars3.githubusercontent.com/u/7591935'
7
+ @via = 'PageRenter'
8
+ @link = 'http://goo.gl'
9
+ @title = 'Titulado aqui oh!'
10
+ @message = 'Partiu compartilhar!'
11
+ @hash_tags = ['partiu','partiu2']
12
+ @url_image = 'https://avatars3.githubusercontent.com/u/7591935'
13
13
 
14
14
  # Global useful vars
15
- @base_hash = {via:via, link:link, message:message, hash_tags:hash_tags, image_url:url_image}
15
+ @base_hash = {via:@via, link:@link, title:@title, message:@message, hash_tags:@hash_tags, image_url:@url_image}
16
16
 
17
17
  # Expected URLs generated:
18
- link = CGI::escape(link)
19
- @facebook_expected_url = "https://www.facebook.com/sharer/sharer.php?u=#{link}"
20
- @twitter_expected_url = "https://twitter.com/intent/tweet?text=#{message}&url=#{link}&via=#{via}&hashtags=#{JustShare.array_to_str_params(hash_tags)}"
21
- @google_plus_expected_url = "https://plus.google.com/share?url=#{link}"
22
- @pinterest_expected_url = "http://pinterest.com/pin/create/bookmarklet?url=#{link}&description=#{message}&media=#{url_image}"
23
- @tumblr_expected_url = "https://www.tumblr.com/share?u=#{link}&t=#{message}"
24
- @blogger_expected_url = "https://www.blogger.com/blog_this.pyra?u=#{link}&n=#{message}"
18
+ @link = CGI::escape(@link)
19
+ @facebook_expected_url = "https://www.facebook.com/sharer/sharer.php?u=#{@link}"
20
+ @twitter_expected_url = "https://twitter.com/intent/tweet?text=#{@message}&url=#{@link}&via=#{@via}&hashtags=#{JustShare.array_to_str_params(@hash_tags)}"
21
+ @google_plus_expected_url = "https://plus.google.com/share?url=#{@link}"
22
+ @pinterest_expected_url = "http://pinterest.com/pin/create/bookmarklet?url=#{@link}&description=#{@message}&media=#{@url_image}"
23
+ @tumblr_expected_url = "https://www.tumblr.com/share?u=#{@link}&t=#{@message}"
24
+ @blogger_expected_url = "https://www.blogger.com/blog_this.pyra?u=#{@link}&n=#{@message}"
25
+ @linked_in_expected_url = "https://www.linkedin.com/shareArticle?mini=true&url=#{@link}&title=#{@title}&summary=#{@message}&source=#{@url_image}"
26
+ @delicious_expected_url = "https://delicious.com/save?mini=true&url=#{@link}&title=#{@title}&tags=#{JustShare.array_to_str_params(@hash_tags)}&note=#{@message}"
25
27
  end
26
28
 
27
29
  # SetUp for each tests
@@ -34,9 +36,21 @@ describe JustShare do
34
36
  #@url_generated = JustShare.on(@base_hash)
35
37
  end
36
38
 
37
- it "Facebook link should be okay & accessible" do
39
+ it "Global config" do
40
+ JustShare.via=@via
41
+ JustShare.link=CGI::unescape(@link)
42
+ JustShare.title=@title
43
+ JustShare.message=@message
44
+ JustShare.hash_tags=@hash_tags
45
+
46
+ @url_generated = JustShare.on({social: :facebook})
47
+ expect(@url_generated).to be_equals @facebook_expected_url
48
+ end
49
+
50
+ it "Facebook" do
38
51
  @base_hash[:social] = :facebook
39
52
  @url_generated = JustShare.on(@base_hash)
53
+ puts @url_generated
40
54
  expect(@url_generated).to be_equals @facebook_expected_url
41
55
  #expect(accessible?(@url_generated)).to be_truthy
42
56
  end
@@ -44,6 +58,7 @@ describe JustShare do
44
58
  it "Twitter" do
45
59
  @base_hash[:social] = :twitter
46
60
  @url_generated = JustShare.on(@base_hash)
61
+ puts @url_generated
47
62
  expect(@url_generated).to be_equals @twitter_expected_url
48
63
  #expect(accessible?(@url_generated)).to be_truthy
49
64
  end
@@ -51,13 +66,23 @@ describe JustShare do
51
66
  it "GooglePlus" do
52
67
  @base_hash[:social] = 'google-plus'
53
68
  @url_generated = JustShare.on(@base_hash)
69
+ puts @url_generated
54
70
  expect(@url_generated).to be_equals @google_plus_expected_url
55
71
  #expect(accessible?(@url_generated)).to be_truthy
56
72
  end
57
73
 
74
+ it "LinkedIn" do
75
+ @base_hash[:social] = 'linked-in'
76
+ @url_generated = JustShare.on(@base_hash)
77
+ puts @url_generated
78
+ expect(@url_generated).to be_equals @linked_in_expected_url
79
+ #expect(accessible?(@url_generated)).to be_truthy
80
+ end
81
+
58
82
  it "Pinterest" do
59
83
  @base_hash[:social] = :pinterest
60
84
  @url_generated = JustShare.on(@base_hash)
85
+ puts @url_generated
61
86
  expect(@url_generated).to be_equals @pinterest_expected_url
62
87
  #expect(accessible?(@url_generated)).to be_truthy
63
88
  end
@@ -65,6 +90,7 @@ describe JustShare do
65
90
  it "Tumblr" do
66
91
  @base_hash[:social] = :tumblr
67
92
  @url_generated = JustShare.on(@base_hash)
93
+ puts @url_generated
68
94
  expect(@url_generated).to be_equals @tumblr_expected_url
69
95
  #expect(accessible?(@url_generated)).to be_truthy
70
96
  end
@@ -72,8 +98,17 @@ describe JustShare do
72
98
  it "Blogger" do
73
99
  @base_hash[:social] = :blogger
74
100
  @url_generated = JustShare.on(@base_hash)
101
+ puts @url_generated
75
102
  expect(@url_generated).to be_equals @blogger_expected_url
76
103
  #expect(accessible?(@url_generated)).to be_truthy
77
104
  end
105
+
106
+ it "Delicious" do
107
+ @base_hash[:social] = :delicious
108
+ @url_generated = JustShare.on(@base_hash)
109
+ puts @url_generated
110
+ expect(@url_generated).to be_equals @delicious_expected_url
111
+ #expect(accessible?(@url_generated)).to be_truthy
112
+ end
78
113
  end
79
114
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: just_share
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilton Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-22 00:00:00.000000000 Z
11
+ date: 2014-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -185,6 +185,7 @@ files:
185
185
  - lib/just_share/delicious.rb
186
186
  - lib/just_share/facebook.rb
187
187
  - lib/just_share/google_plus.rb
188
+ - lib/just_share/linked_in.rb
188
189
  - lib/just_share/pinterest.rb
189
190
  - lib/just_share/reddit.rb
190
191
  - lib/just_share/social_linker.rb
@@ -195,13 +196,7 @@ files:
195
196
  - lib/just_share/vk.rb
196
197
  - lib/just_share/xing.rb
197
198
  - spec/helpers.rb
198
- - spec/just_share/delicious_spec.rb
199
- - spec/just_share/facebook_spec.rb
200
- - spec/just_share/google_plus_spec.rb
201
199
  - spec/just_share/just_share_spec.rb
202
- - spec/just_share/pinterest_spec.rb
203
- - spec/just_share/tumblr_spec.rb
204
- - spec/just_share/twitter_spec.rb
205
200
  - spec/spec_helper.rb
206
201
  homepage: http://tonfw.github.io/just_share
207
202
  licenses:
@@ -229,11 +224,5 @@ specification_version: 4
229
224
  summary: Create share links to many social networks
230
225
  test_files:
231
226
  - spec/helpers.rb
232
- - spec/just_share/delicious_spec.rb
233
- - spec/just_share/facebook_spec.rb
234
- - spec/just_share/google_plus_spec.rb
235
227
  - spec/just_share/just_share_spec.rb
236
- - spec/just_share/pinterest_spec.rb
237
- - spec/just_share/tumblr_spec.rb
238
- - spec/just_share/twitter_spec.rb
239
228
  - spec/spec_helper.rb
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe JustShare::Delicious do
4
-
5
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe JustShare::Facebook do
4
-
5
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe JustShare::GooglePlus do
4
-
5
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe JustShare::Pinterest do
4
-
5
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe JustShare::Tumblr do
4
-
5
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe JustShare::Twitter do
4
-
5
- end