ruby-bitly 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c173fdedc9e8eb666ec603ae9f8d3cee19e3b070
4
+ data.tar.gz: 7bf398863c2f068f3d52ca8f5d15347ae885101f
5
+ SHA512:
6
+ metadata.gz: 7afbb33e8e8524bcd6c7259b5e831cfe51ece8292dd0d0486067d6bcd00299035d4a406a01ecf106fb8c1041c9682023253bbf485528ce87332c7f5c0aec07f0
7
+ data.tar.gz: f8369b7e41778a32a12ff74dc8222392982dd3142d41c4e3048abd5784427ff3b1419cc70e376bc3b4552ff6592f7a15d4fbb9118407526683b35e3048b574e6
data/Gemfile CHANGED
@@ -2,3 +2,15 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in ruby-bitly.gemspec
4
4
  gemspec
5
+
6
+ group :development, :test do
7
+
8
+ platforms :ruby_18 do
9
+ gem 'ruby-debug'
10
+ end
11
+
12
+ platforms :ruby_19, :ruby_20 do
13
+ gem 'debugger'
14
+ end
15
+
16
+ end
@@ -1,38 +1,58 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-bitly (0.1.5)
5
- rest-client (~> 1.6.1)
4
+ ruby-bitly (0.1.6)
5
+ json_pure (~> 1.7)
6
+ rest-client (~> 1.6)
6
7
 
7
8
  GEM
8
9
  remote: http://rubygems.org/
9
10
  specs:
10
- addressable (2.2.6)
11
- crack (0.1.8)
12
- diff-lcs (1.1.2)
13
- mime-types (1.16)
14
- rake (0.8.7)
15
- rest-client (1.6.1)
11
+ addressable (2.3.3)
12
+ columnize (0.3.6)
13
+ crack (0.3.2)
14
+ debugger (1.4.0)
15
+ columnize (>= 0.3.1)
16
+ debugger-linecache (~> 1.1.1)
17
+ debugger-ruby_core_source (~> 1.2.0)
18
+ debugger-linecache (1.1.2)
19
+ debugger-ruby_core_source (>= 1.1.1)
20
+ debugger-ruby_core_source (1.2.0)
21
+ diff-lcs (1.2.1)
22
+ json_pure (1.7.7)
23
+ linecache (0.46)
24
+ rbx-require-relative (> 0.0.4)
25
+ mime-types (1.21)
26
+ rake (10.0.3)
27
+ rbx-require-relative (0.0.9)
28
+ rest-client (1.6.7)
16
29
  mime-types (>= 1.16)
17
- rspec (2.6.0)
18
- rspec-core (~> 2.6.0)
19
- rspec-expectations (~> 2.6.0)
20
- rspec-mocks (~> 2.6.0)
21
- rspec-core (2.6.4)
22
- rspec-expectations (2.6.0)
23
- diff-lcs (~> 1.1.2)
24
- rspec-mocks (2.6.0)
25
- vcr (1.10.0)
30
+ rspec (2.13.0)
31
+ rspec-core (~> 2.13.0)
32
+ rspec-expectations (~> 2.13.0)
33
+ rspec-mocks (~> 2.13.0)
34
+ rspec-core (2.13.0)
35
+ rspec-expectations (2.13.0)
36
+ diff-lcs (>= 1.1.3, < 2.0)
37
+ rspec-mocks (2.13.0)
38
+ ruby-debug (0.10.4)
39
+ columnize (>= 0.1)
40
+ ruby-debug-base (~> 0.10.4.0)
41
+ ruby-debug-base (0.10.4)
42
+ linecache (>= 0.3)
43
+ vcr (1.10.3)
26
44
  webmock (1.6.4)
27
- addressable (> 2.2.5, ~> 2.2)
45
+ addressable (~> 2.2, > 2.2.5)
28
46
  crack (>= 0.1.7)
29
47
 
30
48
  PLATFORMS
31
49
  ruby
32
50
 
33
51
  DEPENDENCIES
