sharrando 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sharrando/sharrando.rb +23 -3
- data/lib/sharrando/version.rb +2 -2
- data/spec/sharrando_spec.rb +24 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 271a68c632116ac2e50d9b68d5bfe6a0da978580
|
4
|
+
data.tar.gz: d1cb4cfaaf460523e0318e3422c40af6b0a246ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcbce8cdb4b5979f151e924e98b771d8e473912fb4155d7d01722d4180252ba7953c8b2665a045a6a83df52d0ae15b53c00d4bc16013876ed0642d4ed6905763
|
7
|
+
data.tar.gz: 1359ace631f33d097c3c68290645018f47f15b58717db01a4aae8499593f501cadeab73fdd21185e942ada3e688412e6ed45fd9596eddc0ae1892013c5fb7473
|
data/lib/sharrando/sharrando.rb
CHANGED
@@ -9,14 +9,34 @@
|
|
9
9
|
#++
|
10
10
|
|
11
11
|
module Sharrando
|
12
|
+
class << self
|
13
|
+
def on(social, *things)
|
14
|
+
things.each { |k, v| things[k] = CGI::escape(v) if v.is_a?(String) }
|
15
|
+
Social.new.send(social, *things)
|
16
|
+
end
|
17
|
+
|
18
|
+
def configure
|
19
|
+
if block_given?
|
20
|
+
yield self
|
21
|
+
else
|
22
|
+
raise ArgumentError, 'A block is required as first parameter.'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Social.list.each do |social|
|
27
|
+
define_method(social) do |*things|
|
28
|
+
self.on(social, *things)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
12
33
|
def sharrando_on(social, *things)
|
13
|
-
|
14
|
-
Social.new.send(social, *things)
|
34
|
+
self.on(social, *things)
|
15
35
|
end
|
16
36
|
|
17
37
|
Social.list.each do |social|
|
18
38
|
define_method(:"sharrando_on_#{social}") do |*things|
|
19
|
-
|
39
|
+
Sharrando.on(social, *things)
|
20
40
|
end
|
21
41
|
end
|
22
42
|
end
|
data/lib/sharrando/version.rb
CHANGED
data/spec/sharrando_spec.rb
CHANGED
@@ -1,15 +1,32 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
require 'sharrando'
|
3
|
-
include Sharrando
|
4
3
|
|
5
4
|
describe Sharrando do
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
context 'using instance methods' do
|
6
|
+
include Sharrando
|
7
|
+
|
8
|
+
it 'gets twitter sharing url' do
|
9
|
+
url = sharrando_on(:twitter, text: 'lololol')
|
10
|
+
expect(url).to be_eql('https://twitter.com/home?status=lololol')
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'gets twitter sharing url via custom helper' do
|
14
|
+
url = sharrando_on_twitter(text: 'lololol')
|
15
|
+
expect(url).to be_eql('https://twitter.com/home?status=lololol')
|
16
|
+
end
|
9
17
|
end
|
10
18
|
|
11
|
-
|
12
|
-
|
13
|
-
|
19
|
+
context 'using class methods' do
|
20
|
+
it 'gets twitter sharing url' do
|
21
|
+
url = Sharrando.on(:twitter, text: 'lololol')
|
22
|
+
expect(url).to be_eql('https://twitter.com/home?status=lololol')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'gets twitter sharing url inside a block' do
|
26
|
+
Sharrando.configure do |on|
|
27
|
+
url = on.twitter(text: 'lololol')
|
28
|
+
expect(url).to be_eql('https://twitter.com/home?status=lololol')
|
29
|
+
end
|
30
|
+
end
|
14
31
|
end
|
15
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sharrando
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giovanni Capuano
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|