snapshot-ruby 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/snapshot/image.rb +10 -5
- data/lib/snapshot/url.rb +5 -5
- data/lib/snapshot/version.rb +1 -1
- data/lib/snapshot.rb +1 -1
- metadata +4 -30
data/lib/snapshot/image.rb
CHANGED
@@ -3,7 +3,11 @@ require 'rest_client'
|
|
3
3
|
|
4
4
|
module Snapshot
|
5
5
|
class Image
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :filesize, :format, :height, :id, :last_accessed_at,
|
7
|
+
:uploaded_at, :width
|
8
|
+
|
9
|
+
# To make it more ActiveRecord like
|
10
|
+
alias_method :created_at, :uploaded_at
|
7
11
|
|
8
12
|
class << self
|
9
13
|
# Uploads a file to the connected Snapshot account.
|
@@ -27,11 +31,11 @@ module Snapshot
|
|
27
31
|
info = JSON.parse(result)['file']
|
28
32
|
|
29
33
|
self.new.tap do |img|
|
30
|
-
img.created_at = Time.at(info['uploaded_at'].to_i)
|
31
34
|
img.filesize = info['size'].to_i
|
32
35
|
img.format = info['type']
|
33
36
|
img.height = info['height'].to_i
|
34
37
|
img.id = info['id']
|
38
|
+
img.uploaded_at = Time.at(info['uploaded_at'].to_i)
|
35
39
|
img.width = info['width'].to_i
|
36
40
|
end
|
37
41
|
end
|
@@ -65,11 +69,12 @@ module Snapshot
|
|
65
69
|
info = JSON.parse(result)
|
66
70
|
|
67
71
|
self.new.tap do |img|
|
68
|
-
img.created_at = Time.at(info['uploaded_at'].to_i)
|
69
72
|
img.filesize = info['size'].to_i
|
70
73
|
img.format = info['type']
|
71
74
|
img.height = info['height'].to_i
|
72
75
|
img.id = info['id']
|
76
|
+
img.last_accessed_at = Time.at(info['last_accessed_at'].to_i)
|
77
|
+
img.uploaded_at = Time.at(info['uploaded_at'].to_i)
|
73
78
|
img.width = info['width'].to_i
|
74
79
|
end
|
75
80
|
rescue RestClient::ResourceNotFound
|
@@ -106,8 +111,8 @@ module Snapshot
|
|
106
111
|
|
107
112
|
def extension
|
108
113
|
case self.format
|
109
|
-
when 'JPEG' then '
|
110
|
-
when 'PNG' then '
|
114
|
+
when 'JPEG' then 'jpg'
|
115
|
+
when 'PNG' then 'png'
|
111
116
|
end
|
112
117
|
end
|
113
118
|
|
data/lib/snapshot/url.rb
CHANGED
@@ -9,14 +9,14 @@ module Snapshot
|
|
9
9
|
tap(&block) if block_given?
|
10
10
|
end
|
11
11
|
|
12
|
-
def method_missing(
|
13
|
-
@options << [
|
12
|
+
def method_missing(processor, *options)
|
13
|
+
@options << [processor.to_s, options]
|
14
14
|
end
|
15
15
|
|
16
16
|
def to_s
|
17
|
-
|
18
|
-
|
19
|
-
Snapshot.connection.url
|
17
|
+
options = @options.flatten
|
18
|
+
options << '' unless options.empty?
|
19
|
+
"#{Snapshot.connection.url}#{options.join('/')}#{id}.#{extension}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/snapshot/version.rb
CHANGED
data/lib/snapshot.rb
CHANGED
metadata
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snapshot-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
version: "0.1"
|
4
|
+
prerelease:
|
5
|
+
version: "0.2"
|
9
6
|
platform: ruby
|
10
7
|
authors:
|
11
8
|
- Jeremy Boles
|
@@ -13,8 +10,7 @@ autorequire:
|
|
13
10
|
bindir: bin
|
14
11
|
cert_chain: []
|
15
12
|
|
16
|
-
date: 2011-
|
17
|
-
default_executable:
|
13
|
+
date: 2011-06-02 00:00:00 Z
|
18
14
|
dependencies:
|
19
15
|
- !ruby/object:Gem::Dependency
|
20
16
|
name: json
|
@@ -24,10 +20,6 @@ dependencies:
|
|
24
20
|
requirements:
|
25
21
|
- - "="
|
26
22
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 1
|
29
|
-
- 4
|
30
|
-
- 6
|
31
23
|
version: 1.4.6
|
32
24
|
type: :runtime
|
33
25
|
version_requirements: *id001
|
@@ -39,10 +31,6 @@ dependencies:
|
|
39
31
|
requirements:
|
40
32
|
- - "="
|
41
33
|
- !ruby/object:Gem::Version
|
42
|
-
segments:
|
43
|
-
- 1
|
44
|
-
- 6
|
45
|
-
- 1
|
46
34
|
version: 1.6.1
|
47
35
|
type: :runtime
|
48
36
|
version_requirements: *id002
|
@@ -54,9 +42,6 @@ dependencies:
|
|
54
42
|
requirements:
|
55
43
|
- - "="
|
56
44
|
- !ruby/object:Gem::Version
|
57
|
-
segments:
|
58
|
-
- 1
|
59
|
-
- 3
|
60
45
|
version: "1.3"
|
61
46
|
type: :development
|
62
47
|
version_requirements: *id003
|
@@ -68,10 +53,6 @@ dependencies:
|
|
68
53
|
requirements:
|
69
54
|
- - "="
|
70
55
|
- !ruby/object:Gem::Version
|
71
|
-
segments:
|
72
|
-
- 2
|
73
|
-
- 4
|
74
|
-
- 0
|
75
56
|
version: 2.4.0
|
76
57
|
type: :development
|
77
58
|
version_requirements: *id004
|
@@ -91,7 +72,6 @@ files:
|
|
91
72
|
- lib/snapshot/version.rb
|
92
73
|
- lib/snapshot.rb
|
93
74
|
- README.md
|
94
|
-
has_rdoc: true
|
95
75
|
homepage: https://github.com/jeremyboles/snapshot-ruby
|
96
76
|
licenses: []
|
97
77
|
|
@@ -105,23 +85,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
85
|
requirements:
|
106
86
|
- - ">="
|
107
87
|
- !ruby/object:Gem::Version
|
108
|
-
segments:
|
109
|
-
- 0
|
110
88
|
version: "0"
|
111
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
90
|
none: false
|
113
91
|
requirements:
|
114
92
|
- - ">="
|
115
93
|
- !ruby/object:Gem::Version
|
116
|
-
segments:
|
117
|
-
- 1
|
118
|
-
- 3
|
119
|
-
- 7
|
120
94
|
version: 1.3.7
|
121
95
|
requirements: []
|
122
96
|
|
123
97
|
rubyforge_project: snapshot-ruby
|
124
|
-
rubygems_version: 1.
|
98
|
+
rubygems_version: 1.8.2
|
125
99
|
signing_key:
|
126
100
|
specification_version: 3
|
127
101
|
summary: Ruby wrapper for storing and manipulating images via Snapshot.
|