34
- rake (~> 0.8.7)
35
- rspec (~> 2.6.0)
52
+ debugger
53
+ rake
54
+ rspec (~> 2.13)
36
55
  ruby-bitly!
56
+ ruby-debug
37
57
  vcr (~> 1.10.0)
38
58
  webmock (~> 1.6.4)
data/bin/bitly CHANGED
@@ -41,7 +41,9 @@ class App
41
41
  protected
42
42
 
43
43
  def copy_to_clipboard(value)
44
- system "printf '#{value.strip}' 2> /dev/null | pbcopy 2> /dev/null" if RUBY_PLATFORM[/darwin/]
44
+ unless value.nil?
45
+ system "printf '#{value.strip}' 2> /dev/null | pbcopy 2> /dev/null" if RUBY_PLATFORM[/darwin/]
46
+ end
45
47
  end
46
48
 
47
49
  def load_account_data
@@ -122,7 +124,7 @@ class App
122
124
  end
123
125
 
124
126
  def output_version
125
- puts "bitly version #{Bitly::VERSION} [gem ruby-bitly]"
127
+ puts "bitly version #{BitlyGem::VERSION} [gem ruby-bitly]"
126
128
  end
127
129
 
128
130
  def process_command
@@ -3,7 +3,7 @@
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :post
5
5
  uri: http://api.bit.ly:80/v3/expand
6
- body: shortURL=http%3A%2F%2Fgoogle.com&login=rafaeldx7&apiKey=R_59c1b174b21d92b2beeb4787a6d7ebaf
6
+ body: shortURL=http%3A%2F%2Fgoogle.com&login=my-login&apiKey=my-secret-key
7
7
  headers:
8
8
  accept:
9
9
  - "*/*; q=0.5, application/xml"
@@ -3,7 +3,7 @@
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :post
5
5
  uri: http://api.bit.ly:80/v3/expand
6
- body: shortURL=http%3A%2F%2Fbit.ly%2FbcvNe5&login=rafaeldx7&apiKey=R_59c1b174b21d92b2beeb4787a6d7ebaf
6
+ body: shortURL=http%3A%2F%2Fbit.ly%2FbcvNe5&login=my-login&apiKey=my-secret-key
7
7
  headers:
8
8
  accept:
9
9
  - "*/*; q=0.5, application/xml"
@@ -2,7 +2,7 @@
2
2
  - !ruby/struct:VCR::HTTPInteraction
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :get
5
- uri: http://api.bit.ly:80/v3/clicks?apiKey=R_59c1b174b21d92b2beeb4787a6d7ebaf&login=rafaeldx7&shortUrl=http://bit.ly/xlii42
5
+ uri: http://api.bit.ly:80/v3/clicks?apiKey=my-secret-key&login=my-login&shortUrl=http://bit.ly/xlii42
6
6
  body:
7
7
  headers:
8
8
  accept:
@@ -3,7 +3,7 @@
3
3
  request: !ruby/struct:VCR::Request
4
4
  method: :post
5
5
  uri: http://api.bit.ly:80/v3/shorten
6
- body: longURL=http%3A%2F%2Fbit.ly%2FbcvNe5&login=rafaeldx7&apiKey=R_59c1b174b21d92b2beeb4787a6d7ebaf
6
+ body: longURL=http%3A%2F%2Fbit.ly%2FbcvNe5&login=my-login&apiKey=my-secret-key
7
7
  headers:
8
8
  accept:
9
9
  - "*/*; q=0.5, application/xml"
@@ -1,36 +1,36 @@
1
- ---
2
- - !ruby/struct:VCR::HTTPInteraction
3
- request: !ruby/struct:VCR::Request
1
+ ---
2
+ - !ruby/struct:VCR::HTTPInteraction
3
+ request: !ruby/struct:VCR::Request
4
4
  method: :post
5
5
  uri: http://api.bit.ly:80/v3/shorten
