catptcha 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +8 -4
- data/catptcha.gemspec +1 -0
- data/lib/catptcha.rb +1 -1
- data/lib/catptcha/seed.rb +15 -0
- metadata +20 -6
data/README.markdown
CHANGED
@@ -24,14 +24,19 @@ Generate and run the migration.
|
|
24
24
|
ruby script/generate catptcha_migration add_catptcha_tables
|
25
25
|
rake db:migrate
|
26
26
|
|
27
|
+
Run the tests.
|
28
|
+
|
29
|
+
rake db:test:prepare
|
30
|
+
rake catptcha:test
|
31
|
+
|
27
32
|
Seed the images.
|
28
33
|
|
29
34
|
rake catptcha:seed
|
30
35
|
|
31
|
-
|
36
|
+
If you have Amazon S3 configured on Rails boot, you can easily upload the
|
37
|
+
images to your own bucket. Otherwise images are still served from Flickr!
|
32
38
|
|
33
|
-
|
34
|
-
rake catptcha:test
|
39
|
+
./script/runner 'Catptcha::Seed.s3_upload("YOUR_BUCKET_NAME")'
|
35
40
|
|
36
41
|
## Usage
|
37
42
|
|
@@ -60,7 +65,6 @@ There are also tools for implementing an admin/review UI:
|
|
60
65
|
|
61
66
|
## TODO and Known Bugs
|
62
67
|
|
63
|
-
* lacks the ability to store or upload photos to external storage
|
64
68
|
* current implementation is closely tied to ActiveRecord and Flickr
|
65
69
|
|
66
70
|
## Author
|
data/catptcha.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.add_dependency "commonthread-flickr_fu", "0.3.0"
|
12
12
|
s.add_dependency "activerecord", "~>2.3"
|
13
13
|
s.add_dependency "will_paginate"
|
14
|
+
s.add_dependency "aws-s3"
|
14
15
|
s.add_development_dependency "rr"
|
15
16
|
s.authors = ['Zack Hobson']
|
16
17
|
s.files = `git ls-files`.split("\n")
|
data/lib/catptcha.rb
CHANGED
data/lib/catptcha/seed.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'flickr_fu'
|
2
|
+
require 'aws/s3'
|
3
|
+
require 'open-uri'
|
2
4
|
|
3
5
|
module Catptcha::Seed
|
4
6
|
SEED_GROUP_KITTENS = {
|
@@ -36,6 +38,19 @@ module Catptcha::Seed
|
|
36
38
|
end
|
37
39
|
end
|
38
40
|
|
41
|
+
def s3_upload bucket_name, silent=false
|
42
|
+
loop do
|
43
|
+
photos = Catptcha::Photo.all(:conditions => "url like '%flickr.com/%'", :limit => 50)
|
44
|
+
break if photos.empty?
|
45
|
+
photos.each do |photo|
|
46
|
+
open(photo.url) {|f| AWS::S3::S3Object.store("catptcha_#{photo.key}", f, bucket_name, :access => :public_read) }
|
47
|
+
photo.url = AWS::S3::S3Object.url_for("catptcha_#{photo.key}", bucket_name, :authenticated => false)
|
48
|
+
photo.save
|
49
|
+
puts "image #{photo.key} uploaded to #{photo.url}" unless silent
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
39
54
|
# fetches up to 2500 photos
|
40
55
|
def update_photos group
|
41
56
|
# http://www.flickr.com/services/api/flickr.photos.search.html
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: catptcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Zack Hobson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-05-
|
18
|
+
date: 2012-05-25 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -64,7 +64,7 @@ dependencies:
|
|
64
64
|
type: :runtime
|
65
65
|
version_requirements: *id003
|
66
66
|
- !ruby/object:Gem::Dependency
|
67
|
-
name:
|
67
|
+
name: aws-s3
|
68
68
|
prerelease: false
|
69
69
|
requirement: &id004 !ruby/object:Gem::Requirement
|
70
70
|
none: false
|
@@ -75,8 +75,22 @@ dependencies:
|
|
75
75
|
segments:
|
76
76
|
- 0
|
77
77
|
version: "0"
|
78
|
-
type: :
|
78
|
+
type: :runtime
|
79
79
|
version_requirements: *id004
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: rr
|
82
|
+
prerelease: false
|
83
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
type: :development
|
93
|
+
version_requirements: *id005
|
80
94
|
description: " Choose the kitten!\n"
|
81
95
|
email:
|
82
96
|
executables: []
|