firefly 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +4 -0
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/firefly.gemspec +8 -2
- data/lib/firefly.rb +2 -0
- data/lib/firefly/server.rb +17 -0
- data/spec/firefly/server_spec.rb +21 -0
- metadata +40 -8
data/HISTORY
CHANGED
data/Rakefile
CHANGED
@@ -18,6 +18,8 @@ begin
|
|
18
18
|
gemspec.add_dependency('dm-aggregates', '~> 1.0.2')
|
19
19
|
gemspec.add_dependency('dm-sqlite-adapter', '~> 1.0.2')
|
20
20
|
gemspec.add_dependency('haml', '~> 3.0.18')
|
21
|
+
gemspec.add_dependency('barby', '~> 0.4.0')
|
22
|
+
gemspec.add_dependency('png', '1.1.0')
|
21
23
|
|
22
24
|
gemspec.add_development_dependency('rspec', '~> 1.3.0')
|
23
25
|
gemspec.add_development_dependency('rack-test', '~> 0.5.4')
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0
|
1
|
+
1.1.0
|
data/firefly.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{firefly}
|
8
|
-
s.version = "1.0
|
8
|
+
s.version = "1.1.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ariejan de Vroom"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-02}
|
13
13
|
s.description = %q{FireFly is a simple URL shortner for personal use. It's powered by Sinatra and can be run with any Rack-capable web server.}
|
14
14
|
s.email = %q{ariejan@ariejan.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -76,6 +76,8 @@ Gem::Specification.new do |s|
|
|
76
76
|
s.add_runtime_dependency(%q<dm-aggregates>, ["~> 1.0.2"])
|
77
77
|
s.add_runtime_dependency(%q<dm-sqlite-adapter>, ["~> 1.0.2"])
|
78
78
|
s.add_runtime_dependency(%q<haml>, ["~> 3.0.18"])
|
79
|
+
s.add_runtime_dependency(%q<barby>, ["~> 0.4.0"])
|
80
|
+
s.add_runtime_dependency(%q<png>, ["= 1.1.0"])
|
79
81
|
s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
|
80
82
|
s.add_development_dependency(%q<rack-test>, ["~> 0.5.4"])
|
81
83
|
else
|
@@ -86,6 +88,8 @@ Gem::Specification.new do |s|
|
|
86
88
|
s.add_dependency(%q<dm-aggregates>, ["~> 1.0.2"])
|
87
89
|
s.add_dependency(%q<dm-sqlite-adapter>, ["~> 1.0.2"])
|
88
90
|
s.add_dependency(%q<haml>, ["~> 3.0.18"])
|
91
|
+
s.add_dependency(%q<barby>, ["~> 0.4.0"])
|
92
|
+
s.add_dependency(%q<png>, ["= 1.1.0"])
|
89
93
|
s.add_dependency(%q<rspec>, ["~> 1.3.0"])
|
90
94
|
s.add_dependency(%q<rack-test>, ["~> 0.5.4"])
|
91
95
|
end
|
@@ -97,6 +101,8 @@ Gem::Specification.new do |s|
|
|
97
101
|
s.add_dependency(%q<dm-aggregates>, ["~> 1.0.2"])
|
98
102
|
s.add_dependency(%q<dm-sqlite-adapter>, ["~> 1.0.2"])
|
99
103
|
s.add_dependency(%q<haml>, ["~> 3.0.18"])
|
104
|
+
s.add_dependency(%q<barby>, ["~> 0.4.0"])
|
105
|
+
s.add_dependency(%q<png>, ["= 1.1.0"])
|
100
106
|
s.add_dependency(%q<rspec>, ["~> 1.3.0"])
|
101
107
|
s.add_dependency(%q<rack-test>, ["~> 0.5.4"])
|
102
108
|
end
|
data/lib/firefly.rb
CHANGED
@@ -7,6 +7,8 @@ require 'dm-core'
|
|
7
7
|
require 'dm-migrations'
|
8
8
|
require 'dm-transactions'
|
9
9
|
require 'dm-aggregates'
|
10
|
+
require 'barby'
|
11
|
+
require 'barby/outputter/png_outputter'
|
10
12
|
|
11
13
|
$:.unshift(File.dirname(__FILE__)) unless
|
12
14
|
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
data/lib/firefly/server.rb
CHANGED
@@ -214,6 +214,23 @@ module Firefly
|
|
214
214
|
YAML::dump(output)
|
215
215
|
end
|
216
216
|
|
217
|
+
# GET /b3d.png
|
218
|
+
#
|
219
|
+
# Return a QR code image
|
220
|
+
get '/:code.png' do
|
221
|
+
@url = Firefly::Url.first(:code => params[:code])
|
222
|
+
|
223
|
+
if @url.nil?
|
224
|
+
status 404
|
225
|
+
"Sorry, that code is unknown."
|
226
|
+
else
|
227
|
+
qr = Barby::QrCode.new(short_url(@url))
|
228
|
+
content_type('image/png')
|
229
|
+
cache_control :public, :max_age => 2592000 # One month
|
230
|
+
body(qr.to_png(:xdim => 15, :margin => 30))
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
217
234
|
# GET /b3d
|
218
235
|
#
|
219
236
|
# Redirect to the shortened URL
|
data/spec/firefly/server_spec.rb
CHANGED
@@ -14,6 +14,27 @@ describe "Firefly" do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
describe "QR Codes" do
|
18
|
+
before(:each) do
|
19
|
+
@url = Firefly::Url.create(:url => 'http://example.com/123', :code => 'alpha')
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return a 200 status" do
|
23
|
+
get '/alpha.png'
|
24
|
+
last_response.should be_ok
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should return a PNG image" do
|
28
|
+
get '/alpha.png'
|
29
|
+
last_response.headers['Content-Type'].should eql('image/png')
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should cache-control to 1 month" do
|
33
|
+
get '/alpha.png'
|
34
|
+
last_response.headers['Cache-Control'].should eql('public, max-age=2592000')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
17
38
|
describe "redirecting" do
|
18
39
|
it "should redirect to the original URL" do
|
19
40
|
fake = Firefly::Url.create(:url => 'http://example.com/123', :code => 'alpha')
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: firefly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
-
- 0
|
9
8
|
- 1
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ariejan de Vroom
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-02 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -130,9 +130,41 @@ dependencies:
|
|
130
130
|
type: :runtime
|
131
131
|
version_requirements: *id007
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
|
-
name:
|
133
|
+
name: barby
|
134
134
|
prerelease: false
|
135
135
|
requirement: &id008 !ruby/object:Gem::Requirement
|
136
|
+
none: false
|
137
|
+
requirements:
|
138
|
+
- - ~>
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
hash: 15
|
141
|
+
segments:
|
142
|
+
- 0
|
143
|
+
- 4
|
144
|
+
- 0
|
145
|
+
version: 0.4.0
|
146
|
+
type: :runtime
|
147
|
+
version_requirements: *id008
|
148
|
+
- !ruby/object:Gem::Dependency
|
149
|
+
name: png
|
150
|
+
prerelease: false
|
151
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
153
|
+
requirements:
|
154
|
+
- - "="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
hash: 19
|
157
|
+
segments:
|
158
|
+
- 1
|
159
|
+
- 1
|
160
|
+
- 0
|
161
|
+
version: 1.1.0
|
162
|
+
type: :runtime
|
163
|
+
version_requirements: *id009
|
164
|
+
- !ruby/object:Gem::Dependency
|
165
|
+
name: rspec
|
166
|
+
prerelease: false
|
167
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
136
168
|
none: false
|
137
169
|
requirements:
|
138
170
|
- - ~>
|
@@ -144,11 +176,11 @@ dependencies:
|
|
144
176
|
- 0
|
145
177
|
version: 1.3.0
|
146
178
|
type: :development
|
147
|
-
version_requirements: *
|
179
|
+
version_requirements: *id010
|
148
180
|
- !ruby/object:Gem::Dependency
|
149
181
|
name: rack-test
|
150
182
|
prerelease: false
|
151
|
-
requirement: &
|
183
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
152
184
|
none: false
|
153
185
|
requirements:
|
154
186
|
- - ~>
|
@@ -160,7 +192,7 @@ dependencies:
|
|
160
192
|
- 4
|
161
193
|
version: 0.5.4
|
162
194
|
type: :development
|
163
|
-
version_requirements: *
|
195
|
+
version_requirements: *id011
|
164
196
|
description: FireFly is a simple URL shortner for personal use. It's powered by Sinatra and can be run with any Rack-capable web server.
|
165
197
|
email: ariejan@ariejan.net
|
166
198
|
executables: []
|