cahdmaker 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/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +2 -0
- data/bin/cahdmaker +34 -0
- data/cahdmaker.gemspec +24 -0
- data/cards/CAH_Black1.png +0 -0
- data/cards/CAH_Black2.png +0 -0
- data/cards/CAH_Black3.png +0 -0
- data/cards/CAH_White.png +0 -0
- data/lib/cahdmaker.rb +54 -0
- data/lib/cahdmaker/version.rb +3 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 30f67fef384dee6694cf49ea9398844fba5447fa
|
4
|
+
data.tar.gz: b62963cadf21282d2dfc170b732e286d64afc233
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de4d4fc30d9541b1221b278921b1808d97f7b57e2e29a47555032356d527fad742744f7373680f51eece8bf00bf52e797a8380ba511aa0153934cc17a51e56ab
|
7
|
+
data.tar.gz: be5e8ff5be76ff21c05bea465727a93b8cbb854f5f1b94e6ebc48d22d84d9edebb362155d112a27262cc71443031c0fa18efcc3dd7d50e72894d253b0a93654f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Michael Klein
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# Cahdmaker
|
2
|
+
|
3
|
+
Create card images for use with a [party game for horrible people](http://cardsagainsthumanity.com).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'cahdmaker'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install cahdmaker
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Code
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require 'cahdmaker'
|
27
|
+
|
28
|
+
maker = Cahdmaker::Maker.new()
|
29
|
+
|
30
|
+
# Generate in-memory card images as RMagick Magick::Image objects
|
31
|
+
white_card = maker.white("31 flavors of hate")
|
32
|
+
black_card = maker.black("I would have gotten away with it if it weren't for _.")
|
33
|
+
pick2_card = maker.black2("I would have gotten away with _ if it weren't for _.")
|
34
|
+
pick3_card = maker.black3("I would have gotten away with _ if it weren't for _ and _.")
|
35
|
+
|
36
|
+
# Save image to file
|
37
|
+
white_card.write('/path/to/white_card.png')
|
38
|
+
|
39
|
+
# Grab image PNG data
|
40
|
+
data = white_card.to_blob
|
41
|
+
|
42
|
+
# Block-driven
|
43
|
+
maker.white('31 flavors of hate') { |card| card.write('/path/to/white_card.png') }
|
44
|
+
```
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it ( https://github.com/[my-github-username]/cahdmaker/fork )
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/cahdmaker
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'cahdmaker'
|
4
|
+
require 'optparse'
|
5
|
+
|
6
|
+
options = {}
|
7
|
+
card_type = :white
|
8
|
+
output_file = nil
|
9
|
+
|
10
|
+
parser = OptionParser.new do |opts|
|
11
|
+
opts.banner = "Usage: cahdmaker [options] <text>"
|
12
|
+
|
13
|
+
opts.on('-b', '--blanks [NUM]', "Number of underscores to use for a blank (8)") { |b| options[:blank_size] = b.to_i}
|
14
|
+
opts.on('-c', '--card [TYPE]', [:white, :black, :black2, :black3], "Select card type (white, black, black2, black3)") { |c| card_type = c }
|
15
|
+
opts.on('-f', '--font [FONT]', "Font (Helvetica-Bold)") { |f| options[:font] = f }
|
16
|
+
opts.on('-o', '--output [FILE]', "Output card to FILE (stdout)") { |o| output_file = o }
|
17
|
+
opts.on('-s', '--size [SIZE]', "Text size in points (60)") { |s| options[:text_size] = s }
|
18
|
+
opts.on_tail('-h', '--help', "Print help string and exit") { puts parser.help; exit }
|
19
|
+
end
|
20
|
+
parser.parse!
|
21
|
+
|
22
|
+
if ARGV.length == 0
|
23
|
+
puts parser.help
|
24
|
+
exit
|
25
|
+
end
|
26
|
+
|
27
|
+
maker = Cahdmaker::Maker.new(options)
|
28
|
+
maker.send(card_type, ARGV.join(' ')) do |card|
|
29
|
+
if output_file.nil?
|
30
|
+
$stdout.write(card.to_blob)
|
31
|
+
else
|
32
|
+
card.write(output_file)
|
33
|
+
end
|
34
|
+
end
|
data/cahdmaker.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cahdmaker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cahdmaker"
|
8
|
+
spec.version = Cahdmaker::VERSION
|
9
|
+
spec.authors = ["Michael Klein"]
|
10
|
+
spec.email = ["mbklein@gmail.com"]
|
11
|
+
spec.summary = %q{Make some Misanthropic Cards}
|
12
|
+
spec.description = %q{Make some Misanthropic Cards}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rmagick"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
data/cards/CAH_White.png
ADDED
Binary file
|
data/lib/cahdmaker.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require "cahdmaker/version"
|
2
|
+
require 'RMagick'
|
3
|
+
require 'tempfile'
|
4
|
+
|
5
|
+
module Cahdmaker
|
6
|
+
class Maker
|
7
|
+
attr_reader :opts
|
8
|
+
|
9
|
+
def initialize(opts={})
|
10
|
+
@opts = { text_size: 60, blank_size: 10, font: 'Helvetica-Bold' }.merge(opts)
|
11
|
+
end
|
12
|
+
|
13
|
+
def black(text, pick=1, &block)
|
14
|
+
make_card(text, "Black#{pick}", &block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def black2(text, &block)
|
18
|
+
black(text, 2, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
def black3(text, &block)
|
22
|
+
black(text, 3, &block)
|
23
|
+
end
|
24
|
+
|
25
|
+
def white(text, &block)
|
26
|
+
make_card(text, "White", &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
def make_card(text, source_card)
|
30
|
+
text_size = opts[:text_size].to_i
|
31
|
+
color = source_card =~ /White/i ? 'black' : 'white'
|
32
|
+
font = opts[:font]
|
33
|
+
text.gsub! /\b_+\b/, ('_' * opts[:blank_size])
|
34
|
+
|
35
|
+
cap = Magick::Image.read(%{caption:#{text}}) do
|
36
|
+
self.size = '600x'
|
37
|
+
self.background_color = 'transparent'
|
38
|
+
self.pointsize = text_size.to_f
|
39
|
+
self['interline-spacing'] = (text_size/3).to_f
|
40
|
+
self.font = font
|
41
|
+
self.fill = color
|
42
|
+
end.first
|
43
|
+
|
44
|
+
img = Magick::Image.read(File.expand_path("../../cards/CAH_#{source_card}.png",__FILE__)).first
|
45
|
+
img.x_resolution = img.y_resolution = 300
|
46
|
+
img.composite!(cap, 75, 75, Magick::OverCompositeOp)
|
47
|
+
if block_given?
|
48
|
+
yield(img)
|
49
|
+
else
|
50
|
+
img
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cahdmaker
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Klein
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rmagick
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Make some Misanthropic Cards
|
56
|
+
email:
|
57
|
+
- mbklein@gmail.com
|
58
|
+
executables:
|
59
|
+
- cahdmaker
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/cahdmaker
|
69
|
+
- cahdmaker.gemspec
|
70
|
+
- cards/CAH_Black1.png
|
71
|
+
- cards/CAH_Black2.png
|
72
|
+
- cards/CAH_Black3.png
|
73
|
+
- cards/CAH_White.png
|
74
|
+
- lib/cahdmaker.rb
|
75
|
+
- lib/cahdmaker/version.rb
|
76
|
+
homepage: ''
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.2
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Make some Misanthropic Cards
|
100
|
+
test_files: []
|