placebear 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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGMzMGQwYjgyMTdlOWE4ZTI0MTJiMTk1NmMwMGE1ODE4ZTQ1ZGE0MQ==
5
+ data.tar.gz: !binary |-
6
+ YjA0YTFmYWUyZDkxODBiZmU2MWY0YTZkZmVhOTlkZGY3N2RlM2E0Mw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ YmIxZDk1Nzc4MGViZDRiNTFkNGE1ZjZkN2U4ZjEzYzdiOWRlMzVjZmJlMWI2
10
+ YTE1YzBiZGI5ZTQ4Y2NiNWFjM2EzYjhjMjNlNTYxYWI5MTdjMDBjYzM4ZmQx
11
+ MGNkNDYwZjViOGExMzc2NWQwYWYyZmQ3ZGIwYzNmMmNkNzIzZDg=
12
+ data.tar.gz: !binary |-
13
+ MTVmZDQ2MTY4OWUxYzA1NzNiY2Q4YWNkNTNhOGJiMjM2ODA5MTg0OWQxMzNk
14
+ OTBjYzI3NGJiMzk2YTAyYWYxMWVkYjExMjc5ZDFiNTAyOTYyZTFjMWQ3Yjlm
15
+ YmZlMDE3NTQwOGM4NGI4ODczZDBjZGFjMjdjYWFlOGRkZWNlMGM=
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in placebear.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 TODO: Write your name
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,34 @@
1
+ # Placebear
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'placebear'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install placebear
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ <%= place_bear 200, 400 %>
25
+ <%= place_bear_gray 200 %>
26
+ ```
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it ( https://github.com/dannysperry/placebear )
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ t.pattern = "test/*_test.rb"
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
@@ -0,0 +1,3 @@
1
+ require "placebear/version"
2
+ require "placebear/place_bear"
3
+ require "placebear/helpers"
@@ -0,0 +1,12 @@
1
+ module PlaceBear::Helpers
2
+ # @see PlaceBear.image
3
+ def place_bear(width = nil, height = nil, grayscale = false)
4
+ PlaceBear.image(width, height, grayscale)
5
+ end
6
+
7
+ # @see PlaceBear.grayscale
8
+ def place_bear_grayscale(width = nil, height = nil)
9
+ PlaceBear.grayscale(width, height)
10
+ end
11
+ alias place_bear_gray place_bear_grayscale
12
+ end
@@ -0,0 +1,43 @@
1
+ require 'active_support/all'
2
+
3
+ class PlaceBear
4
+ DEFAULT_WIDTH = 300
5
+ DEFAULT_HEIGHT = 300
6
+
7
+ # Returns the URL for an optionally grayscale placebear with
8
+ # the given width and height. If the width is given but the height
9
+ # is not, the image will be square.
10
+ #
11
+ # @param [Number] width the width of the placebear
12
+ # @param [Number] height the height of the placebear
13
+ # @param [Boolean] grayscale whether or not to make the placebear grayscale
14
+ def self.image(width = nil, height = nil, grayscale = false)
15
+ if width.nil?
16
+ width = DEFAULT_WIDTH
17
+ height = DEFAULT_HEIGHT
18
+ elsif height.nil?
19
+ height = width
20
+ end
21
+
22
+ if grayscale
23
+ "<img src='http://placebear.com/g/#{width}/#{height}' />".html_safe
24
+ else
25
+ "<img src='http://placebear.com/#{width}/#{height}' />".html_safe
26
+ end
27
+ end
28
+
29
+ # Returns the URL for a grayscale placebear with the given
30
+ # width and height. If the width is given but the height
31
+ # is not, the image will be square.
32
+ #
33
+ # @param [Number] width the width of the placebear
34
+ # @param [Number] height the height of the placebear
35
+ def self.grayscale(width = nil, height = nil)
36
+ self.image(width, height, true)
37
+ end
38
+
39
+ class << self
40
+ alias_method :bear, :image
41
+ alias_method :gray, :grayscale
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module Placebear
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'placebear/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "placebear"
8
+ spec.version = Placebear::VERSION
9
+ spec.authors = ["dannysperry"]
10
+ spec.email = ["danny.sperry@gmail.com"]
11
+ spec.summary = %q{a simple rails helper method for writting placebear image tags in rails}
12
+ spec.description = %q{PlaceBear's code is taken heavily from https://github.com/BinaryMuse/placekitten}
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 "activesupport"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "minitest", "~> 4.7.3"
26
+
27
+ end
@@ -0,0 +1,24 @@
1
+ require 'placebear'
2
+ require 'test_helper'
3
+
4
+ class PlaceBearHelpersTest < Minitest::Unit::TestCase
5
+ include PlaceBear::Helpers
6
+
7
+ def test_placebear_helper
8
+ assert_equal place_bear(300), "<img src='http://placebear.com/300/300' />"
9
+ end
10
+
11
+ def test_placebear_grayscale_helper
12
+ assert_equal place_bear_grayscale(300), "<img src='http://placebear.com/g/300/300' />"
13
+ end
14
+
15
+ def test_placebear_gray_alias
16
+ assert_equal place_bear_gray(500,200), "<img src='http://placebear.com/g/500/200' />"
17
+ end
18
+
19
+ def test_placebear_gray_with_no_params
20
+ assert_equal place_bear_gray, "<img src='http://placebear.com/g/300/300' />"
21
+ end
22
+
23
+ end
24
+
@@ -0,0 +1,29 @@
1
+ require 'placebear'
2
+ require 'test_helper'
3
+
4
+ class PlaceBearTest < Minitest::Unit::TestCase
5
+ def test_returns_activesupport_safebuffer
6
+ assert_equal PlaceBear.image(400).class, ActiveSupport::SafeBuffer
7
+ end
8
+
9
+ def test_grayscale
10
+ assert_equal PlaceBear.grayscale(400), "<img src='http://placebear.com/g/400/400' />"
11
+ end
12
+
13
+ def test_placebear_without_params
14
+ assert_equal PlaceBear.image, "<img src='http://placebear.com/300/300' />"
15
+ end
16
+
17
+ def test_placebear
18
+ assert_equal PlaceBear.image(400), "<img src='http://placebear.com/400/400' />"
19
+ end
20
+
21
+ def test_bear_alias
22
+ assert_equal PlaceBear.image(400), "<img src='http://placebear.com/400/400' />"
23
+ end
24
+
25
+ def test_gray_alias
26
+ assert_equal PlaceBear.grayscale(300), "<img src='http://placebear.com/g/300/300' />"
27
+ end
28
+
29
+ end
@@ -0,0 +1,3 @@
1
+ require 'minitest/unit'
2
+ require 'minitest/autorun'
3
+ require 'minitest/pride'
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: placebear
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - dannysperry
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
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
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 4.7.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 4.7.3
69
+ description: PlaceBear's code is taken heavily from https://github.com/BinaryMuse/placekitten
70
+ email:
71
+ - danny.sperry@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - lib/placebear.rb
82
+ - lib/placebear/helpers.rb
83
+ - lib/placebear/place_bear.rb
84
+ - lib/placebear/version.rb
85
+ - placebear.gemspec
86
+ - test/placebear_helpers_test.rb
87
+ - test/placebear_test.rb
88
+ - test/test_helper.rb
89
+ homepage: ''
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ! '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: a simple rails helper method for writting placebear image tags in rails
113
+ test_files:
114
+ - test/placebear_helpers_test.rb
115
+ - test/placebear_test.rb
116
+ - test/test_helper.rb