placekitten 1.0.0

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.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in placekitten.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ placekitten
2
+ ===========
3
+
4
+ placekitten is a small library for generating [placekittens](http://placekitten.com/).
5
+
6
+ Installing
7
+ ----------
8
+
9
+ placekitten is available on [RubyGems](http://rubygems.org/gems/placekitten).
10
+
11
+ gem install placekitten
12
+
13
+ Examples
14
+ --------
15
+
16
+ require 'placekitten'
17
+
18
+ # Generate a 300x400 placekitten
19
+ PlaceKitten.image(300, 400) # => "http://placekitten.com/300/400"
20
+
21
+ # Generate a 400x600 grayscale placekitten
22
+ PlaceKitten.image(400, 600, true) # => "http://placekitten.com/g/300/400"
23
+ # Alternatively:
24
+ PlaceKitten.grayscale(400, 600)
25
+
26
+ Rails Helpers
27
+ -------------
28
+
29
+ # in Gemfile:
30
+ gem 'placekitten'
31
+
32
+ # in app/helpers/application_helper.rb:
33
+ module ApplicationHelper
34
+ include PlaceKitten::Helpers
35
+ end
36
+
37
+ License
38
+ -------
39
+
40
+ Copyright (c) 2011 Brandon Tilley <brandon@brandontilley.com>
41
+
42
+ Permission is hereby granted, free of charge, to any person obtaining a copy
43
+ of this software and associated documentation files (the "Software"), to deal
44
+ in the Software without restriction, including without limitation the rights
45
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46
+ copies of the Software, and to permit persons to whom the Software is
47
+ furnished to do so, subject to the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be included in
50
+ all copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
58
+ THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'bundler'
2
+ require 'rake/testtask'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ desc "Run basic tests"
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "lib"
8
+ t.pattern = "test/*_test.rb"
9
+ t.verbose = true
10
+ t.warning = true
11
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,2 @@
1
+ require 'placekitten/placekitten'
2
+ require 'placekitten/helpers'
@@ -0,0 +1,9 @@
1
+ module PlaceKitten::Helpers
2
+ def placekitten(width = 200, height = 300, grayscale = false)
3
+ PlaceKitten.image(width, height, grayscale)
4
+ end
5
+
6
+ def placekitten_gray(width = 200, height = 300)
7
+ PlaceKitten.grayscale(width, height)
8
+ end
9
+ end
@@ -0,0 +1,29 @@
1
+ class PlaceKitten
2
+ # Returns the URL for an optionally grayscale placekitten with
3
+ # the given width and height.
4
+ #
5
+ # @param [Number] width the width of the placekitten
6
+ # @param [Number] height the height of the placekitten
7
+ # @param [Boolean] grayscale whether or not to make the placekitten grayscale
8
+ def self.image(width = 300, height = 200, grayscale = false)
9
+ if grayscale
10
+ "http://placekitten.com/g/#{width}/#{height}"
11
+ else
12
+ "http://placekitten.com/#{width}/#{height}"
13
+ end
14
+ end
15
+
16
+ # Returns the URL for a grayscale placekitten with the given
17
+ # width and height.
18
+ #
19
+ # @param [Number] width the width of the placekitten
20
+ # @param [Number] height the height of the placekitten
21
+ def self.grayscale(width = 300, height = 200)
22
+ self.image(width, height, true)
23
+ end
24
+
25
+ class << self
26
+ alias_method :kitten, :image
27
+ alias_method :gray, :grayscale
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "placekitten"
6
+ s.version = File.read('VERSION').strip
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Brandon Tilley"]
9
+ s.email = ["brandon@brandontilley.com"]
10
+ s.homepage = "https://github.com/BinaryMuse/placekitten"
11
+ s.summary = %q{A small library to generate placekitten images.}
12
+ s.description = %q{A small library to generate placekitten images.}
13
+
14
+ s.rubyforge_project = "placekitten"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+ end
@@ -0,0 +1,15 @@
1
+ require 'placekitten'
2
+ require 'test/unit'
3
+
4
+ class KittenRailsTest < Test::Unit::TestCase
5
+ include PlaceKitten::Helpers
6
+ def test_placekitten_helper
7
+ image = placekitten(400, 500)
8
+ assert_equal "http://placekitten.com/400/500", image
9
+ end
10
+
11
+ def test_placekitten_gray_helper
12
+ image = placekitten_gray(400, 500)
13
+ assert_equal "http://placekitten.com/g/400/500", image
14
+ end
15
+ end
@@ -0,0 +1,29 @@
1
+ require 'placekitten'
2
+ require 'test/unit'
3
+
4
+ class KittenTest < Test::Unit::TestCase
5
+ def test_width_height
6
+ image = PlaceKitten.image(300, 200)
7
+ assert_equal "http://placekitten.com/300/200", image
8
+ end
9
+
10
+ def test_image_alias
11
+ image = PlaceKitten.kitten(300, 200)
12
+ assert_equal "http://placekitten.com/300/200", image
13
+ end
14
+
15
+ def test_grayscale_arg
16
+ image = PlaceKitten.image(100, 300, true)
17
+ assert_equal "http://placekitten.com/g/100/300", image
18
+ end
19
+
20
+ def test_grayscale_method
21
+ image = PlaceKitten.grayscale(200, 400)
22
+ assert_equal "http://placekitten.com/g/200/400", image
23
+ end
24
+
25
+ def test_grayscale_method_alias
26
+ image = PlaceKitten.gray(200, 400)
27
+ assert_equal "http://placekitten.com/g/200/400", image
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: placekitten
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 1.0.0
6
+ platform: ruby
7
+ authors:
8
+ - Brandon Tilley
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-01 00:00:00 -08:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: A small library to generate placekitten images.
18
+ email:
19
+ - brandon@brandontilley.com
20
+ executables: []
21
+
22
+ extensions: []
23
+
24
+ extra_rdoc_files: []
25
+
26
+ files:
27
+ - .gitignore
28
+ - Gemfile
29
+ - README.md
30
+ - Rakefile
31
+ - VERSION
32
+ - lib/placekitten.rb
33
+ - lib/placekitten/helpers.rb
34
+ - lib/placekitten/placekitten.rb
35
+ - placekitten.gemspec
36
+ - test/placekitten_helpers_test.rb
37
+ - test/placekitten_test.rb
38
+ has_rdoc: true
39
+ homepage: https://github.com/BinaryMuse/placekitten
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ none: false
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project: placekitten
62
+ rubygems_version: 1.5.0
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: A small library to generate placekitten images.
66
+ test_files:
67
+ - test/placekitten_helpers_test.rb
68
+ - test/placekitten_test.rb