pf_retrowave 0.0.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.
- checksums.yaml +7 -0
- data/lib/photofunia_retro-wave.rb +68 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 776d2d2441099e52b6923a4a3c1f2bbf72ae10fb
|
4
|
+
data.tar.gz: 94b34f0b9675c3be0d2878ebdda7f3d56267ba74
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 478c81c4102de494f2a71e4babaf5d22256faced60659786a9e21cabf2087881e22fe1994a16126c73008b6a009ecaeab1af93badc5f158153fb8195707152da
|
7
|
+
data.tar.gz: 9d571d6b97cd0e9c5f3078889925a6ebf6909881de88c857883a7269b178f638b4aab74bd786360bec0e063dd6993556686a0ce4c7b2b642cf1a5d39dbb0031b
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require "faraday"
|
2
|
+
|
3
|
+
class RetroWaveImage
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def assert(x,t=nil)
|
8
|
+
x || raise(ArgumentError, "Assertion failed#{t ? ": #{t}" : ""}")
|
9
|
+
end
|
10
|
+
|
11
|
+
public
|
12
|
+
|
13
|
+
def initialize(h)
|
14
|
+
|
15
|
+
assert h[:text1].to_s.length<=15 , "Length of text1 exceeds 15 characters"
|
16
|
+
assert h[:text2].to_s.length<=12 , "Length of text2 exceeds 12 characters"
|
17
|
+
assert h[:text3].to_s.length<=25 , "Length of text3 exceeds 25 characters"
|
18
|
+
assert h[:bcg].to_i.between?(1,5), "Background ID is not between 1 and 5"
|
19
|
+
assert h[:txt].to_i.between?(1,4), "Text style ID is not between 1 and 4"
|
20
|
+
|
21
|
+
@content = {
|
22
|
+
bcg: h[:bcg].to_i,
|
23
|
+
txt: h[:txt].to_i,
|
24
|
+
text1: h[:text1].to_s,
|
25
|
+
text2: h[:text2].to_s,
|
26
|
+
text3: h[:text3].to_s
|
27
|
+
}
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def generate
|
32
|
+
conn = Faraday.new "https://photofunia.com"
|
33
|
+
resp = conn.post("/categories/all_effects/retro-wave?server=2",{"current-category": "all_effects"}.merge(@content))
|
34
|
+
@location = resp.headers["location"]
|
35
|
+
result = conn.get @location
|
36
|
+
@raw_url = result.body.match(%r{<a[^<>]*href="([^"]+)"[^<>]*>\s*Large\s*</a>}m)[1]
|
37
|
+
@raw = Faraday.get(@raw_url).body
|
38
|
+
end
|
39
|
+
|
40
|
+
def inspect
|
41
|
+
return "#<RetroWaveImage content=#{@content.inspect}>"
|
42
|
+
end
|
43
|
+
|
44
|
+
attr_accessor :content
|
45
|
+
|
46
|
+
def save(location="")
|
47
|
+
|
48
|
+
unless @raw
|
49
|
+
puts "Content not generated yet, doing that now"
|
50
|
+
generate
|
51
|
+
end
|
52
|
+
|
53
|
+
if File.directory?(location)
|
54
|
+
fname = sprintf "%s/%s.photofunia.80s.jpg", File.expand_path(location), @location.split(?/)[-1]
|
55
|
+
File.write(fname,@raw)
|
56
|
+
return fname
|
57
|
+
else
|
58
|
+
if location==""
|
59
|
+
location = sprintf "%s/%s.photofunia.80s.jpg", File.expand_path(location), @location.split(?/)[-1]
|
60
|
+
end
|
61
|
+
location.end_with?(".jpg") || location+=".jpg"
|
62
|
+
#p location
|
63
|
+
File.write(location,@raw)
|
64
|
+
return location
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pf_retrowave
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- izumariu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Lib for generatin an 80s Retro Wave meme image.
|
14
|
+
email: ''
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/photofunia_retro-wave.rb
|
20
|
+
homepage: ''
|
21
|
+
licenses:
|
22
|
+
- MS-PL
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.6.11
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: photofunia-80s-retrowave
|
44
|
+
test_files: []
|