doge 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZWZmNWU1ODFmYjM2NWMzMzFiMjQ1Yjk2ZDgwMTcxN2Q0OTg5NjdkOQ==
5
+ data.tar.gz: !binary |-
6
+ ZGQ1MjVjNzJjNzJlZTRkYTQ0ZGMxYzYzODk5ZDlkMTQ5MmNmMDljYQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTU3YmQzNjdiNjllMmE3ZGYxNGQwZGJlNzNjM2M3M2VkZWM5MjJkY2JjN2Qw
10
+ NmE4ODYwN2ZjNDNmMWQyYTkxYjllMzIwZGY5YmYxOTMzODAwODdhMjFhMjU3
11
+ NWE5ZmQ1Y2UzMjJlNjU4ZDBiOTVhOWM2MzUzYjBkZDg5MDBkNGI=
12
+ data.tar.gz: !binary |-
13
+ Yzc5NjA0MDAwMTQxMzIzOWRkNGIzMzFlNmYxMzIwZjQxZTA4YjEyNGI2YmM4
14
+ YzhmMDdlZjA5MzdjODkzN2Y1ZTc5ZWYyZThiMzM0ZjQxZTZlNmJhMWNlYmIw
15
+ NDg5ODY5ZjRjNDZhYjFhMzQ0YzljNDVmYWFhNmI0Y2E1YmMzODY=
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in doge.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Pascal Jungblut
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.
@@ -0,0 +1,56 @@
1
+ # Doge
2
+
3
+ ```
4
+ such gem
5
+
6
+ amaze
7
+
8
+
9
+ so ruby
10
+
11
+ wow
12
+ ```
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem 'doge'
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install doge
27
+
28
+ ## Usage
29
+
30
+ ```
31
+ require 'doge'
32
+
33
+ Doge.new do
34
+ such "code"
35
+ wow
36
+ so "ruby"
37
+ amaze
38
+ wuff "Doge.new"
39
+ end.image.write("output.jpg")
40
+ ```
41
+
42
+ Will write the image to disk:
43
+
44
+ ![output](res/test.jpg)
45
+
46
+ `#image` will return an [`Magick::Image`](http://www.simplesystems.org/RMagick/doc/imageattrs.html).
47
+
48
+ Available methods are `such`, `wow`, `so`, `amaze` and `wuff` which writes a custom string.
49
+
50
+ ## Contributing
51
+
52
+ 1. Fork it
53
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
54
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
55
+ 4. Push to the branch (`git push origin my-new-feature`)
56
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'doge/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "doge"
8
+ spec.version = Doge::VERSION
9
+ spec.authors = ["Pascal Jungblut"]
10
+ spec.email = ["mail@pascal-jungblut.com"]
11
+ spec.description = %q{such gem}
12
+ spec.summary = %q{wow}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_runtime_dependency "rmagick"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,61 @@
1
+ require "doge/version"
2
+ require 'RMagick'
3
+
4
+
5
+ class Doge
6
+ attr_reader :image
7
+
8
+ def initialize(&block)
9
+ @image = Magick::ImageList.new(File.expand_path('lib/doge/images/doge.jpg'))
10
+ @occupied = []
11
+ instance_eval &block if block
12
+ end
13
+
14
+ def wuff(term)
15
+ text = image_text
16
+ metrics = text.get_type_metrics(@image, term)
17
+ horizontal_padding = @image.columns * 0.1
18
+ horizontal_top = @image.columns - horizontal_padding - metrics.width
19
+ height = metrics.height.round + 5 #padding
20
+ @image.annotate(text, 0,0, Random.rand(horizontal_padding..horizontal_top), y_for_height(height), term)
21
+ self
22
+ end
23
+
24
+ [:such, :wow, :so, :much, :amaze].each do |word|
25
+ define_method(word) { |text = ''| wuff(word.to_s + " " + text) }
26
+ end
27
+
28
+ private
29
+ def random_rgb
30
+ "rgb(#{Random.rand(0..255)}, #{Random.rand(0..255)}, #{Random.rand(0..255)})"
31
+ end
32
+
33
+ def image_text
34
+ text = Magick::Draw.new
35
+ text.gravity = Magick::NorthWestGravity
36
+ text.pointsize = 50
37
+ text.font_family = "Comic Sans MS"
38
+ text.font_weight = Magick::BoldWeight
39
+ text.fill = random_rgb
40
+ text
41
+ end
42
+
43
+ def y_for_height(height)
44
+ vertical_padding = @image.rows * 0.1
45
+ vertical_top = @image.rows - vertical_padding
46
+ row = 0
47
+ begin
48
+ row = Random.rand(vertical_padding..vertical_top).round
49
+ end while row_occupied?(row, height)
50
+ @occupied << (row..(row + height))
51
+ row
52
+ end
53
+
54
+ def row_occupied?(row, height)
55
+ @occupied.each do |range|
56
+ return true if range.include?(row)
57
+ return true if range.include?(row + height)
58
+ end
59
+ false
60
+ end
61
+ end
Binary file
@@ -0,0 +1,3 @@
1
+ class Doge
2
+ VERSION = "1.0.0"
3
+ end
Binary file
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doge
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Pascal Jungblut
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-30 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.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: such gem
56
+ email:
57
+ - mail@pascal-jungblut.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - doge.gemspec
68
+ - lib/doge.rb
69
+ - lib/doge/images/doge.jpg
70
+ - lib/doge/version.rb
71
+ - res/test.jpg
72
+ homepage: ''
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.1.11
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: wow
96
+ test_files: []