esa 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 329f57a926a65830b8354c22344a8157c1b3de43
4
- data.tar.gz: 17a14d17d1e788b3741eb8bd3c69aea848abff7c
3
+ metadata.gz: bac52bf7b2e659e55596b89891f38c61773a52ac
4
+ data.tar.gz: 916c2ef77c5a18a5197992f38c2712cafc08395c
5
5
  SHA512:
6
- metadata.gz: a61640a6684988e31e0a88d9024533204243fd3777a559a64ef2540315064e98a6a47112203d59ed8ba3e84b9554462ddbfa526eb144087e0ae563007380e1ed
7
- data.tar.gz: a8a8587f8dab6de832b47e3c1dada4f8e8a27800224adee3da4b876b6a7511b5b1fdac62ca5d7f5f686d44a29d4bc42bddf014075a36c1e025c036f6dc7cb633
6
+ metadata.gz: d17c30676abbdaabe4d381bec5d60a00bd5cabad134cf04f58af89ae5d32a98fb5c48234529bbd3420728f8bb067721c33466e5e96c29aaba3d4f827a690ae7e
7
+ data.tar.gz: 791b867661b6f9b4674d3073729b94f25b2756b43baeb6aa46350a4c60f0937d80a137e6f0323e93b44176e03d40348de21b5f50e6f2f26a1aa82224376498c5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.1.1 (2015-10-01)
2
+ - [Enable to set cookie for remote url on #upload_attachment by fukayatsu · Pull Request #14 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/14)
3
+
1
4
  ## 1.1.0 (2015-10-01)
2
5
  - [Enable to Upload Attachment by fukayatsu · Pull Request #13 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/13)
3
6
 
data/README.md CHANGED
@@ -76,9 +76,10 @@ client.delete_comment(comment_id)
76
76
 
77
77
 
78
78
  # Upload Attachment(beta)
79
- client.upload_attachment('/Users/foo/Desktop/foo.png') # Path
80
- client.upload_attachment(File.open('/Users/foo/Desktop/foo.png')) # File
81
- client.upload_attachment('http://example.com/foo.png') # URL
79
+ client.upload_attachment('/Users/foo/Desktop/foo.png') # Path
80
+ client.upload_attachment(File.open('/Users/foo/Desktop/foo.png')) # File
81
+ client.upload_attachment('http://example.com/foo.png') # Remote URL
82
+ client.upload_attachment(['http://example.com/foo.png', cookie_str]) # Remote URL + Cookie
82
83
 
83
84
  ```
84
85
 
@@ -101,11 +101,16 @@ module Esa
101
101
  end
102
102
 
103
103
  def file_from(path_or_file_or_url)
104
+ path_or_file_or_url, cookie = *path_or_file_or_url if path_or_file_or_url.is_a?(Array)
105
+
104
106
  if path_or_file_or_url.respond_to?(:read)
105
107
  path_or_file_or_url
106
108
  elsif path_or_file_or_url.is_a?(String) && HTTP_REGEX.match(path_or_file_or_url)
107
109
  remote_url = path_or_file_or_url
108
- response = send_simple_request(:get, remote_url)
110
+ headers = {}
111
+ headers[:Cookie] = cookie if cookie
112
+ response = send_simple_request(:get, remote_url, nil, headers)
113
+ raise RemoteURLNotAvailableError, "#{remote_url} is not available." unless response.status == 200
109
114
  PathStringIO.new(File.basename(remote_url), response.body)
110
115
  else
111
116
  path = path_or_file_or_url
data/lib/esa/errors.rb CHANGED
@@ -2,4 +2,5 @@ module Esa
2
2
  class EsaError < StandardError; end
3
3
  class TeamNotSpecifiedError < EsaError; end
4
4
  class MissingContentTypeError < EsaError; end
5
+ class RemoteURLNotAvailableError < EsaError; end
5
6
  end
data/lib/esa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Esa
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esa
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - fukayatsu