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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6eb1b65fbd4cf5f20021e4950f0d4df73d015591
4
- data.tar.gz: 227b55edc016cbbf490beb865ac33268acfbbaf0
3
+ metadata.gz: 42c0103985289f8faa7d99d4860b8f921ba60f47
4
+ data.tar.gz: 1eaadf4c3e6fae2bfed7a1a7c7a64f4dde0fcd1e
5
5
  SHA512:
6
- metadata.gz: 1a30644834d46ef94d4f769202cf466442c8e7089fba78407836ae791c7ee14ac9b875d2396b510639d14ffb28d81bb3a59b1f2ef32a45f5ff8d90da1cb66052
7
- data.tar.gz: 74645e901e21768c4f4f9c060e86cb1220d356896fe3828d97d0f667eed7a55c3395cb9902cbd302587eca225027fe0f07d596a1cfdc12a7fbca45fcae03d7b6
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
- [![Build Status](https://travis-ci.org/jonahoffline/filepreviews-ruby.svg)](https://travis-ci.org/jonahoffline/filepreviews-ruby)
3
- [![Gem Version](https://badge.fury.io/rb/filepreviews.svg)](http://badge.fury.io/rb/filepreviews)
4
- [![Dependency Status](https://gemnasium.com/jonahoffline/filepreviews-ruby.svg)](https://gemnasium.com/jonahoffline/filepreviews-ruby)
5
- [![Code Climate](https://codeclimate.com/github/jonahoffline/filepreviews-ruby.png)](https://codeclimate.com/github/jonahoffline/filepreviews-ruby)
6
- [![Inline docs](http://inch-pages.github.io/github/jonahoffline/filepreviews-ruby.png)](http://inch-pages.github.io/github/jonahoffline/filepreviews-ruby)
7
- [![Gitter chat](https://badges.gitter.im/jonahoffline/filepreviews-ruby.png)](https://gitter.im/jonahoffline/filepreviews-ruby)
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
- options = {
77
- size: {
78
- width: 100,
79
- height: 999
80
- },
81
- # supported: 'exif', 'ocr', 'psd' or 'all' which means everything
82
- metadata: ['exif', 'ocr', 'psd']
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, options)
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://badges.gitter.im/jonahoffline/filepreviews-ruby.png)](https://gitter.im/jonahoffline/filepreviews-ruby)
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
@@ -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(:size, extract_size(params.size)) if params.size
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
- .get nil, prepare_request(params)
61
+ .post { |req| req.body = JSON.generate(options) }
59
62
  parse(response.body)
60
63
  end
61
64
 
@@ -32,7 +32,7 @@ module Filepreviews
32
32
  def process_params(params)
33
33
  {
34
34
  url: CGI.unescape(params.url),
35
- metadata: extract_metadata(params.metadata)
35
+ metadata: [extract_metadata(params.metadata)]
36
36
  }
37
37
  end
38
38
  end
@@ -1,5 +1,5 @@
1
1
  # @author Jonah Ruiz <jonah@pixelhipsters.com>
2
2
  # Contains the version namespaced
3
3
  module Filepreviews
4
- VERSION = '1.1.0'
4
+ VERSION = '1.2.0'
5
5
  end
@@ -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 = { 'User-Agent' => "Filepreviews-Rubygem/#{Filepreviews::VERSION}" }
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
@@ -14,7 +14,7 @@ describe Filepreviews::Utils do
14
14
  params = OpenStruct.new(url: url, metadata: ['png'])
15
15
 
16
16
  expect(kawaii.process_params(params))
17
- .to eq(url: url, metadata: 'png')
17
+ .to eq(url: url, metadata: ['png'])
18
18
  end
19
19
  end
20
20
 
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.1.0
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-16 00:00:00.000000000 Z
11
+ date: 2014-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler