mustachio 0.1.1
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.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +28 -0
- data/Gemfile.lock +94 -0
- data/LICENSE.txt +20 -0
- data/README.md +3 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bookmarklet.js +18 -0
- data/config.ru +13 -0
- data/lib/mustachio.rb +102 -0
- data/mustachio.gemspec +105 -0
- data/public/favicon.ico +0 -0
- data/public/images/dubya.jpeg +0 -0
- data/public/images/guy_hecker.jpeg +0 -0
- data/public/images/mustache_03.png +0 -0
- data/spec/fixtures/vcr_cassettes/big_obama.yml +7044 -0
- data/spec/fixtures/vcr_cassettes/dubya.yml +378 -0
- data/spec/fixtures/vcr_cassettes/small_obama.yml +903 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/big_obama.jpeg +0 -0
- data/spec/support/dubya.jpeg +0 -0
- data/spec/support/small_obama.jpeg +0 -0
- data/spec/unit/analyser_spec.rb +75 -0
- data/views/face_api_dev_challenge.haml +69 -0
- data/views/ga.haml +12 -0
- data/views/index.haml +10 -0
- metadata +301 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
ENV['RACK_ENV'] ||= 'test'
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
Bundler.require
|
6
|
+
|
7
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
8
|
+
require 'mustachio'
|
9
|
+
require 'webmock/rspec'
|
10
|
+
require 'vcr'
|
11
|
+
|
12
|
+
Mustachio.set :environment, :test
|
13
|
+
|
14
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
15
|
+
# in spec/support/ and its subdirectories.
|
16
|
+
Dir[File.join('spec', 'support', '**', '*.rb')].each {|f| require f}
|
17
|
+
|
18
|
+
VCR.config do |c|
|
19
|
+
c.cassette_library_dir = File.join(File.dirname(__FILE__), 'fixtures', 'vcr_cassettes')
|
20
|
+
c.stub_with :webmock # or :fakeweb
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
# == Mock Framework
|
25
|
+
#
|
26
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
27
|
+
#
|
28
|
+
# config.mock_with :mocha
|
29
|
+
# config.mock_with :flexmock
|
30
|
+
# config.mock_with :rr
|
31
|
+
config.mock_with :rspec
|
32
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# P.S. I'm pretty sure it's spelled "analyZer", but I'm staying consistent w/ Dragonfly
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "retrieving face data" do
|
5
|
+
def get_photo(filename='dubya.jpeg')
|
6
|
+
image_url = "http://www.foo.com/#{filename}"
|
7
|
+
image_path = File.join(File.dirname(__FILE__), '..', 'support', filename)
|
8
|
+
stub_request(:get, image_url).to_return(:body => File.new(image_path))
|
9
|
+
|
10
|
+
Magickly.dragonfly.fetch(image_url)
|
11
|
+
end
|
12
|
+
|
13
|
+
def face_data(filename='dubya.jpeg')
|
14
|
+
photo = get_photo(filename)
|
15
|
+
data = nil
|
16
|
+
VCR.use_cassette( filename.chomp(File.extname(filename)) ) do
|
17
|
+
data = photo.face_data
|
18
|
+
end
|
19
|
+
|
20
|
+
data
|
21
|
+
end
|
22
|
+
|
23
|
+
def face_data_as_px(filename='dubya.jpeg')
|
24
|
+
photo = get_photo(filename)
|
25
|
+
data = nil
|
26
|
+
VCR.use_cassette( filename.chomp(File.extname(filename)) ) do
|
27
|
+
data = photo.face_data_as_px
|
28
|
+
end
|
29
|
+
|
30
|
+
data
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#face_data" do
|
34
|
+
it "should give similar results for small and large photos" do
|
35
|
+
big_obama_data = face_data('big_obama.jpeg')
|
36
|
+
small_obama_data = face_data('small_obama.jpeg')
|
37
|
+
|
38
|
+
big_eye_x = big_obama_data['tags'].first['eye_right']['x']
|
39
|
+
small_eye_x = small_obama_data['tags'].first['eye_right']['x']
|
40
|
+
|
41
|
+
big_eye_x.should be_kind_of Float
|
42
|
+
small_eye_x.should be_kind_of Float
|
43
|
+
|
44
|
+
# compare positioning (percentages)
|
45
|
+
small_eye_x.should be_within(1.0).of(small_eye_x)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#face_data_as_px" do
|
50
|
+
it "should not scale a photo smaller than 900px" do
|
51
|
+
image = get_photo
|
52
|
+
image.height.should eq 300
|
53
|
+
|
54
|
+
VCR.use_cassette('dubya') do
|
55
|
+
image.face_data_as_px['height'].should eq 300
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should scale the detection areas proportionally for large photos" do
|
60
|
+
big_obama_data = face_data_as_px('big_obama.jpeg')
|
61
|
+
small_obama_data = face_data_as_px('small_obama.jpeg')
|
62
|
+
|
63
|
+
big_eye_x = big_obama_data['tags'].first['eye_right']['x']
|
64
|
+
small_eye_x = small_obama_data['tags'].first['eye_right']['x']
|
65
|
+
|
66
|
+
big_eye_x.should be_kind_of Float
|
67
|
+
small_eye_x.should be_kind_of Float
|
68
|
+
big_eye_x.should_not be_within(1.0).of(small_eye_x)
|
69
|
+
|
70
|
+
scale = big_obama_data['width'] / small_obama_data['width'].to_f
|
71
|
+
# compare positioning (px)
|
72
|
+
big_eye_x.should be_within(5.0).of(small_eye_x * scale)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title Face.com Developer Challenge Submission
|
5
|
+
%link{:href => 'http://fonts.googleapis.com/css?family=Bentham|IM+Fell+English+SC|OFL+Sorts+Mill+Goudy+TT|Oswald|Ultra', :rel=> 'stylesheet', :type => 'text/css'}
|
6
|
+
:css
|
7
|
+
body {
|
8
|
+
background-color: #E3CBA8;
|
9
|
+
color: #4F4841;
|
10
|
+
font-family: 'OFL Sorts Mill Goudy TT', arial, serif;
|
11
|
+
}
|
12
|
+
.wrapper {
|
13
|
+
border: 2px dotted #4F4841;
|
14
|
+
padding: 20px;
|
15
|
+
width: 600px;
|
16
|
+
margin: auto;
|
17
|
+
}
|
18
|
+
h1 {
|
19
|
+
text-align: center;
|
20
|
+
font-size: 6em;
|
21
|
+
font-family: 'Oswald', arial, serif;
|
22
|
+
}
|
23
|
+
h2 {
|
24
|
+
text-align: center;
|
25
|
+
font-family: 'Ultra', arial, serif;
|
26
|
+
}
|
27
|
+
body h1:first-child {
|
28
|
+
margin: 0;
|
29
|
+
}
|
30
|
+
p {
|
31
|
+
font-style: italic;
|
32
|
+
}
|
33
|
+
hr {
|
34
|
+
width: 15%;
|
35
|
+
color: #4F4841;
|
36
|
+
border: 1px solid #4F4841;
|
37
|
+
}
|
38
|
+
.im-fell {
|
39
|
+
font-style: normal;
|
40
|
+
font-family: 'IM Fell English SC', arial, serif;
|
41
|
+
font-size: 1.8em;
|
42
|
+
}
|
43
|
+
.bentham {
|
44
|
+
font-family: 'Bentham', arial, serif;
|
45
|
+
font-style: normal;
|
46
|
+
}
|
47
|
+
#guy-hecker {
|
48
|
+
display: block;
|
49
|
+
margin: auto;
|
50
|
+
width: 204px;
|
51
|
+
}
|
52
|
+
= haml :ga
|
53
|
+
%body
|
54
|
+
.wrapper
|
55
|
+
%h1 NOTICE
|
56
|
+
%p
|
57
|
+
In the entire history of photography, countless photographs of friends and loved ones have remained common and humdrum. We, the people, say:
|
58
|
+
%h2 This will not stand.
|
59
|
+
%p
|
60
|
+
On this, the fifteenth day of May, 2011: I, Aidan Feldman, declare my intent to build the mobile application by the name of "mustachio", with intent to settle this score.
|
61
|
+
%p
|
62
|
+
%span.im-fell In said application,
|
63
|
+
upon the taking of a digital photograph, all faces are detected and mustaches are applied forthwith, endowing instant poise and panache to otherwise colloquial subjects, all before one can proclaim "<a href='http://en.wikipedia.org/wiki/Ambrose_Burnside'>Ambrose Burnside</a>". These properly whiskered photos are then suitable to be shared with acquaintances and cohorts across the globe, which can then be accomplished from within the comfort of "mustachio".
|
64
|
+
%hr
|
65
|
+
.separator
|
66
|
+
%p.bentham
|
67
|
+
An application by the same name has been constructed for the world wide web - see
|
68
|
+
%a{:href => 'https://github.com/afeld/mustachio'} https://github.com/afeld/mustachio
|
69
|
+
%img#guy-hecker{:src => '/images/guy_hecker.jpeg', :alt => ''}
|
data/views/ga.haml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
:javascript
|
2
|
+
var _gaq = _gaq || [];
|
3
|
+
_gaq.push(['_setAccount', 'UA-23374334-1']);
|
4
|
+
_gaq.push(['_setDomainName', 'none']);
|
5
|
+
_gaq.push(['_setAllowLinker', true]);
|
6
|
+
_gaq.push(['_trackPageview']);
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
10
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
11
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
12
|
+
})();
|
data/views/index.haml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title mustachio
|
5
|
+
= haml :ga
|
6
|
+
%body
|
7
|
+
%a{:href => "http://github.com/afeld/mustachio"}
|
8
|
+
%img{:style => "position: absolute; top: 0; right: 0; border: 0;", :src => "https://d3nwyuy0nl342s.cloudfront.net/img/7afbc8b248c68eb468279e8c17986ad46549fb71/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67", :alt => "Fork me on GitHub"}
|
9
|
+
%img{:src => "/?src=http://www.librarising.com/astrology/celebs/images2/QR/queenelizabethii.jpg"}
|
10
|
+
%h1 #{@site}/?src=<em>YOUR_IMAGE_URL</em>
|
metadata
ADDED
@@ -0,0 +1,301 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mustachio
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Aidan Feldman
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-16 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
hash: 25
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 3
|
31
|
+
version: 1.2.3
|
32
|
+
type: :runtime
|
33
|
+
requirement: *id001
|
34
|
+
prerelease: false
|
35
|
+
name: sinatra
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ~>
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 59
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
- 9
|
46
|
+
- 0
|
47
|
+
version: 0.9.0
|
48
|
+
type: :runtime
|
49
|
+
requirement: *id002
|
50
|
+
prerelease: false
|
51
|
+
name: dragonfly
|
52
|
+
- !ruby/object:Gem::Dependency
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ~>
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
hash: 13
|
59
|
+
segments:
|
60
|
+
- 1
|
61
|
+
- 1
|
62
|
+
version: "1.1"
|
63
|
+
type: :runtime
|
64
|
+
requirement: *id003
|
65
|
+
prerelease: false
|
66
|
+
name: magickly
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 15
|
74
|
+
segments:
|
75
|
+
- 2
|
76
|
+
- 2
|
77
|
+
- 4
|
78
|
+
version: 2.2.4
|
79
|
+
type: :runtime
|
80
|
+
requirement: *id004
|
81
|
+
prerelease: false
|
82
|
+
name: addressable
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
|
+
type: :runtime
|
94
|
+
requirement: *id005
|
95
|
+
prerelease: false
|
96
|
+
name: haml
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - "="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 23
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
- 0
|
107
|
+
- 4
|
108
|
+
version: 0.0.4
|
109
|
+
type: :runtime
|
110
|
+
requirement: *id006
|
111
|
+
prerelease: false
|
112
|
+
name: face
|
113
|
+
- !ruby/object:Gem::Dependency
|
114
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ~>
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 9
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
- 1
|
123
|
+
version: "0.1"
|
124
|
+
type: :runtime
|
125
|
+
requirement: *id007
|
126
|
+
prerelease: false
|
127
|
+
name: imagesize
|
128
|
+
- !ruby/object:Gem::Dependency
|
129
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ~>
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
hash: 3
|
135
|
+
segments:
|
136
|
+
- 1
|
137
|
+
- 6
|
138
|
+
version: "1.6"
|
139
|
+
type: :development
|
140
|
+
requirement: *id008
|
141
|
+
prerelease: false
|
142
|
+
name: jeweler
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
hash: 3
|
150
|
+
segments:
|
151
|
+
- 0
|
152
|
+
version: "0"
|
153
|
+
type: :development
|
154
|
+
requirement: *id009
|
155
|
+
prerelease: false
|
156
|
+
name: rack-test
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ~>
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
hash: 9
|
164
|
+
segments:
|
165
|
+
- 2
|
166
|
+
- 5
|
167
|
+
version: "2.5"
|
168
|
+
type: :development
|
169
|
+
requirement: *id010
|
170
|
+
prerelease: false
|
171
|
+
name: rspec
|
172
|
+
- !ruby/object:Gem::Dependency
|
173
|
+
version_requirements: &id011 !ruby/object:Gem::Requirement
|
174
|
+
none: false
|
175
|
+
requirements:
|
176
|
+
- - ~>
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
hash: 3
|
179
|
+
segments:
|
180
|
+
- 1
|
181
|
+
- 6
|
182
|
+
version: "1.6"
|
183
|
+
type: :development
|
184
|
+
requirement: *id011
|
185
|
+
prerelease: false
|
186
|
+
name: webmock
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
version_requirements: &id012 !ruby/object:Gem::Requirement
|
189
|
+
none: false
|
190
|
+
requirements:
|
191
|
+
- - ~>
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
hash: 29
|
194
|
+
segments:
|
195
|
+
- 1
|
196
|
+
- 9
|
197
|
+
version: "1.9"
|
198
|
+
type: :development
|
199
|
+
requirement: *id012
|
200
|
+
prerelease: false
|
201
|
+
name: vcr
|
202
|
+
- !ruby/object:Gem::Dependency
|
203
|
+
version_requirements: &id013 !ruby/object:Gem::Requirement
|
204
|
+
none: false
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
hash: 3
|
209
|
+
segments:
|
210
|
+
- 0
|
211
|
+
version: "0"
|
212
|
+
type: :development
|
213
|
+
requirement: *id013
|
214
|
+
prerelease: false
|
215
|
+
name: ruby-debug19
|
216
|
+
- !ruby/object:Gem::Dependency
|
217
|
+
version_requirements: &id014 !ruby/object:Gem::Requirement
|
218
|
+
none: false
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
hash: 3
|
223
|
+
segments:
|
224
|
+
- 0
|
225
|
+
version: "0"
|
226
|
+
type: :development
|
227
|
+
requirement: *id014
|
228
|
+
prerelease: false
|
229
|
+
name: ruby-debug
|
230
|
+
description: Adds a 'mustachify' shortcut to magickly.
|
231
|
+
email: aidan.feldman@gmail.com
|
232
|
+
executables: []
|
233
|
+
|
234
|
+
extensions: []
|
235
|
+
|
236
|
+
extra_rdoc_files:
|
237
|
+
- LICENSE.txt
|
238
|
+
- README.md
|
239
|
+
files:
|
240
|
+
- .document
|
241
|
+
- .rspec
|
242
|
+
- Gemfile
|
243
|
+
- Gemfile.lock
|
244
|
+
- LICENSE.txt
|
245
|
+
- README.md
|
246
|
+
- Rakefile
|
247
|
+
- VERSION
|
248
|
+
- bookmarklet.js
|
249
|
+
- config.ru
|
250
|
+
- lib/mustachio.rb
|
251
|
+
- mustachio.gemspec
|
252
|
+
- public/favicon.ico
|
253
|
+
- public/images/dubya.jpeg
|
254
|
+
- public/images/guy_hecker.jpeg
|
255
|
+
- public/images/mustache_03.png
|
256
|
+
- spec/fixtures/vcr_cassettes/big_obama.yml
|
257
|
+
- spec/fixtures/vcr_cassettes/dubya.yml
|
258
|
+
- spec/fixtures/vcr_cassettes/small_obama.yml
|
259
|
+
- spec/spec_helper.rb
|
260
|
+
- spec/support/big_obama.jpeg
|
261
|
+
- spec/support/dubya.jpeg
|
262
|
+
- spec/support/small_obama.jpeg
|
263
|
+
- spec/unit/analyser_spec.rb
|
264
|
+
- views/face_api_dev_challenge.haml
|
265
|
+
- views/ga.haml
|
266
|
+
- views/index.haml
|
267
|
+
homepage: http://github.com/afeld/mustachio
|
268
|
+
licenses:
|
269
|
+
- MIT
|
270
|
+
post_install_message:
|
271
|
+
rdoc_options: []
|
272
|
+
|
273
|
+
require_paths:
|
274
|
+
- lib
|
275
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
276
|
+
none: false
|
277
|
+
requirements:
|
278
|
+
- - ">="
|
279
|
+
- !ruby/object:Gem::Version
|
280
|
+
hash: 3
|
281
|
+
segments:
|
282
|
+
- 0
|
283
|
+
version: "0"
|
284
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
|
+
none: false
|
286
|
+
requirements:
|
287
|
+
- - ">="
|
288
|
+
- !ruby/object:Gem::Version
|
289
|
+
hash: 3
|
290
|
+
segments:
|
291
|
+
- 0
|
292
|
+
version: "0"
|
293
|
+
requirements: []
|
294
|
+
|
295
|
+
rubyforge_project:
|
296
|
+
rubygems_version: 1.8.2
|
297
|
+
signing_key:
|
298
|
+
specification_version: 3
|
299
|
+
summary: automatic mustachifying of any image
|
300
|
+
test_files: []
|
301
|
+
|