sss-ruby 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sss-ruby/builder.rb +27 -0
- data/lib/sss-ruby/helpers.rb +17 -0
- data/lib/sss-ruby/main.rb +38 -0
- data/lib/sss-ruby/rails.rb +3 -0
- data/lib/sss-ruby.rb +4 -0
- metadata +50 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'querystring'
|
2
|
+
|
3
|
+
module ScreenshotShark
|
4
|
+
|
5
|
+
class Builder
|
6
|
+
|
7
|
+
# Create new instance with options
|
8
|
+
def initialize options
|
9
|
+
@options = options
|
10
|
+
end
|
11
|
+
|
12
|
+
# Build screenshot URL
|
13
|
+
def build_url
|
14
|
+
defaults = {
|
15
|
+
:key => ScreenshotShark.api_key,
|
16
|
+
:url => 'http://www.google.com/',
|
17
|
+
:op => 'r:200:120'
|
18
|
+
}
|
19
|
+
options = defaults.merge @options
|
20
|
+
options[:token] = ScreenshotShark.hash options
|
21
|
+
qs = QueryString.stringify options
|
22
|
+
"http://screenshotshark.com/capture?#{qs}"
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module ScreenshotShark
|
2
|
+
module Helpers
|
3
|
+
|
4
|
+
# Create an image URL for the specified website
|
5
|
+
def sss_image_url url, options = {}
|
6
|
+
options[:url] = url
|
7
|
+
Builder.new(options).build_url()
|
8
|
+
end
|
9
|
+
|
10
|
+
# Create an image tag for the specified website
|
11
|
+
def sss_image_tag url, options = {}
|
12
|
+
options[:url] = url
|
13
|
+
url = Builder.new(options).build_url()
|
14
|
+
'<img src="#{url}">'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
3
|
+
module ScreenshotShark
|
4
|
+
|
5
|
+
# Cheap singleton
|
6
|
+
extend self
|
7
|
+
|
8
|
+
# Set API and secret keys
|
9
|
+
def config api_key, secret
|
10
|
+
self.api_key = api_key
|
11
|
+
self.secret = secret
|
12
|
+
end
|
13
|
+
|
14
|
+
def api_key= api_key
|
15
|
+
@api_key = api_key
|
16
|
+
end
|
17
|
+
|
18
|
+
def api_key
|
19
|
+
raise 'API key not set.' unless @api_key
|
20
|
+
@api_key
|
21
|
+
end
|
22
|
+
|
23
|
+
def secret= secret
|
24
|
+
@secret = secret
|
25
|
+
end
|
26
|
+
|
27
|
+
def secret
|
28
|
+
raise 'Secret key not set.' unless @secret
|
29
|
+
@secret
|
30
|
+
end
|
31
|
+
|
32
|
+
# Build a HMAC-SHA1 hash for token
|
33
|
+
def hash options
|
34
|
+
h = "#{options[:key]}:#{options[:url]}:#{options[:op]}"
|
35
|
+
OpenSSL::HMAC.hexdigest('sha1', self.secret, h)
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/lib/sss-ruby.rb
ADDED
metadata
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sss-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mike Holly
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-10 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ScreenshotShark API for Ruby
|
15
|
+
email:
|
16
|
+
- mikejholly@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/sss-ruby/builder.rb
|
22
|
+
- lib/sss-ruby/helpers.rb
|
23
|
+
- lib/sss-ruby/main.rb
|
24
|
+
- lib/sss-ruby/rails.rb
|
25
|
+
- lib/sss-ruby.rb
|
26
|
+
homepage: http://screenshotshark.com/
|
27
|
+
licenses: []
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
require_paths:
|
31
|
+
- lib
|
32
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 1.8.23
|
47
|
+
signing_key:
|
48
|
+
specification_version: 3
|
49
|
+
summary: ScreenshotShark
|
50
|
+
test_files: []
|