6
- body: longURL=http%3A%2F%2Fgoogle.com&login=rafaeldx7&apiKey=R_59c1b174b21d92b2beeb4787a6d7ebaf
7
- headers:
8
- accept:
6
+ body: longURL=http%3A%2F%2Fgoogle.com&login=my-login&apiKey=my-secret-key
7
+ headers:
8
+ accept:
9
9
  - "*/*; q=0.5, application/xml"
10
- accept-encoding:
10
+ accept-encoding:
11
11
  - gzip, deflate
12
- content-length:
12
+ content-length:
13
13
  - "89"
14
- content-type:
14
+ content-type:
15
15
  - application/x-www-form-urlencoded
16
- response: !ruby/struct:VCR::Response
17
- status: !ruby/struct:VCR::ResponseStatus
16
+ response: !ruby/struct:VCR::Response
17
+ status: !ruby/struct:VCR::ResponseStatus
18
18
  code: 200
19
19
  message: OK
20
- headers:
21
- server:
20
+ headers:
21
+ server:
22
22
  - nginx
23
- date:
23
+ date:
24
24
  - Sat, 28 May 2011 17:11:14 GMT
25
- content-type:
25
+ content-type:
26
26
  - application/json; charset=utf-8
27
- connection:
27
+ connection:
28
28
  - keep-alive
29
- mime-version:
29
+ mime-version:
30
30
  - "1.0"
31
- content-length:
31
+ content-length:
32
32
  - "184"
33
33
  body: |
34
- { "status_code": 200, "status_txt": "OK", "data": { "long_url": "http:\/\/google.com\/", "url": "http:\/\/bit.ly\/lVW32C", "hash": "lVW32C", "global_hash": "3j4ir4", "new_hash": 0 } }
34
+ { "status_code": 200, "status_txt": "OK", "data": { "long_url": "http:\/\/google.com\/", "url": "http:\/\/bit.ly\/lVW32C", "hash": "lVW32C", "global_hash": "3j4ir4", "new_hash": 3 } }
35
35
 
36
36
  http_version: "1.1"
@@ -6,40 +6,44 @@ require 'ostruct'
6
6
 
7
7
  class Bitly < OpenStruct
8
8
 
9
- VERSION = '0.1.5'
10
9
  REST_API_URL = "http://api.bit.ly"
11
10
  ACTION_PATH = { :shorten => '/v3/shorten', :expand => '/v3/expand', :clicks => '/v3/clicks' }
12
11
 
13
- def Bitly.shorten(new_long_url, login, key)
14
- response = JSON.parse RestClient.post(REST_API_URL + ACTION_PATH[:shorten], { :longURL => new_long_url, :login => login, :apiKey => key })
12
+ class << self
13
+ attr_accessor :login, :key
15
14
 
16
- bitly = Bitly.new response["data"]
15
+ def shorten(new_long_url, login = self.login, key = self.key)
16
+ response = JSON.parse RestClient.post(REST_API_URL + ACTION_PATH[:shorten], { :longURL => new_long_url, :login => login, :apiKey => key })
17
+ response.delete("data") if response["data"].empty?
17
18
 
18
- bitly.hash_path = response["data"]["hash"] if response["status_code"] == 200
19
- bitly.status_code = response["status_code"]
20
- bitly.status_txt = response["status_txt"]
19
+ bitly = new response["data"]
21
20
 
22
- bitly
23
- end
21
+ bitly.hash_path = response["data"]["hash"] if response["status_code"] == 200
22
+ bitly.status_code = response["status_code"]
23
+ bitly.status_txt = response["status_txt"]
24
24
 
25
- def Bitly.expand(new_short_url, login, key)
26
- response = JSON.parse RestClient.post(REST_API_URL + ACTION_PATH[:expand], { :shortURL => new_short_url, :login => login, :apiKey => key })
25
+ bitly
26
+ end
27
27
 
28
- bitly = Bitly.new(response["data"]["expand"].first)
29
- bitly.status_code = response["status_code"]
30
- bitly.status_txt = response["status_txt"]
31
- bitly.long_url = bitly.error if bitly.error
28
+ def expand(new_short_url, login = self.login, key = self.key)
29
+ response = JSON.parse RestClient.post(REST_API_URL + ACTION_PATH[:expand], { :shortURL => new_short_url, :login => login, :apiKey => key })
32
30
 
33
- bitly
34
- end
31
+ bitly = new(response["data"]["expand"].first)
32
+ bitly.status_code = response["status_code"]
33
+ bitly.status_txt = response["status_txt"]
34
+ bitly.long_url = bitly.error if bitly.error
35
+
36
+ bitly
37
+ end
35
38
 
36
- def Bitly.get_clicks(new_short_url, login, key)
37
- response = JSON.parse RestClient.get("#{REST_API_URL}#{ACTION_PATH[:clicks]}?login=#{login}&apiKey=#{key}&shortUrl=#{new_short_url}")
39
+ def get_clicks(new_short_url, login = self.login, key = self.key)
40
+ response = JSON.parse RestClient.get("#{REST_API_URL}#{ACTION_PATH[:clicks]}?login=#{login}&apiKey=#{key}&shortUrl=#{new_short_url}")
38
41
 
39
- bitly = Bitly.new(response["data"]["clicks"].first)
40
- bitly.status_code = response["status_code"]
41
- bitly.status_txt = response["status_txt"]
42
+ bitly = new(response["data"]["clicks"].first)
43
+ bitly.status_code = response["status_code"]
44
+ bitly.status_txt = response["status_txt"]
42
45
 
43
- bitly
46
+ bitly
47
+ end
44
48
  end
45
49
  end
@@ -0,0 +1,3 @@
1
+ module BitlyGem
2
+ VERSION = '0.1.6'
3
+ end
@@ -1,10 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "ruby-bitly"
3
+ require "ruby-bitly/version"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "ruby-bitly"
7
- s.version = Bitly::VERSION
7
+ s.version = BitlyGem::VERSION
8
8
  s.authors = ["rafaeldx7"]
9
9
  s.email = ["rafaeldx7@gmail.com"]
10
10
  s.homepage = "http://github.com/rafaeldx7/ruby-bitly"
@@ -14,9 +14,10 @@ Gem::Specification.new do |s|
14
14
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
15
15
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
16
  s.require_paths = ["lib"]
17
- s.add_dependency('rest-client','~> 1.6.1')
18
- s.add_development_dependency('rake', '~> 0.8.7')
19
- s.add_development_dependency('rspec', '~> 2.6.0')
17
+ s.add_dependency('rest-client', '~> 1.6')
18
+ s.add_dependency('json_pure', '~> 1.7')
19
+ s.add_development_dependency('rake')
20
+ s.add_development_dependency('rspec', '~> 2.13')
20
21
  s.add_development_dependency('vcr', '~> 1.10.0')
21
22
  s.add_development_dependency('webmock', '~> 1.6.4')
22
23
  end
@@ -4,8 +4,8 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
4
  describe "RubyBitly" do
5
5
 
6
6
  before(:all) do
7
- @login = 'rafaeldx7'
8
- @key = 'R_59c1b174b21d92b2beeb4787a6d7ebaf'
7
+ @login = 'my-login'
8
+ @key = 'my-secret-key'
9
9
  end
10
10
 
11
11
  it "Shorten long url" do
@@ -15,7 +15,7 @@ describe "RubyBitly" do
15
15
 
16
16
  response.status_code.should == 200
17
17
  response.status_txt.should == "OK"
18
- response.new_hash.should == 0
18
+ response.new_hash.should == 3
19
19
  response.global_hash.should_not be_empty
20
20
  response.hash_path.length.should_not == 0
21
21
  response.url.should match /^http:\/\/bit\.ly\/[A-Za-z0-9]*/
metadata CHANGED
@@ -1,72 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-bitly
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
5
- prerelease:
4
+ version: 0.1.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - rafaeldx7
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2011-06-11 00:00:00.000000000 -03:00
13
- default_executable:
11
+ date: 2013-03-11 00:00:00.000000000 Z
14
12
  dependencies:
