shrimp_me 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 411deff663e709936e2042083bbc01e00e5b9c90
4
+ data.tar.gz: b85ee5048e6e9b19890a3ebd536644e1e460eec3
5
+ SHA512:
6
+ metadata.gz: a3f74ceddff44360e2b9d7f097c811e919c20875ca92d7826cc8aed396d08ac56f7657f1a942499ba6a0da4e17ad193b0a1753ec79cb5e917bdf0a742f6a107b
7
+ data.tar.gz: 3c5c12ac4178979d7ebf7af087bd03927b969b8d1916305a3aa7e2f6608c60fc478f2d6edba4c7b8d47bafa1a631287594733a45e7f3629a971df56733f5ecd7
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shrimp_me.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Sam Kuhlmann
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # ShrimpMe
2
+
3
+ A wrapper gem for the Shrimpy.me url shortener api.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'shrimp_me'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install shrimp_me
20
+
21
+ ## Usage
22
+
23
+ Here's a simple script that shrimps your url:
24
+ <pre><code>
25
+ require 'shrimp_me'
26
+
27
+ _Create an instance of the client:_
28
+ connection = ShrimpMe::Shrimp.new
29
+
30
+ _Post your long url:_
31
+ shrimpy_url = connection.shorten("http://en.wikipedia.org/wiki/Norm_Peterson")
32
+ </pre></code>
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.test_files = FileList['test/*_test.rb']
7
+ end
8
+
9
+ task default: :test
10
+
data/lib/shrimp_me.rb ADDED
@@ -0,0 +1,31 @@
1
+ require "shrimp_me/version"
2
+ require 'httparty'
3
+
4
+ module ShrimpMe
5
+ class Shrimp
6
+ include HTTParty
7
+ attr_reader :base_uri
8
+
9
+ def initialize
10
+ @base_uri = "http://www.shrimpy.me/api/v1/urls.json"
11
+ end
12
+
13
+ def shorten(full_url)
14
+ response = post_url(full_url)
15
+ "http://shrimpy.me/#{response["slug"]}"
16
+ end
17
+
18
+ def post_url(full_url)
19
+ options = {
20
+ body: {
21
+ url: {
22
+ full_url: full_url
23
+ }
24
+ }
25
+ }
26
+
27
+ HTTParty.post(base_uri, options)
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,3 @@
1
+ module ShrimpMe
2
+ VERSION = "1.0.0"
3
+ end
data/shrimp_me.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'shrimp_me/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "shrimp_me"
8
+ spec.version = ShrimpMe::VERSION
9
+ spec.authors = ["Sam Kuhlmann"]
10
+ spec.email = ["samkuhlmann@gmail.com"]
11
+ spec.summary = %q{A wrapper gem for the Shrimp.me url shortener service}
12
+ spec.description = %q{}
13
+ spec.homepage = "https://github.com/skuhlmann/shrimp-me"
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
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "vcr"
25
+ spec.add_development_dependency "webmock"
26
+ spec.add_dependency "httparty"
27
+ end
@@ -0,0 +1,40 @@
1
+ require 'minitest/autorun'
2
+ require 'minitest/pride'
3
+ require 'vcr'
4
+ require 'webmock'
5
+ require './lib/shrimp_me'
6
+
7
+ class ClientTest < Minitest::Test
8
+
9
+ VCR.configure do |config|
10
+ config.cassette_library_dir = "test/fixtures/vcr_cassettes"
11
+ config.hook_into :webmock
12
+ end
13
+
14
+ def test_it_exists
15
+ assert ShrimpMe::Shrimp
16
+ end
17
+
18
+ def test_it_connects
19
+ connection = ShrimpMe::Shrimp.new
20
+
21
+ assert_equal "http://www.shrimpy.me/api/v1/urls.json", connection.base_uri
22
+ end
23
+
24
+ def test_it_posts_to_shrimp_me
25
+ connection = ShrimpMe::Shrimp.new
26
+ VCR.use_cassette("poster") do
27
+ response = connection.post_url("http://google.com")
28
+
29
+ assert_equal "Google", response["title"]
30
+ end
31
+ end
32
+
33
+ def test_it_shortens_a_url
34
+ VCR.use_cassette("shrimper") do
35
+ connection = ShrimpMe::Shrimp.new
36
+
37
+ assert_includes connection.shorten("http://google.com"), "http://shrimpy.me"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://www.shrimpy.me/api/v1/urls.json
6
+ body:
7
+ encoding: UTF-8
8
+ string: url[full_url]=http%3A%2F%2Fgoogle.com
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 201
19
+ message: Created
20
+ headers:
21
+ Server:
22
+ - Cowboy
23
+ Connection:
24
+ - close
25
+ Date:
26
+ - Sun, 08 Feb 2015 20:21:10 GMT
27
+ Status:
28
+ - 201 Created
29
+ X-Frame-Options:
30
+ - SAMEORIGIN
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Location:
36
+ - http://www.shrimpy.me/31
37
+ Content-Type:
38
+ - application/json; charset=utf-8
39
+ Vary:
40
+ - Accept-Encoding
41
+ Etag:
42
+ - W/"f5c0deae51f24f410b75318dc97357b2"
43
+ Cache-Control:
44
+ - max-age=0, private, must-revalidate
45
+ X-Request-Id:
46
+ - 03c09dfc-76f6-4209-b980-bdc8e7076047
47
+ X-Runtime:
48
+ - '0.114750'
49
+ Via:
50
+ - 1.1 vegur
51
+ body:
52
+ encoding: ASCII-8BIT
53
+ string: '{"id":31,"full_url":"http://google.com","slug":"E0sntQ","title":"Google","created_at":"2015-02-08T20:21:10Z","updated_at":"2015-02-08T20:21:10Z"}'
54
+ http_version:
55
+ recorded_at: Sun, 08 Feb 2015 20:21:10 GMT
56
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,56 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: http://www.shrimpy.me/api/v1/urls.json
6
+ body:
7
+ encoding: UTF-8
8
+ string: url[full_url]=http%3A%2F%2Fgoogle.com
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 201
19
+ message: Created
20
+ headers:
21
+ Server:
22
+ - Cowboy
23
+ Connection:
24
+ - close
25
+ Date:
26
+ - Sun, 08 Feb 2015 20:21:10 GMT
27
+ Status:
28
+ - 201 Created
29
+ X-Frame-Options:
30
+ - SAMEORIGIN
31
+ X-Xss-Protection:
32
+ - 1; mode=block
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ Location:
36
+ - http://www.shrimpy.me/32
37
+ Content-Type:
38
+ - application/json; charset=utf-8
39
+ Vary:
40
+ - Accept-Encoding
41
+ Etag:
42
+ - W/"bef44dd74a72f4f9713740414cb89504"
43
+ Cache-Control:
44
+ - max-age=0, private, must-revalidate
45
+ X-Request-Id:
46
+ - 395c3624-f3f4-40f1-8194-e7da6aee92ea
47
+ X-Runtime:
48
+ - '0.099666'
49
+ Via:
50
+ - 1.1 vegur
51
+ body:
52
+ encoding: ASCII-8BIT
53
+ string: '{"id":32,"full_url":"http://google.com","slug":"wKRwBw","title":"Google","created_at":"2015-02-08T20:21:10Z","updated_at":"2015-02-08T20:21:10Z"}'
54
+ http_version:
55
+ recorded_at: Sun, 08 Feb 2015 20:21:10 GMT
56
+ recorded_with: VCR 2.9.3
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: shrimp_me
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sam Kuhlmann
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-20 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: vcr
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: webmock
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: httparty
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: ''
98
+ email:
99
+ - samkuhlmann@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - lib/shrimp_me.rb
110
+ - lib/shrimp_me/version.rb
111
+ - shrimp_me.gemspec
112
+ - test/client_test.rb
113
+ - test/fixtures/vcr_cassettes/poster.yml
114
+ - test/fixtures/vcr_cassettes/shrimper.yml
115
+ homepage: https://github.com/skuhlmann/shrimp-me
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.4.5
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: A wrapper gem for the Shrimp.me url shortener service
139
+ test_files:
140
+ - test/client_test.rb
141
+ - test/fixtures/vcr_cassettes/poster.yml
142
+ - test/fixtures/vcr_cassettes/shrimper.yml