drummond 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in drummond.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jen Oslislo
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,29 @@
1
+ # Drummond
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'drummond'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install drummond
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/drummond.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'drummond/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "drummond"
8
+ gem.version = Drummond::VERSION
9
+ gem.authors = ["Jen Oslislo"]
10
+ gem.email = ["poeksweb@gmail.com"]
11
+ gem.description = %q{A simple wrapper for Faraday}
12
+ gem.summary = %q{A simple wrapper for Faraday}
13
+ gem.homepage = "http://github.com/poeks/drummond"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'faraday', '~>0.8.8'
21
+ gem.add_dependency 'multi_json', '~>1.7.9'
22
+ gem.add_development_dependency 'rspec'
23
+ end
@@ -0,0 +1,3 @@
1
+ class Drummond
2
+ VERSION = "0.0.1"
3
+ end
data/lib/drummond.rb ADDED
@@ -0,0 +1,48 @@
1
+ require "drummond/version"
2
+
3
+ class Drummond
4
+
5
+ attr_accessor :conn, :debug
6
+
7
+ def initialize url, debug=false, encoding=:url_encoded, adapter=Faraday.default_adapter
8
+ @debug = debug
9
+ @conn = Faraday.new(:url => url) do |faraday|
10
+ faraday.request encoding
11
+ faraday.response :logger if @debug
12
+ faraday.adapter adapter
13
+ end
14
+ end
15
+
16
+ def get path, params = {}, headers = {}
17
+ self.request path, 'get', params, headers
18
+ end
19
+
20
+ def post path, params = {}, headers = {}
21
+ self.request path, 'post', params, headers
22
+ end
23
+
24
+ def put path, params = {}, headers = {}
25
+ self.request path, 'put', params, headers
26
+ end
27
+
28
+ def delete path, params = {}, headers = {}
29
+ self.request path, 'delete', params, headers
30
+ end
31
+
32
+ protected
33
+
34
+ def request path, method = 'get', params = {}, headers = {}
35
+ res = self.conn.send(method, path) do |req|
36
+ req.params = params
37
+ req.headers = headers if headers.keys.size > 0
38
+ end
39
+ self.process res.body
40
+ end
41
+
42
+ def process stuff
43
+ MultiJson.load stuff
44
+ rescue MultiJson::LoadError => le
45
+ stuff
46
+ end
47
+
48
+ end
@@ -0,0 +1,35 @@
1
+ require 'rubygems'
2
+ require 'faraday'
3
+ require 'multi_json'
4
+
5
+ require_relative '../lib/drummond'
6
+
7
+ describe Drummond do
8
+
9
+ it 'should also return HTML' do
10
+ r = Drummond.new "http://google.com"
11
+ res = r.get ''
12
+ expect(res.class).to eq(String)
13
+ expect(res).to match(/^<HTML/)
14
+ end
15
+
16
+ it 'should GET json' do
17
+ r = Drummond.new "http://date.jsontest.com"
18
+ res = r.get ''
19
+ expect(res.class).to eq(Hash)
20
+ end
21
+
22
+ it 'should POST json' do
23
+ r = Drummond.new "http://date.jsontest.com"
24
+ res = r.post ''
25
+ expect(res.class).to eq(Hash)
26
+ end
27
+
28
+ it 'should send parameters' do
29
+ r = Drummond.new "http://validate.jsontest.com"
30
+ res = r.get '', {json: "{thinga: 'b'}"}
31
+ expect(res.class).to eq(Hash)
32
+ expect(res['empty']).to eq(false)
33
+ end
34
+
35
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: drummond
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jen Oslislo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.8.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.8
30
+ - !ruby/object:Gem::Dependency
31
+ name: multi_json
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.7.9
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.7.9
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: A simple wrapper for Faraday
63
+ email:
64
+ - poeksweb@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - drummond.gemspec
75
+ - lib/drummond.rb
76
+ - lib/drummond/version.rb
77
+ - spec/drummond_spec.rb
78
+ homepage: http://github.com/poeks/drummond
79
+ licenses: []
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 1.8.25
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: A simple wrapper for Faraday
102
+ test_files:
103
+ - spec/drummond_spec.rb