15
13
  - !ruby/object:Gem::Dependency
16
14
  name: rest-client
17
- requirement: &2153230060 !ruby/object:Gem::Requirement
18
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
19
16
  requirements:
20
17
  - - ~>
21
18
  - !ruby/object:Gem::Version
22
- version: 1.6.1
19
+ version: '1.6'
23
20
  type: :runtime
24
21
  prerelease: false
25
- version_requirements: *2153230060
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
26
27
  - !ruby/object:Gem::Dependency
27
- name: rake
28
- requirement: &2153224380 !ruby/object:Gem::Requirement
29
- none: false
28
+ name: json_pure
29
+ requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: 0.8.7
33
+ version: '1.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
- version_requirements: *2153224380
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
37
55
  - !ruby/object:Gem::Dependency
38
56
  name: rspec
39
- requirement: &2153223140 !ruby/object:Gem::Requirement
40
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
41
58
  requirements:
42
59
  - - ~>
43
60
  - !ruby/object:Gem::Version
44
- version: 2.6.0
61
+ version: '2.13'
45
62
  type: :development
46
63
  prerelease: false
47
- version_requirements: *2153223140
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '2.13'
48
69
  - !ruby/object:Gem::Dependency
49
70
  name: vcr
50
- requirement: &2153221880 !ruby/object:Gem::Requirement
51
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
52
72
  requirements:
53
73
  - - ~>
54
74
  - !ruby/object:Gem::Version
55
75
  version: 1.10.0
56
76
  type: :development
57
77
  prerelease: false
58
- version_requirements: *2153221880
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.10.0
59
83
  - !ruby/object:Gem::Dependency
60
84
  name: webmock
61
- requirement: &2153221100 !ruby/object:Gem::Requirement
62
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
63
86
  requirements:
64
87
  - - ~>
65
88
  - !ruby/object:Gem::Version
66
89
  version: 1.6.4
67
90
  type: :development
68
91
  prerelease: false
69
- version_requirements: *2153221100
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 1.6.4
70
97
  description: A simple bit.ly ruby client
71
98
  email:
72
99
  - rafaeldx7@gmail.com
@@ -90,39 +117,32 @@ files:
90
117
  - fixtures/vcr_cassettes/shorten_bitly_url.yml
91
118
  - fixtures/vcr_cassettes/shorten_long_url.yml
92
119
  - lib/ruby-bitly.rb
120
+ - lib/ruby-bitly/version.rb
93
121
  - ruby-bitly.gemspec
94
122
  - spec/ruby-bitly_spec.rb
95
123
  - spec/spec_helper.rb
96
- has_rdoc: true
97
124
  homepage: http://github.com/rafaeldx7/ruby-bitly
98
125
  licenses: []
126
+ metadata: {}
99
127
  post_install_message:
100
128
  rdoc_options: []
101
129
  require_paths:
102
130
  - lib
103
131
  required_ruby_version: !ruby/object:Gem::Requirement
104
- none: false
105
132
  requirements:
106
- - - ! '>='
133
+ - - '>='
107
134
  - !ruby/object:Gem::Version
108
135
  version: '0'
109
- segments:
110
- - 0
111
- hash: -1233735729712306384
112
136
  required_rubygems_version: !ruby/object:Gem::Requirement
113
- none: false
114
137
  requirements:
115
- - - ! '>='
138
+ - - '>='
116
139
  - !ruby/object:Gem::Version
117
140
  version: '0'
118
- segments:
119
- - 0
120
- hash: -1233735729712306384
121
141
  requirements: []
122
142
  rubyforge_project:
123
- rubygems_version: 1.6.2
143
+ rubygems_version: 2.0.0
124
144
  signing_key:
125
- specification_version: 3
145
+ specification_version: 4
126
146
  summary: A simple bit.ly ruby client
127
147
  test_files:
128
148
  - spec/ruby-bitly_spec.rb