imagekit 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 302b23641b16ecf025b6f11409465ea105f2cbcf6abc1afdf6a297f3f07449c4
4
+ data.tar.gz: da1ab59bfc20408df78e95f75f95aef9a63dee1bf3de1330a0f7e0866103fe7a
5
+ SHA512:
6
+ metadata.gz: 499bec791c175f0e3de08769593403bacd060be4e3cdfac181e620934d6ec2087d8662b8e18da797780b9ac98c596af9e1eec73ddcc5803c22a6436d5e342140
7
+ data.tar.gz: e267cf7cb804f85948a4ff270b5f9cb12c383cf019019ccc3765fd0213ed455e725afb15b1a571d7fa3eab3a9b58f71d555cc46cd27408775fd403dd62e34c4d
data/lib/imagekit.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "imagekit/version"
2
+ require "imagekit/imagekit"
@@ -0,0 +1,41 @@
1
+ require "cgi"
2
+ require "digest"
3
+ require "json"
4
+
5
+ class ImageKit
6
+ def initialize(url, options = {}, api_key = nil)
7
+ @url = url
8
+ @options = options
9
+ @api_key = api_key
10
+ end
11
+
12
+ def to_s
13
+ "https://api.imagekit.co/screenshot?#{query_string}"
14
+ end
15
+
16
+ class << self
17
+ attr_accessor :api_key
18
+ end
19
+
20
+ private
21
+
22
+ def query_string
23
+ params = params_without_hash
24
+ params[:hash] = hash
25
+ params.map do |k, v|
26
+ "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"
27
+ end.join("&")
28
+ end
29
+
30
+ def hash
31
+ Digest::MD5.hexdigest params_without_hash.to_json + (ImageKit.api_key || api_key)
32
+ end
33
+
34
+ def params_without_hash
35
+ {
36
+ url: @url,
37
+ width: @options[:width].to_s,
38
+ height: @options[:height].to_s
39
+ }.reject { |_k, v| v.strip == "" }
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ class ImageKit
2
+ VERSION = "1.0.0"
3
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: imagekit
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Marc Köhlbrugge
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-01-26 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: hey@marckohlbrugge.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/imagekit.rb
20
+ - lib/imagekit/imagekit.rb
21
+ - lib/imagekit/version.rb
22
+ homepage: https://imagekit.co
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubygems_version: 3.0.3
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Ruby client for imagekit.co
45
+ test_files: []