sharrando 0.4 → 0.5

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: 85365e496c7e79ddf2e2f7453e1b83c846ece463
4
- data.tar.gz: 8f8b0ccff4cfa8d87889ef83251e0469bb33b151
3
+ metadata.gz: 271a68c632116ac2e50d9b68d5bfe6a0da978580
4
+ data.tar.gz: d1cb4cfaaf460523e0318e3422c40af6b0a246ff
5
5
  SHA512:
6
- metadata.gz: 9f4db86db4c50f3f872a72367b5bcae72212c0f99d251d904c90c597e2239d5c4c87f66259d40b1bc96612870cbd14ece7209f296021a8c48ddefaec1fe070c0
7
- data.tar.gz: 39f7d323922c43b09b065964300126721f6dd38aec857987cf9d9ec1c9a4c68d31af0b2645348d544fa5de226213f872ead732a520b85fb7ae7ffb6f2affb93b
6
+ metadata.gz: fcbce8cdb4b5979f151e924e98b771d8e473912fb4155d7d01722d4180252ba7953c8b2665a045a6a83df52d0ae15b53c00d4bc16013876ed0642d4ed6905763
7
+ data.tar.gz: 1359ace631f33d097c3c68290645018f47f15b58717db01a4aae8499593f501cadeab73fdd21185e942ada3e688412e6ed45fd9596eddc0ae1892013c5fb7473
@@ -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
- things.each { |k, v| things[k] = CGI::escape(v) if v.is_a?(String) }
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
- sharrando_on(social, *things)
39
+ Sharrando.on(social, *things)
20
40
  end
21
41
  end
22
42
  end
@@ -9,5 +9,5 @@
9
9
  #++
10
10
 
11
11
  module Sharrando
12
- VERSION = '0.4'
13
- end
12
+ VERSION = '0.5'
13
+ end
@@ -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
- it 'gets twitter sharing url' do
7
- url = sharrando_on(:twitter, text: 'lololol')
8
- expect(url).to be_eql('https://twitter.com/home?status=lololol')
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
- it 'gets twitter sharing url via custom helper' do
12
- url = sharrando_on_twitter(text: 'lololol')
13
- expect(url).to be_eql('https://twitter.com/home?status=lololol')
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'
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-05-14 00:00:00.000000000 Z
11
+ date: 2014-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec