just_share 1.0.0
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 +7 -0
- data/.gitignore +35 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +52 -0
- data/LICENSE +23 -0
- data/README.md +4 -0
- data/Rakefile +2 -0
- data/just_share.gemspec +40 -0
- data/lib/just_share/blogger.rb +14 -0
- data/lib/just_share/chiq.rb +0 -0
- data/lib/just_share/delicious.rb +2 -0
- data/lib/just_share/facebook.rb +13 -0
- data/lib/just_share/google_plus.rb +13 -0
- data/lib/just_share/pinterest.rb +15 -0
- data/lib/just_share/reddit.rb +0 -0
- data/lib/just_share/social_linker.rb +43 -0
- data/lib/just_share/string.rb +59 -0
- data/lib/just_share/tumblr.rb +14 -0
- data/lib/just_share/twitter.rb +16 -0
- data/lib/just_share/version.rb +6 -0
- data/lib/just_share/vk.rb +0 -0
- data/lib/just_share/xing.rb +0 -0
- data/lib/just_share.rb +72 -0
- data/spec/helpers.rb +20 -0
- data/spec/just_share/delicious_spec.rb +5 -0
- data/spec/just_share/facebook_spec.rb +5 -0
- data/spec/just_share/google_plus_spec.rb +5 -0
- data/spec/just_share/just_share_spec.rb +79 -0
- data/spec/just_share/pinterest_spec.rb +5 -0
- data/spec/just_share/tumblr_spec.rb +5 -0
- data/spec/just_share/twitter_spec.rb +5 -0
- data/spec/spec_helper.rb +19 -0
- metadata +239 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a675643203352c0a085354a6fe5cbf3d2d300b03
|
4
|
+
data.tar.gz: 54298e3d193bd13e2b3a39f4edb1ff63e5d62050
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0a98745b5f48f01e4b165632e215c36760e89e2880aec2a748e9f8cd3c11a2734b3c016a5a380d32909708e71de780a3a83becc9bb439f71a4fbe836e53f5c53
|
7
|
+
data.tar.gz: eaad38152ce711a3b6f925eeb8056db411f4e3811860b59cb5649888a53122abfee69e0b1f5862a498448632b0b3dee02d2a65bc2ecc7a16073e324a6193a3a1
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
.idea/
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalisation:
|
25
|
+
/.bundle/
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
just_share (1.0.0)
|
5
|
+
colorize (~> 0.7.3, >= 0.7.3)
|
6
|
+
multi_json (~> 1.10, >= 1.10.1)
|
7
|
+
rest-client (~> 1.7, >= 1.7.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
colorize (0.7.5)
|
13
|
+
diff-lcs (1.2.5)
|
14
|
+
docile (1.1.5)
|
15
|
+
faker (1.4.3)
|
16
|
+
i18n (~> 0.5)
|
17
|
+
i18n (0.6.11)
|
18
|
+
mime-types (2.4.3)
|
19
|
+
multi_json (1.10.1)
|
20
|
+
netrc (0.10.2)
|
21
|
+
rake (10.4.2)
|
22
|
+
rest-client (1.7.2)
|
23
|
+
mime-types (>= 1.16, < 3.0)
|
24
|
+
netrc (~> 0.7)
|
25
|
+
rspec (3.1.0)
|
26
|
+
rspec-core (~> 3.1.0)
|
27
|
+
rspec-expectations (~> 3.1.0)
|
28
|
+
rspec-mocks (~> 3.1.0)
|
29
|
+
rspec-core (3.1.7)
|
30
|
+
rspec-support (~> 3.1.0)
|
31
|
+
rspec-expectations (3.1.2)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.1.0)
|
34
|
+
rspec-mocks (3.1.3)
|
35
|
+
rspec-support (~> 3.1.0)
|
36
|
+
rspec-support (3.1.2)
|
37
|
+
simplecov (0.9.1)
|
38
|
+
docile (~> 1.1.0)
|
39
|
+
multi_json (~> 1.0)
|
40
|
+
simplecov-html (~> 0.8.0)
|
41
|
+
simplecov-html (0.8.0)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
bundler (~> 1.6)
|
48
|
+
faker (~> 1.4, >= 1.4.2)
|
49
|
+
just_share!
|
50
|
+
rake (~> 10.3, >= 10.3.2)
|
51
|
+
rspec (~> 3.1, >= 3.1.0)
|
52
|
+
simplecov (~> 0.7, >= 0.7.1)
|
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Ton Frameworks
|
4
|
+
Copyright (c) 2014 Ilton Garcia
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
14
|
+
copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
22
|
+
SOFTWARE.
|
23
|
+
|
data/README.md
ADDED
data/Rakefile
ADDED
data/just_share.gemspec
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'just_share/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "just_share"
|
8
|
+
spec.version = JustShare::VERSION
|
9
|
+
spec.authors = ["Ilton Garcia"]
|
10
|
+
spec.email = ["ilton_unb@hotmail.com"]
|
11
|
+
spec.summary = 'Create share links to many social networks'
|
12
|
+
spec.description = 'It is useful to create the share buttons on sites, blog & apps to increase your range'
|
13
|
+
spec.homepage = "http://tonfw.github.io/just_share"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
#================== GEMs to build it GEM, so its improve the development ==============================
|
22
|
+
# Base GEMs to build it gem
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.3", '>= 10.3.2'
|
25
|
+
|
26
|
+
# RSpec for tests
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.1", '>= 3.1.0'
|
28
|
+
# Coverage
|
29
|
+
spec.add_development_dependency 'simplecov', '~> 0.7', '>= 0.7.1'
|
30
|
+
# Create readable attrs values
|
31
|
+
spec.add_development_dependency 'faker', '~> 1.4', '>= 1.4.2'
|
32
|
+
|
33
|
+
#================== GEMs to be used when it is called on a project ====================================
|
34
|
+
# HTTP REST Client to test if the URL is accessible
|
35
|
+
spec.add_dependency "rest-client", '~> 1.7', '>= 1.7.2'
|
36
|
+
# Easy JSON create
|
37
|
+
spec.add_dependency "multi_json", '~> 1.10', '>= 1.10.1'
|
38
|
+
# To pretty print on console
|
39
|
+
spec.add_dependency "colorize", '~> 0.7.3', '>= 0.7.3'
|
40
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class JustShare::Blogger < JustShare::SocialLinker
|
2
|
+
def setup_attrs
|
3
|
+
# Base URL
|
4
|
+
self.domain='https://www.blogger.com'
|
5
|
+
self.path='blog_this.pyra'
|
6
|
+
|
7
|
+
# Params (only the link is working, the others are deprecated for the sharer.php & won't work)
|
8
|
+
url_param = "u=#{self.link}"
|
9
|
+
description_param = "n=#{self.message}"
|
10
|
+
|
11
|
+
# build the params
|
12
|
+
self.params = "#{url_param}&#{description_param}"
|
13
|
+
end
|
14
|
+
end
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class JustShare::Facebook < JustShare::SocialLinker
|
2
|
+
def setup_attrs
|
3
|
+
# Base URL
|
4
|
+
self.domain='https://www.facebook.com'
|
5
|
+
self.path='sharer/sharer.php'
|
6
|
+
|
7
|
+
# Params (only the link is working, the others are deprecated for the sharer.php & won't work)
|
8
|
+
url_param = "u=#{self.link}"
|
9
|
+
|
10
|
+
# build the params
|
11
|
+
self.params = "#{url_param}"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class JustShare::GooglePlus < JustShare::SocialLinker
|
2
|
+
def setup_attrs
|
3
|
+
# Base URL
|
4
|
+
self.domain='https://plus.google.com'
|
5
|
+
self.path='share'
|
6
|
+
|
7
|
+
# Params (only the link is working, the others are deprecated for the sharer.php & won't work)
|
8
|
+
url_param = "url=#{self.link}"
|
9
|
+
|
10
|
+
# build the params
|
11
|
+
self.params = "#{url_param}"
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class JustShare::Pinterest < JustShare::SocialLinker
|
2
|
+
def setup_attrs
|
3
|
+
# Base URL
|
4
|
+
self.domain='http://pinterest.com'
|
5
|
+
self.path='pin/create/bookmarklet'
|
6
|
+
|
7
|
+
# Params (only the link is working, the others are deprecated for the sharer.php & won't work)
|
8
|
+
url_param = "url=#{self.link}"
|
9
|
+
description_param = "description=#{self.message}"
|
10
|
+
image_param = "media=#{self.image_url}"
|
11
|
+
|
12
|
+
# build the params
|
13
|
+
self.params = "#{url_param}&#{description_param}&#{image_param}"
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
# ParentClass which have the attrs to create the links
|
4
|
+
class JustShare::SocialLinker
|
5
|
+
# Attrs accessor for it classes
|
6
|
+
attr_accessor :message # Base Message (like from the Ad.social_message)
|
7
|
+
attr_accessor :aux_link # The redirect link on the post
|
8
|
+
attr_accessor :via # The app which post like: PageRenter
|
9
|
+
attr_accessor :hash_tags # Array of HashTags, like nature, sunset, HereWeGo...
|
10
|
+
attr_accessor :image_url # URL to the image
|
11
|
+
|
12
|
+
# Attrs filled on children
|
13
|
+
attr_accessor :domain # ex: facebook.com twitter.com ...
|
14
|
+
attr_accessor :path # ex: facebook.com twitter.com ...
|
15
|
+
attr_accessor :params # ex: facebook.com twitter.com ...
|
16
|
+
|
17
|
+
# It constructor must be reused by it children
|
18
|
+
def initialize(params={})
|
19
|
+
# SetUp the attrs
|
20
|
+
self.via=params[:via] || self.via=JustShare.via
|
21
|
+
self.aux_link=params[:link] || self.aux_link=JustShare.link
|
22
|
+
self.message=params[:message] || self.message=JustShare.message
|
23
|
+
self.hash_tags=params[:hash_tags] || self.hash_tags=JustShare.hash_tags
|
24
|
+
self.image_url=params[:image_url] || self.hash_tags=JustShare.image_url
|
25
|
+
end
|
26
|
+
|
27
|
+
# FacadeMethod
|
28
|
+
def get_post_link
|
29
|
+
# SetUp attrs
|
30
|
+
setup_attrs
|
31
|
+
# Create & return it URL created
|
32
|
+
"#{self.domain}/#{self.path}?#{params}"
|
33
|
+
end
|
34
|
+
|
35
|
+
# Overwriting the link getter to return it encoded as HTTP uses
|
36
|
+
def link
|
37
|
+
CGI::escape(self.aux_link)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Method to be implemented on it children!
|
41
|
+
def setup_attrs
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class String
|
2
|
+
# Humanize the String format rails humanized (but renamed to not have conflicts & REFACTORED)
|
3
|
+
def capitalize_humanized
|
4
|
+
# Replace underscore to whitespace
|
5
|
+
self.gsub!('_', ' ')
|
6
|
+
|
7
|
+
# Split on where are the hyphens
|
8
|
+
self_in_array = self.split(/-/)
|
9
|
+
|
10
|
+
# Recreate Capitalizing
|
11
|
+
it_new_format = ''
|
12
|
+
self_in_array.each do |sub_str|
|
13
|
+
it_new_format = it_new_format+sub_str.capitalize
|
14
|
+
end
|
15
|
+
|
16
|
+
# Return it new format
|
17
|
+
it_new_format
|
18
|
+
end
|
19
|
+
|
20
|
+
# Helpful for the RSpec test
|
21
|
+
def equals? str
|
22
|
+
self == str
|
23
|
+
end
|
24
|
+
|
25
|
+
# Rails Constantize (but renamed to not have conflicts)
|
26
|
+
def to_constant
|
27
|
+
camel_cased_word = self
|
28
|
+
names = camel_cased_word.split('::')
|
29
|
+
|
30
|
+
# Trigger a builtin NameError exception including the ill-formed constant in the message.
|
31
|
+
Object.const_get(camel_cased_word) if names.empty?
|
32
|
+
|
33
|
+
# Remove the first blank element in case of '::ClassName' notation.
|
34
|
+
names.shift if names.size > 1 && names.first.empty?
|
35
|
+
|
36
|
+
names.inject(Object) do |constant, name|
|
37
|
+
if constant == Object
|
38
|
+
constant.const_get(name)
|
39
|
+
else
|
40
|
+
candidate = constant.const_get(name)
|
41
|
+
next candidate if constant.const_defined?(name, false)
|
42
|
+
=begin TODO UNCOMMENT IF ANYTHING CRASH
|
43
|
+
next candidate unless Object.const_defined?(name)
|
44
|
+
|
45
|
+
# Go down the ancestors to check it it's owned
|
46
|
+
# directly before we reach Object or the end of ancestors.
|
47
|
+
constant = constant.ancestors.inject do |const, ancestor|
|
48
|
+
break const if ancestor == Object
|
49
|
+
break ancestor if ancestor.const_defined?(name, false)
|
50
|
+
const
|
51
|
+
end
|
52
|
+
|
53
|
+
# owner is in Object, so raise
|
54
|
+
constant.const_get(name, false)
|
55
|
+
=end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class JustShare::Tumblr < JustShare::SocialLinker
|
2
|
+
def setup_attrs
|
3
|
+
# Base URL
|
4
|
+
self.domain='https://www.tumblr.com'
|
5
|
+
self.path='share'
|
6
|
+
|
7
|
+
# Params (only the link is working, the others are deprecated for the sharer.php & won't work)
|
8
|
+
url_param = "u=#{self.link}"
|
9
|
+
description_param = "t=#{self.message}"
|
10
|
+
|
11
|
+
# build the params
|
12
|
+
self.params = "#{url_param}&#{description_param}"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class JustShare::Twitter < JustShare::SocialLinker
|
2
|
+
def setup_attrs
|
3
|
+
# Base URL
|
4
|
+
self.domain='https://twitter.com'
|
5
|
+
self.path='intent/tweet'
|
6
|
+
|
7
|
+
# Params (for twitter it is possible set more params on URL, but to more style check it tags documentation)
|
8
|
+
via_param = "via=#{self.via}" # IMPORTANT: be the App? Like PageRenter?
|
9
|
+
url_param = "url=#{self.link}"
|
10
|
+
text_param = "text=#{self.message}"
|
11
|
+
hash_tag_param = "hashtags=#{JustShare.array_to_str_params self.hash_tags}"
|
12
|
+
|
13
|
+
# build the params
|
14
|
+
self.params = "#{text_param}&#{url_param}&#{via_param}&#{hash_tag_param}"
|
15
|
+
end
|
16
|
+
end
|
File without changes
|
File without changes
|
data/lib/just_share.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Libs/Gems or Ruby classes for it GEM
|
2
|
+
require 'json'
|
3
|
+
require 'rest_client'
|
4
|
+
|
5
|
+
# Gem files
|
6
|
+
[:version, :string, :social_linker, :blogger, :delicious, :facebook, :google_plus, :pinterest, :tumblr, :twitter].each { |lib| require "just_share/#{lib}" }
|
7
|
+
|
8
|
+
# Module to have "global accessible vars to it gem scope"
|
9
|
+
module JustShare
|
10
|
+
# Attrs to ConfigThe Module & reuse those attrs
|
11
|
+
@via
|
12
|
+
@link
|
13
|
+
@message
|
14
|
+
@hash_tags
|
15
|
+
@image_url
|
16
|
+
|
17
|
+
# Facade method to create the links
|
18
|
+
def self.on(params={})
|
19
|
+
# SetUp the params if those attrs are empty
|
20
|
+
@via = params[:via] unless params[:via].nil?
|
21
|
+
@link = params[:link] unless params[:link].nil?
|
22
|
+
@message = params[:message] unless params[:message].nil?
|
23
|
+
@hash_tags = params[:hash_tags] unless params[:hash_tags].nil?
|
24
|
+
@image_url = params[:image_url] unless params[:image_url].nil?
|
25
|
+
|
26
|
+
# Dynamic instantiate the social network & get it generated link
|
27
|
+
social_network = "JustShare::#{params[:social].to_s.capitalize_humanized}".to_constant.new params
|
28
|
+
social_network.get_post_link
|
29
|
+
end
|
30
|
+
|
31
|
+
# Convert it array to a simple String to be a GET HTTP param
|
32
|
+
def self.array_to_str_params input_array
|
33
|
+
return_str = '' # init
|
34
|
+
input_array.each { |item| return_str="#{return_str}#{item}," }
|
35
|
+
return_str # return
|
36
|
+
end
|
37
|
+
|
38
|
+
# Static methods to set the Attrs (it means not necessary those attrs in the 'on' method)
|
39
|
+
def self.via=(via)
|
40
|
+
@via=via
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.link=(link)
|
44
|
+
@link=link
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.message=(message)
|
48
|
+
@message=message
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.hash_tags=(hash_tags)
|
52
|
+
@hash_tags = hash_tags if hash_tags.is_a?Array
|
53
|
+
@hash_tags = [] if @hash_tags.nil?
|
54
|
+
@hash_tags.append(hash_tags) unless hash_tags.is_a?Array
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.via
|
58
|
+
@via
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.link_url
|
62
|
+
@link
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.message
|
66
|
+
@message
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.hash_tags
|
70
|
+
@hash_tags.nil? ? @hash_tags=[] : @hash_tags
|
71
|
+
end
|
72
|
+
end
|
data/spec/helpers.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module Helpers
|
2
|
+
# Check if it is an accessible URL
|
3
|
+
def accessible? url
|
4
|
+
resp = RestClient.get url
|
5
|
+
resp.code == 200 ? true : false
|
6
|
+
end
|
7
|
+
|
8
|
+
# Return it current test name, receiving:
|
9
|
+
# context: (self from the RSpec)
|
10
|
+
# the_first: get based only on the first name on the test name
|
11
|
+
def get_current_test_name context, counter, the_first=true
|
12
|
+
current_spec = context.class.descendants.first
|
13
|
+
tests = current_spec.examples
|
14
|
+
test_name = tests[counter].metadata[:description]
|
15
|
+
test_name = test_name.split(' ').first if the_first
|
16
|
+
|
17
|
+
# return it name
|
18
|
+
test_name
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe JustShare do
|
4
|
+
describe 'Links write spelled & accessible' do
|
5
|
+
# SetUp for all tests
|
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'
|
13
|
+
|
14
|
+
# Global useful vars
|
15
|
+
@base_hash = {via:via, link:link, message:message, hash_tags:hash_tags, image_url:url_image}
|
16
|
+
|
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}"
|
25
|
+
end
|
26
|
+
|
27
|
+
# SetUp for each tests
|
28
|
+
before(:each) do
|
29
|
+
# Dynamic get which test is running
|
30
|
+
social_on_test_name = get_current_test_name(self, 0)
|
31
|
+
@base_hash[:social] = social_on_test_name.downcase.strip.to_sym
|
32
|
+
|
33
|
+
# Create it url_generated globally to be DRY on the tests
|
34
|
+
#@url_generated = JustShare.on(@base_hash)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "Facebook link should be okay & accessible" do
|
38
|
+
@base_hash[:social] = :facebook
|
39
|
+
@url_generated = JustShare.on(@base_hash)
|
40
|
+
expect(@url_generated).to be_equals @facebook_expected_url
|
41
|
+
#expect(accessible?(@url_generated)).to be_truthy
|
42
|
+
end
|
43
|
+
|
44
|
+
it "Twitter" do
|
45
|
+
@base_hash[:social] = :twitter
|
46
|
+
@url_generated = JustShare.on(@base_hash)
|
47
|
+
expect(@url_generated).to be_equals @twitter_expected_url
|
48
|
+
#expect(accessible?(@url_generated)).to be_truthy
|
49
|
+
end
|
50
|
+
|
51
|
+
it "GooglePlus" do
|
52
|
+
@base_hash[:social] = 'google-plus'
|
53
|
+
@url_generated = JustShare.on(@base_hash)
|
54
|
+
expect(@url_generated).to be_equals @google_plus_expected_url
|
55
|
+
#expect(accessible?(@url_generated)).to be_truthy
|
56
|
+
end
|
57
|
+
|
58
|
+
it "Pinterest" do
|
59
|
+
@base_hash[:social] = :pinterest
|
60
|
+
@url_generated = JustShare.on(@base_hash)
|
61
|
+
expect(@url_generated).to be_equals @pinterest_expected_url
|
62
|
+
#expect(accessible?(@url_generated)).to be_truthy
|
63
|
+
end
|
64
|
+
|
65
|
+
it "Tumblr" do
|
66
|
+
@base_hash[:social] = :tumblr
|
67
|
+
@url_generated = JustShare.on(@base_hash)
|
68
|
+
expect(@url_generated).to be_equals @tumblr_expected_url
|
69
|
+
#expect(accessible?(@url_generated)).to be_truthy
|
70
|
+
end
|
71
|
+
|
72
|
+
it "Blogger" do
|
73
|
+
@base_hash[:social] = :blogger
|
74
|
+
@url_generated = JustShare.on(@base_hash)
|
75
|
+
expect(@url_generated).to be_equals @blogger_expected_url
|
76
|
+
#expect(accessible?(@url_generated)).to be_truthy
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'rest_client'
|
3
|
+
require './spec/helpers'
|
4
|
+
require 'cgi'
|
5
|
+
|
6
|
+
Bundler.setup
|
7
|
+
|
8
|
+
require 'simplecov'
|
9
|
+
SimpleCov.start do
|
10
|
+
end
|
11
|
+
|
12
|
+
# and any other gems you need
|
13
|
+
require 'just_share'
|
14
|
+
require 'faker'
|
15
|
+
|
16
|
+
RSpec.configure do |c|
|
17
|
+
# some (optional) config here
|
18
|
+
c.include Helpers
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: just_share
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ilton Garcia
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.3'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 10.3.2
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '10.3'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 10.3.2
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rspec
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.1'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 3.1.0
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '3.1'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 3.1.0
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: simplecov
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - "~>"
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0.7'
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.7.1
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0.7'
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.7.1
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: faker
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '1.4'
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.4.2
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.4'
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 1.4.2
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
name: rest-client
|
109
|
+
requirement: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - "~>"
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '1.7'
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.7.2
|
117
|
+
type: :runtime
|
118
|
+
prerelease: false
|
119
|
+
version_requirements: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '1.7'
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 1.7.2
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: multi_json
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '1.10'
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 1.10.1
|
137
|
+
type: :runtime
|
138
|
+
prerelease: false
|
139
|
+
version_requirements: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - "~>"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '1.10'
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 1.10.1
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: colorize
|
149
|
+
requirement: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 0.7.3
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: 0.7.3
|
157
|
+
type: :runtime
|
158
|
+
prerelease: false
|
159
|
+
version_requirements: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - "~>"
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: 0.7.3
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.7.3
|
167
|
+
description: It is useful to create the share buttons on sites, blog & apps to increase
|
168
|
+
your range
|
169
|
+
email:
|
170
|
+
- ilton_unb@hotmail.com
|
171
|
+
executables: []
|
172
|
+
extensions: []
|
173
|
+
extra_rdoc_files: []
|
174
|
+
files:
|
175
|
+
- ".gitignore"
|
176
|
+
- Gemfile
|
177
|
+
- Gemfile.lock
|
178
|
+
- LICENSE
|
179
|
+
- README.md
|
180
|
+
- Rakefile
|
181
|
+
- just_share.gemspec
|
182
|
+
- lib/just_share.rb
|
183
|
+
- lib/just_share/blogger.rb
|
184
|
+
- lib/just_share/chiq.rb
|
185
|
+
- lib/just_share/delicious.rb
|
186
|
+
- lib/just_share/facebook.rb
|
187
|
+
- lib/just_share/google_plus.rb
|
188
|
+
- lib/just_share/pinterest.rb
|
189
|
+
- lib/just_share/reddit.rb
|
190
|
+
- lib/just_share/social_linker.rb
|
191
|
+
- lib/just_share/string.rb
|
192
|
+
- lib/just_share/tumblr.rb
|
193
|
+
- lib/just_share/twitter.rb
|
194
|
+
- lib/just_share/version.rb
|
195
|
+
- lib/just_share/vk.rb
|
196
|
+
- lib/just_share/xing.rb
|
197
|
+
- 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
|
+
- 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
|
+
- spec/spec_helper.rb
|
206
|
+
homepage: http://tonfw.github.io/just_share
|
207
|
+
licenses:
|
208
|
+
- MIT
|
209
|
+
metadata: {}
|
210
|
+
post_install_message:
|
211
|
+
rdoc_options: []
|
212
|
+
require_paths:
|
213
|
+
- lib
|
214
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
requirements: []
|
225
|
+
rubyforge_project:
|
226
|
+
rubygems_version: 2.2.2
|
227
|
+
signing_key:
|
228
|
+
specification_version: 4
|
229
|
+
summary: Create share links to many social networks
|
230
|
+
test_files:
|
231
|
+
- 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
|
+
- 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
|
+
- spec/spec_helper.rb
|