sharrando 0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6e2fb8336acf96cadc54ce2645f830c739b751c7
4
+ data.tar.gz: 784e314d843a171aa879872bf35df4a5eb9b0ae6
5
+ SHA512:
6
+ metadata.gz: e2ec466bf5d7702cbccf13078fb6593ee47f38596b776971bc0289a11372101f29ed9b520cea59b277d2b00b5e862470aab88d6a3a69378b60484b25a8736396
7
+ data.tar.gz: f5c846dfe0a6f7cb5480e98a0d31dc238a4148b3bd496f0c39b0980dd539ae83b65f8b9814b17871a5d6d879574bd2b4a8d9c9a6b09b8970c61cef5a3b627ed5
@@ -0,0 +1,16 @@
1
+ #--
2
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3
+ # Version 2, December 2004
4
+ #
5
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
6
+ # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
7
+ #
8
+ # 0. You just DO WHAT THE FUCK YOU WANT TO.
9
+ #++
10
+
11
+ module Sharrando
12
+ def sharrando_social_url(social, *things)
13
+ things.each { |k, v| things[k] = CGI::escape(v) if v.is_a?(String) }
14
+ Social.new.send(social, *things)
15
+ end
16
+ end
@@ -0,0 +1,49 @@
1
+ #--
2
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3
+ # Version 2, December 2004
4
+ #
5
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
6
+ # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
7
+ #
8
+ # 0. You just DO WHAT THE FUCK YOU WANT TO.
9
+ #++
10
+
11
+ module Sharrando
12
+ class Social
13
+ def email(subject: subject, body: body)
14
+ "mailto:?to=&subject=#{subject}&body=#{body.gsub("\n", "%0D%0A")}"
15
+ end
16
+
17
+ def twitter(text: text)
18
+ "https://twitter.com/home?status=#{text}"
19
+ end
20
+
21
+ def facebook(title: title, url: url, description: description, image: image)
22
+ if !description || description.empty?
23
+ "http://www.facebook.com/sharer.php?t=#{title}&u=#{url}"
24
+ else
25
+ "http://www.facebook.com/sharer.php?s=100&p[url]=#{url}&p[title]=#{title}&p[summary]=#{description}&p[images][0]=#{image}"
26
+ end
27
+ end
28
+
29
+ def google_plus(url: url, text: text)
30
+ "https://plus.google.com/share?url=#{url}&t=#{text}"
31
+ end
32
+
33
+ def tumblr(data_type: data_type, contents: contents = {})
34
+ raise ArgumentError, "Data type must be <link>, <text>, <photo> or <quote>" unless %i(link text photo quote).include? data_type
35
+
36
+ "http://www.tumblr.com/share/#{data_type}?".tap do |url|
37
+ (contents ||= {}).each { |key, val| url << "#{key}=#{CGI::escape(val)}&"}
38
+ end
39
+ end
40
+
41
+ def delicious(url: url, title: title)
42
+ "http://www.delicious.com/save?url=#{url}&title=#{title}&jump=yes&pic=#{image}"
43
+ end
44
+
45
+ def linkedin(url: url, title: title, description: description, source: source)
46
+ "http://www.linkedin.com/shareArticle?mini=true&url=#{url}&title=#{title}&summary=#{description}&source=#{source}"
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,13 @@
1
+ #--
2
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3
+ # Version 2, December 2004
4
+ #
5
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
6
+ # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
7
+ #
8
+ # 0. You just DO WHAT THE FUCK YOU WANT TO.
9
+ #++
10
+
11
+ module Sharrando
12
+ VERSION = '0.1'
13
+ end
data/lib/sharrando.rb ADDED
@@ -0,0 +1,14 @@
1
+ #--
2
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3
+ # Version 2, December 2004
4
+ #
5
+ # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
6
+ # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
7
+ #
8
+ # 0. You just DO WHAT THE FUCK YOU WANT TO.
9
+ #++
10
+ require 'cgi'
11
+
12
+ require 'sharrando/social'
13
+ require 'sharrando/sharrando'
14
+ require 'sharrando/version'
@@ -0,0 +1,10 @@
1
+ #! /usr/bin/env ruby
2
+ require 'sharrando'
3
+ include Sharrando
4
+
5
+ describe Sharrando do
6
+ it 'gets twitter sharring url' do
7
+ url = sharrando_social_url(:twitter, text: 'lololol')
8
+ expect(url).to be_eql('https://twitter.com/home?status=lololol')
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sharrando
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Giovanni Capuano
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Get URLs for share things to social networks like Facebook, Twitter,
42
+ Linkedin, Tumblr, etc.
43
+ email: webmaster@giovannicapuano.net
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/sharrando.rb
49
+ - lib/sharrando/sharrando.rb
50
+ - lib/sharrando/social.rb
51
+ - lib/sharrando/version.rb
52
+ - spec/sharrando_spec.rb
53
+ homepage: http://www.giovannicapuano.net
54
+ licenses:
55
+ - WTFPL
56
+ metadata: {}
57
+ post_install_message:
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubyforge_project:
73
+ rubygems_version: 2.2.2
74
+ signing_key:
75
+ specification_version: 4
76
+ summary: Get URLs for share things to the social networks.
77
+ test_files:
78
+ - spec/sharrando_spec.rb