stj 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@stj --create
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec"
10
+ gem "bundler"
11
+ gem "jeweler"
12
+ gem "simplecov"
13
+ gem "pry"
14
+ gem "pry-nav"
15
+ gem "pry-doc"
16
+ end
17
+
18
+ gem "mini_magick"
@@ -0,0 +1,56 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ coderay (1.0.8)
5
+ diff-lcs (1.1.3)
6
+ git (1.2.5)
7
+ jeweler (1.8.4)
8
+ bundler (~> 1.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rdoc
12
+ json (1.7.5)
13
+ method_source (0.8.1)
14
+ mini_magick (3.4)
15
+ subexec (~> 0.2.1)
16
+ multi_json (1.3.6)
17
+ pry (0.9.10)
18
+ coderay (~> 1.0.5)
19
+ method_source (~> 0.8)
20
+ slop (~> 3.3.1)
21
+ pry-doc (0.4.4)
22
+ pry (>= 0.9.9.6)
23
+ yard (~> 0.8.1)
24
+ pry-nav (0.2.2)
25
+ pry (~> 0.9.10)
26
+ rake (0.9.2.2)
27
+ rdoc (3.12)
28
+ json (~> 1.4)
29
+ rspec (2.11.0)
30
+ rspec-core (~> 2.11.0)
31
+ rspec-expectations (~> 2.11.0)
32
+ rspec-mocks (~> 2.11.0)
33
+ rspec-core (2.11.1)
34
+ rspec-expectations (2.11.3)
35
+ diff-lcs (~> 1.1.3)
36
+ rspec-mocks (2.11.3)
37
+ simplecov (0.7.1)
38
+ multi_json (~> 1.0)
39
+ simplecov-html (~> 0.7.1)
40
+ simplecov-html (0.7.1)
41
+ slop (3.3.3)
42
+ subexec (0.2.2)
43
+ yard (0.8.3)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ bundler
50
+ jeweler
51
+ mini_magick
52
+ pry
53
+ pry-doc
54
+ pry-nav
55
+ rspec
56
+ simplecov
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Dayton Nolan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = stj
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to stj
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Dayton Nolan. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "stj"
18
+ gem.homepage = "http://github.com/koriroys/stj"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{stj is a meme generator for the "Spoke to Joe" meme.}
21
+ gem.description = %Q{stj is a meme generator for the "Spoke to Joe" meme.}
22
+ gem.email = "kori@koriroys.com"
23
+ gem.authors = ["Kori Roys", "Dayton Nolan"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ task :default => :spec
35
+
36
+ require 'rdoc/task'
37
+ Rake::RDocTask.new do |rdoc|
38
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
39
+
40
+ rdoc.rdoc_dir = 'rdoc'
41
+ rdoc.title = "stj #{version}"
42
+ rdoc.rdoc_files.include('README*')
43
+ rdoc.rdoc_files.include('lib/**/*.rb')
44
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/bin/stj ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ $: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
3
+ require 'stj/meme'
4
+ STJ::Meme.new(ARGV[0]).create(Dir.pwd)
Binary file
@@ -0,0 +1,7 @@
1
+ $: << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
2
+
3
+ module STJ
4
+
5
+ LIB_PATH = File.expand_path('stj', File.dirname(__FILE__))
6
+
7
+ end
Binary file
Binary file
Binary file
@@ -0,0 +1,46 @@
1
+ require 'stj'
2
+ require 'mini_magick'
3
+
4
+ module STJ
5
+ class Meme
6
+ attr_reader :default_phrase, :first_phrase, :image
7
+
8
+ def initialize(first_phrase)
9
+ @default_phrase = "THEN I SPOKE TO JOE"
10
+ @first_phrase = first_phrase
11
+ @image = File.join(STJ::LIB_PATH, "images", 'crying-girl-joe.jpg')
12
+ end
13
+
14
+ def output_file_name
15
+ name = first_phrase.downcase.gsub(/\s+/, '_').gsub(/\W/, '')
16
+ "tistj_#{name}.jpg"
17
+ end
18
+
19
+ def create(path)
20
+ point_size = 50
21
+ img = MiniMagick::Image.from_file(image)
22
+ img.combine_options do |c|
23
+ c.gravity 'South'
24
+ c.font File.join(STJ::LIB_PATH, 'fonts', 'impact.ttf')
25
+ c.pointsize '50'
26
+ c.stroke '#000000'
27
+ c.draw "text 10,0 '#{default_phrase}'"
28
+ c.fill("#FFFFFF")
29
+
30
+ c.gravity 'North'
31
+ if first_phrase.size > 20
32
+ point_size -= (first_phrase.size - 20) * 1.25
33
+ end
34
+ point_size = 25 if point_size < 25
35
+
36
+ c.pointsize point_size.to_s
37
+ c.stroke '#000000'
38
+ c.draw "text 10,0 '#{first_phrase}'"
39
+ c.fill("#FFFFFF")
40
+ end
41
+ img.write(File.join(path, output_file_name))
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,39 @@
1
+ require 'stj/meme'
2
+
3
+ describe STJ::Meme do
4
+
5
+ let(:temp_dir) { File.join(SPEC_PATH, "temp") }
6
+
7
+ before do
8
+ FileUtils.mkdir(temp_dir) unless File.exists?(temp_dir)
9
+ end
10
+
11
+ after do
12
+ FileUtils.rm_rf(temp_dir) if File.exists?(temp_dir)
13
+ end
14
+
15
+ it "has a default bottom phrase" do
16
+ expect(STJ::Meme.new("").default_phrase).to eq("THEN I SPOKE TO JOE")
17
+ end
18
+
19
+ it "have a first_phrase" do
20
+ expect(STJ::Meme.new("this is a test").first_phrase).to eq("this is a test")
21
+ end
22
+
23
+ it "has an image" do
24
+ expect(STJ::Meme.new("").image).to eq(File.join(LIB_PATH, 'images', 'crying-girl-joe.jpg'))
25
+ end
26
+
27
+ it "has an output file name" do
28
+ expect(STJ::Meme.new("I didn't know how to make gems").output_file_name).to eq("tistj_i_didnt_know_how_to_make_gems.jpg")
29
+ end
30
+
31
+ it "generates a meme image" do
32
+ meme = STJ::Meme.new("I thought I knew Clojure")
33
+ meme.create(temp_dir)
34
+ expect(File.exists?(File.join(temp_dir, "tistj_i_thought_i_knew_clojure.jpg"))).to be_true
35
+ expect(FileUtils.cmp(meme.image, File.join(temp_dir, meme.output_file_name))).to be_false
36
+ end
37
+
38
+
39
+ end
@@ -0,0 +1,17 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'stj'
5
+ require "pry"
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
13
+
14
+
15
+ BIN = File.expand_path('../bin/stj', File.dirname(__FILE__))
16
+ LIB_PATH = File.expand_path('../lib/stj', File.dirname(__FILE__))
17
+ SPEC_PATH = File.expand_path(File.dirname(__FILE__))
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe STJ do
4
+ it "has a reference to the lib path" do
5
+ expect(STJ::LIB_PATH).to eq LIB_PATH
6
+ end
7
+ end
@@ -0,0 +1,83 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "stj"
8
+ s.version = "1.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kori Roys", "Dayton Nolan"]
12
+ s.date = "2012-10-20"
13
+ s.description = "stj is a meme generator for the \"Spoke to Joe\" meme."
14
+ s.email = "kori@koriroys.com"
15
+ s.executables = ["stj"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".rspec",
23
+ ".rvmrc",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/stj",
31
+ "lib/.DS_Store",
32
+ "lib/stj.rb",
33
+ "lib/stj/.DS_Store",
34
+ "lib/stj/fonts/impact.ttf",
35
+ "lib/stj/images/crying-girl-joe.jpg",
36
+ "lib/stj/images/crying-girl.jpg",
37
+ "lib/stj/images/joe.png",
38
+ "lib/stj/meme.rb",
39
+ "spec/meme_spec.rb",
40
+ "spec/spec_helper.rb",
41
+ "spec/stj_spec.rb",
42
+ "stj.gemspec"
43
+ ]
44
+ s.homepage = "http://github.com/koriroys/stj"
45
+ s.licenses = ["MIT"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = "1.8.23"
48
+ s.summary = "stj is a meme generator for the \"Spoke to Joe\" meme."
49
+
50
+ if s.respond_to? :specification_version then
51
+ s.specification_version = 3
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<mini_magick>, [">= 0"])
55
+ s.add_development_dependency(%q<rspec>, [">= 0"])
56
+ s.add_development_dependency(%q<bundler>, [">= 0"])
57
+ s.add_development_dependency(%q<jeweler>, [">= 0"])
58
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
59
+ s.add_development_dependency(%q<pry>, [">= 0"])
60
+ s.add_development_dependency(%q<pry-nav>, [">= 0"])
61
+ s.add_development_dependency(%q<pry-doc>, [">= 0"])
62
+ else
63
+ s.add_dependency(%q<mini_magick>, [">= 0"])
64
+ s.add_dependency(%q<rspec>, [">= 0"])
65
+ s.add_dependency(%q<bundler>, [">= 0"])
66
+ s.add_dependency(%q<jeweler>, [">= 0"])
67
+ s.add_dependency(%q<simplecov>, [">= 0"])
68
+ s.add_dependency(%q<pry>, [">= 0"])
69
+ s.add_dependency(%q<pry-nav>, [">= 0"])
70
+ s.add_dependency(%q<pry-doc>, [">= 0"])
71
+ end
72
+ else
73
+ s.add_dependency(%q<mini_magick>, [">= 0"])
74
+ s.add_dependency(%q<rspec>, [">= 0"])
75
+ s.add_dependency(%q<bundler>, [">= 0"])
76
+ s.add_dependency(%q<jeweler>, [">= 0"])
77
+ s.add_dependency(%q<simplecov>, [">= 0"])
78
+ s.add_dependency(%q<pry>, [">= 0"])
79
+ s.add_dependency(%q<pry-nav>, [">= 0"])
80
+ s.add_dependency(%q<pry-doc>, [">= 0"])
81
+ end
82
+ end
83
+
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stj
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Kori Roys
9
+ - Dayton Nolan
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-10-20 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mini_magick
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rspec
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: bundler
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: jeweler
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ name: simplecov
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ type: :development
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: pry
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-nav
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ - !ruby/object:Gem::Dependency
128
+ name: pry-doc
129
+ requirement: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ type: :development
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ description: stj is a meme generator for the "Spoke to Joe" meme.
144
+ email: kori@koriroys.com
145
+ executables:
146
+ - stj
147
+ extensions: []
148
+ extra_rdoc_files:
149
+ - LICENSE.txt
150
+ - README.rdoc
151
+ files:
152
+ - .document
153
+ - .rspec
154
+ - .rvmrc
155
+ - Gemfile
156
+ - Gemfile.lock
157
+ - LICENSE.txt
158
+ - README.rdoc
159
+ - Rakefile
160
+ - VERSION
161
+ - bin/stj
162
+ - lib/.DS_Store
163
+ - lib/stj.rb
164
+ - lib/stj/.DS_Store
165
+ - lib/stj/fonts/impact.ttf
166
+ - lib/stj/images/crying-girl-joe.jpg
167
+ - lib/stj/images/crying-girl.jpg
168
+ - lib/stj/images/joe.png
169
+ - lib/stj/meme.rb
170
+ - spec/meme_spec.rb
171
+ - spec/spec_helper.rb
172
+ - spec/stj_spec.rb
173
+ - stj.gemspec
174
+ homepage: http://github.com/koriroys/stj
175
+ licenses:
176
+ - MIT
177
+ post_install_message:
178
+ rdoc_options: []
179
+ require_paths:
180
+ - lib
181
+ required_ruby_version: !ruby/object:Gem::Requirement
182
+ none: false
183
+ requirements:
184
+ - - ! '>='
185
+ - !ruby/object:Gem::Version
186
+ version: '0'
187
+ segments:
188
+ - 0
189
+ hash: 1878908302123333219
190
+ required_rubygems_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ! '>='
194
+ - !ruby/object:Gem::Version
195
+ version: '0'
196
+ requirements: []
197
+ rubyforge_project:
198
+ rubygems_version: 1.8.23
199
+ signing_key:
200
+ specification_version: 3
201
+ summary: stj is a meme generator for the "Spoke to Joe" meme.
202
+ test_files: []