earl_post 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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/earl_post.gemspec +18 -0
- data/lib/earl_post.rb +38 -0
- data/lib/earl_post/version.rb +3 -0
- metadata +54 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Jacob Vallejo
|
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,35 @@
|
|
1
|
+
# EarlPost
|
2
|
+
|
3
|
+
Leverages the builtin net/http(s) 'gem' of the Ruby stdlib to submit POSTS and read back HTTP/S Requests and Responses.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'earl_post'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install earl_post
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Use `Earl::Post.to_url('https://example.com', post_data)`
|
22
|
+
|
23
|
+
-- or --
|
24
|
+
|
25
|
+
Use `post_data = Earl::Msg.new('https://example.com', post_data)` to be able to
|
26
|
+
access `post_data.submit` to submit and `post_data.response` to store and access
|
27
|
+
the response.
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/earl_post.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/earl_post/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Jacob Vallejo"]
|
6
|
+
gem.email = ["you@jahkeup.com"]
|
7
|
+
gem.description = %q{Submit HTTP/S Posts and read Responses}
|
8
|
+
gem.summary = %q{This gem will accept http/s uri's to submit a given piece of
|
9
|
+
data to and then return the response. }
|
10
|
+
gem.homepage = ""
|
11
|
+
|
12
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
13
|
+
gem.files = `git ls-files`.split("\n")
|
14
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
gem.name = "earl_post"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = EarlPost::VERSION
|
18
|
+
end
|
data/lib/earl_post.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require "earl_post/version"
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
module Earl
|
5
|
+
end
|
6
|
+
|
7
|
+
class Earl::Post
|
8
|
+
def self.to_url(url,data)
|
9
|
+
# submit lead to url via xml format.
|
10
|
+
# will return the response, use response.body to analyze
|
11
|
+
ssl = url.include? "https"
|
12
|
+
url = URI.parse(url)
|
13
|
+
http = Net::HTTP.new(url.host, url.port)
|
14
|
+
http.use_ssl = ssl
|
15
|
+
request = Net::HTTP::Post.new(url.path)
|
16
|
+
request.body = data
|
17
|
+
http.request(request).body
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Earl::Msg
|
22
|
+
attr_accessor :data, :url
|
23
|
+
|
24
|
+
def initialize(url = nil,data = nil)
|
25
|
+
@data = data
|
26
|
+
@url = url
|
27
|
+
@submitted = false
|
28
|
+
@response = nil
|
29
|
+
end
|
30
|
+
def submit
|
31
|
+
unless @url
|
32
|
+
false
|
33
|
+
else
|
34
|
+
@submitted = true
|
35
|
+
@response = Earl::Post.to_url(@url, @data)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: earl_post
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jacob Vallejo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-29 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Submit HTTP/S Posts and read Responses
|
15
|
+
email:
|
16
|
+
- you@jahkeup.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- earl_post.gemspec
|
27
|
+
- lib/earl_post.rb
|
28
|
+
- lib/earl_post/version.rb
|
29
|
+
homepage: ''
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 1.8.18
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: This gem will accept http/s uri's to submit a given piece of data to and
|
53
|
+
then return the response.
|
54
|
+
test_files: []
|