pocket 0.1.0 → 0.2.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.
Files changed (5) hide show
  1. data/MIT-LICENSE +1 -1
  2. data/README.md +0 -0
  3. data/Rakefile +0 -0
  4. data/lib/pocket.rb +13 -12
  5. metadata +3 -3
@@ -1,4 +1,4 @@
1
- Copyright 2011 Ryan Fitzgerald
1
+ Copyright 2011 Adam Kirk, Mysterious Trousers, LLC
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
@@ -11,7 +11,6 @@ class Pocket
11
11
  :method => :get,
12
12
  :username => nil,
13
13
  :password => nil,
14
- :use_ssl => false,
15
14
  :data => nil,
16
15
  :headers => {
17
16
  "Content-Type" => "application/json",
@@ -23,32 +22,34 @@ class Pocket
23
22
  _options = _options.merge(options)
24
23
 
25
24
  # consolidate needed vars
26
- _url = URI.parse(url)
25
+ _uri = URI.parse(url)
27
26
  _method = _options[:method]
28
27
  _username = _options[:username]
29
28
  _password = _options[:password]
30
29
  _use_ssl = _options[:use_ssl]
31
30
  _data = _options[:data]
32
31
  _headers = _options[:headers]
33
- _path = _url.path ? _url.path : ""
34
- _query = _url.query ? "?" + _url.query : ""
35
- _api_query = _path + _query
36
32
 
37
33
  # create http object
38
- http = Net::HTTP.new(_url.host, _url.port)
39
- http.use_ssl = _use_ssl
34
+ http = Net::HTTP.new(_uri.host, _uri.port)
35
+
36
+ # if ssl
37
+ if _uri.scheme == "https"
38
+ http.use_ssl = true
39
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
40
+ end
40
41
 
41
42
  # create request
42
43
  if _method == :get
43
- request = Net::HTTP::Get.new(_api_query, _headers)
44
+ request = Net::HTTP::Get.new(_uri.request_uri, _headers)
44
45
  elsif _method == :post
45
- request = Net::HTTP::Post.new(_api_query, _headers)
46
+ request = Net::HTTP::Post.new(_uri.request_uri, _headers)
46
47
  elsif _method == :put
47
- request = Net::HTTP::Put.new(_api_query, _headers)
48
+ request = Net::HTTP::Put.new(_uri.request_uri, _headers)
48
49
  elsif _method == :delete
49
- request = Net::HTTP::Delete.new(_api_query, _headers)
50
+ request = Net::HTTP::Delete.new(_uri.request_uri, _headers)
50
51
  else
51
- request = Net::HTTP::Get.new(_api_query, _headers)
52
+ request = Net::HTTP::Get.new(_uri.request_uri, _headers)
52
53
  end
53
54
 
54
55
  # add data (if any)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pocket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-24 00:00:00.000000000Z
13
+ date: 2011-11-24 00:00:00.000000000 Z
14
14
  dependencies: []
15
15
  description: curl done right
16
16
  email: adam@mysterioustrousers.com
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  version: '0'
43
43
  requirements: []
44
44
  rubyforge_project:
45
- rubygems_version: 1.8.10
45
+ rubygems_version: 1.8.24
46
46
  signing_key:
47
47
  specification_version: 3
48
48
  summary: curl done right