filepreviews 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +11 -0
- data/README.md +22 -15
- data/lib/filepreviews.rb +10 -1
- data/lib/filepreviews/http.rb +5 -2
- data/lib/filepreviews/utils.rb +1 -1
- data/lib/filepreviews/version.rb +1 -1
- data/spec/filepreviews/http_spec.rb +4 -1
- data/spec/filepreviews/utils_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42c0103985289f8faa7d99d4860b8f921ba60f47
|
4
|
+
data.tar.gz: 1eaadf4c3e6fae2bfed7a1a7c7a64f4dde0fcd1e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 177adaded1998f11e606c4791b4d1762d5b44fa1c92926da18fb2de748958f3cbae8dd867c3ea43881c56de43e232232b107525ba1b9e729ade70945c606e51e
|
7
|
+
data.tar.gz: fe4e2041b2690f420f18db0c4d8c6a5d7bd0647487b7a9eb6897e7f3a5d1f86955bc841d389578af100a1782974253b932d2455ca7c368de7c68b2e42ffc162e
|
data/Changelog.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Filepreviews Changelog
|
2
2
|
|
3
|
+
## 1.2.0
|
4
|
+
|
5
|
+
Released Jun 26, 2014 ([1.2.0](https://github.com/jonahoffline/filepreviews-ruby/tree/v1.2.0)).
|
6
|
+
|
7
|
+
* Update http request from `GET` to `POST`
|
8
|
+
* Add `:format` option
|
9
|
+
* Add new `:metadata` options: `checksum` and `multimedia`
|
10
|
+
* Update `:size` to `:sizes` parameter (in request)
|
11
|
+
* Update README to fix small typo (in example) and add new options
|
12
|
+
* Update version to 1.2.0
|
13
|
+
|
3
14
|
## 1.1.0
|
4
15
|
|
5
16
|
Released Jun 16, 2014 ([1.1.0](https://github.com/jonahoffline/filepreviews-ruby/tree/v1.1.0)).
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# FilePreviews.io (Ruby client)
|
2
|
-
[![
|
3
|
-
[![
|
4
|
-
[![Dependency Status](
|
5
|
-
[![Code Climate](
|
6
|
-
[![
|
7
|
-
[![
|
2
|
+
[![Gem Version](http://img.shields.io/gem/v/filepreviews.svg?style=flat)](http://badge.fury.io/rb/filepreviews)
|
3
|
+
[![Build Status](http://img.shields.io/travis/jonahoffline/filepreviews-ruby.svg?style=flat)](https://travis-ci.org/jonahoffline/filepreviews-ruby)
|
4
|
+
[![Dependency Status](http://img.shields.io/gemnasium/jonahoffline/filepreviews-ruby.svg?style=flat)](https://gemnasium.com/jonahoffline/filepreviews-ruby)
|
5
|
+
[![Code Climate](http://img.shields.io/codeclimate/github/jonahoffline/filepreviews-ruby.svg?style=flat)](https://codeclimate.com/github/jonahoffline/filepreviews-ruby)
|
6
|
+
[![Gitter chat](https://img.shields.io/badge/gitter-filepreviews--ruby-blue.svg?style=flat)](https://gitter.im/jonahoffline/filepreviews-ruby)
|
7
|
+
[![Inline docs](http://inch-ci.org/github/jonahoffline/filepreviews-ruby.png)](http://inch-ci.org/github/jonahoffline/filepreviews-ruby)
|
8
8
|
|
9
9
|
This is the ruby client library for the **Demo API** of [FilePreviews.io](http://filepreviews.io) service. A lot more to come very soon.
|
10
10
|
|
@@ -73,16 +73,22 @@ result.metadata
|
|
73
73
|
You can optionally send an options object (per request).
|
74
74
|
|
75
75
|
```ruby
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
76
|
+
conf = {
|
77
|
+
options: {
|
78
|
+
size: {
|
79
|
+
width: 100,
|
80
|
+
height: 999
|
81
|
+
},
|
82
|
+
# supported: 'exif', 'ocr', 'psd', 'checksum', 'multimedia',
|
83
|
+
# and 'all' which means everything
|
84
|
+
metadata: ['exif', 'ocr', 'psd'],
|
85
|
+
|
86
|
+
# supported: 'jpg', 'jpeg', 'png'
|
87
|
+
format: 'jpg'
|
88
|
+
}
|
83
89
|
}
|
84
90
|
|
85
|
-
result = FilePreviews.generate(url,
|
91
|
+
result = FilePreviews.generate(url, conf)
|
86
92
|
result.preview_url
|
87
93
|
result.metadata_url
|
88
94
|
result.metadata
|
@@ -116,7 +122,8 @@ Options:
|
|
116
122
|
## Discussion
|
117
123
|
If you have any questions, ideas or jokes:
|
118
124
|
|
119
|
-
[![Gitter chat](https://
|
125
|
+
[![Gitter chat](https://img.shields.io/badge/gitter-filepreviews--ruby-blue.svg?style=flat)](https://gitter.im/jonahoffline/filepreviews-ruby)
|
126
|
+
|
120
127
|
|
121
128
|
## Contributing
|
122
129
|
|
data/lib/filepreviews.rb
CHANGED
@@ -45,12 +45,21 @@ module Filepreviews
|
|
45
45
|
metadata = (options.fetch(:metadata) & metadata_formats)
|
46
46
|
options.store(:metadata, metadata)
|
47
47
|
|
48
|
+
image = (options.fetch(:format) if image_formats.include?(options[:format]))
|
49
|
+
options.store(:format, image)
|
50
|
+
|
48
51
|
default_options.merge(options)
|
49
52
|
end
|
50
53
|
|
51
54
|
# Supported (image) formats in metadata
|
52
55
|
# @return [Array] image file extensions
|
53
56
|
def self.metadata_formats
|
54
|
-
%w(all exif ocr psd)
|
57
|
+
%w(all exif ocr psd checksum multimedia)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Supported extracted (image) thumbnail formats
|
61
|
+
# @return [Array] thumbnail image file extensions
|
62
|
+
def self.image_formats
|
63
|
+
%w(jpg jpeg png)
|
55
64
|
end
|
56
65
|
end
|
data/lib/filepreviews/http.rb
CHANGED
@@ -22,6 +22,7 @@ module Filepreviews
|
|
22
22
|
Faraday.new(url: url) do |conn|
|
23
23
|
conn.adapter :typhoeus
|
24
24
|
conn.headers[:user_agent] = USER_AGENT
|
25
|
+
conn.headers[:content_type] = 'application/json'
|
25
26
|
configure_api_auth_header(conn.headers)
|
26
27
|
configure_logger(conn) if debug
|
27
28
|
end
|
@@ -47,15 +48,17 @@ module Filepreviews
|
|
47
48
|
# @return [Hash<Symbol>] processed parameters
|
48
49
|
def prepare_request(params)
|
49
50
|
request = process_params(params)
|
50
|
-
request.store(:
|
51
|
+
request.store(:sizes, [extract_size(params.size)]) if params.size
|
52
|
+
request.store(:format, params.format) if params.format
|
51
53
|
request
|
52
54
|
end
|
53
55
|
|
54
56
|
# Returns parsed response from API
|
55
57
|
# @return [Filepreviews::Response] json response as callable methods
|
56
58
|
def fetch(params)
|
59
|
+
options = prepare_request(params)
|
57
60
|
response = default_connection(API_URL, params.debug)
|
58
|
-
.
|
61
|
+
.post { |req| req.body = JSON.generate(options) }
|
59
62
|
parse(response.body)
|
60
63
|
end
|
61
64
|
|
data/lib/filepreviews/utils.rb
CHANGED
data/lib/filepreviews/version.rb
CHANGED
@@ -23,7 +23,10 @@ describe Filepreviews::HTTP do
|
|
23
23
|
|
24
24
|
describe 'configure_api_auth_header' do
|
25
25
|
before(:each) { Filepreviews.api_key = nil }
|
26
|
-
header = {
|
26
|
+
header = {
|
27
|
+
'User-Agent' => "Filepreviews-Rubygem/#{Filepreviews::VERSION}",
|
28
|
+
'Content-Type' => 'application/json'
|
29
|
+
}
|
27
30
|
|
28
31
|
context 'when api_key is set' do
|
29
32
|
it 'configures the X-API-KEY header' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filepreviews
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonah Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|