picfit 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c442064d0c59868a391f192a9763a0a98eabb4fd
4
- data.tar.gz: e9278df0364f51f76751aec27669299f1e900014
3
+ metadata.gz: b14d9ac68816da66c9a6cb1189e970c7965d1894
4
+ data.tar.gz: 343d149f0145bae89cf14e63469c59ef067418e3
5
5
  SHA512:
6
- metadata.gz: e5c528a70d3e552fab005c32ba9d1fb97b4024712a52a4656671ee07abe34e878de296390442f5a10df4a010a3ddacb4328f131805d0f75ef899d4f0dc537504
7
- data.tar.gz: 0029a7d6acaceacae49af28b5331c86cd5634e31d0f28089b08212acfa8b4833bda2dda6082dd551ec7b8768de505debaaf592583c165fe0286e25ea148b4567
6
+ metadata.gz: 6a617af09bd767d9b8605f3c93f57d76b8eea41f960738e17b74332b4521eecc10e2670c71b8139ebea227a534ee6bac6170c50987b4445ff07b9db8c954d02a
7
+ data.tar.gz: 8b954a26f0933a76f5873228a50cf23547ffaa28d853b98f5dc5a2becf0af61866b0a815e3fe08724e96a976a60263ceeaaab6f0b7849b15bd3943b8c45adca8
@@ -53,15 +53,25 @@ module Picfit
53
53
  result[param_key] = options[key] if options[key]
54
54
  result
55
55
  end
56
- # Create a query string from the params
57
- query_string = params.map{|k,v| [CGI.escape(k.to_s), "=", CGI.escape(v.to_s)]}.map(&:join).join("&")
58
- if secret_key
59
- # lets use << instead of + or interpolation
60
- query_string << "&sig="
61
- query_string << sign_string(secret_key, query_string)
56
+
57
+ if options[:query_string]
58
+ # Create a query params array from the params
59
+ query_string = params.map{|k,v| [CGI.escape(k.to_s), "=", CGI.escape(v.to_s)]}.map(&:join).join("&")
60
+ if secret_key
61
+ # lets use << instead of + or interpolation
62
+ query_string << "&sig="
63
+ query_string << sign_string(secret_key, query_string)
64
+ end
65
+ else
66
+ path << ["", params[:op], [params[:w].to_s, params[:h].to_s].join('x'), params[:path]].join("/")
67
+ end
68
+
69
+ if query_string
70
+ path << "?"
71
+ path << query_string
62
72
  end
63
- path << "?"
64
- path << query_string
73
+
74
+ path
65
75
  end
66
76
 
67
77
  def sign_string(secret_key, query_string)
@@ -75,4 +85,4 @@ module Picfit
75
85
  end
76
86
 
77
87
  end
78
- end
88
+ end
@@ -5,11 +5,13 @@ module Picfit
5
5
  :base_url,
6
6
  :method,
7
7
  :secret_key,
8
+ :query_string
8
9
  ].freeze
9
10
 
10
- DEFAULT_METHOD = :display
11
- DEFAULT_BASE_URL = ""
12
- DEFAULT_SECRET_KEY = nil
11
+ DEFAULT_METHOD = :display
12
+ DEFAULT_BASE_URL = ""
13
+ DEFAULT_SECRET_KEY = nil
14
+ DEFAULT_QUERY_STRING = false
13
15
 
14
16
  attr_accessor *VALID_OPTIONS_KEYS
15
17
 
@@ -35,6 +37,7 @@ module Picfit
35
37
  self.base_url = DEFAULT_BASE_URL
36
38
  self.method = DEFAULT_METHOD
37
39
  self.secret_key = DEFAULT_SECRET_KEY
40
+ self.query_string = DEFAULT_QUERY_STRING
38
41
  end
39
42
  end
40
- end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module Picfit
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picfit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgar Gonzalez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-17 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler