fill_murray 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +67 -22
- data/fill_murray.gemspec +2 -2
- data/lib/fill_murray/version.rb +1 -1
- data/lib/fill_murray/view_helpers.rb +46 -11
- metadata +7 -7
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# Fill Murray
|
2
2
|
|
3
|
-
Fill Murray makes it super simple to add placeholder images of Bill Murray
|
4
|
-
your Rails projects. It uses the
|
5
|
-
|
3
|
+
Fill Murray makes it super simple to add placeholder images of Bill Murray, Nick
|
4
|
+
Cage or Steven Segal to your Rails projects. It uses the
|
5
|
+
[websites](http://www.fillmurray.com/) created by
|
6
|
+
[Dave Cowart](https://twitter.com/davecowart) to serve images.
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
@@ -31,38 +32,82 @@ This will render an image of Bill Murray at a random height and width between
|
|
31
32
|
|
32
33
|
### Parameters
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
#### Dimensions
|
36
|
+
|
37
|
+
You can explicitly control image dimensions -- `width` and `height`:
|
36
38
|
|
37
39
|
```erb
|
38
|
-
<%= fill_murray 200, 300 %>
|
40
|
+
<%= fill_murray :width => 200, :height => 300 %>
|
39
41
|
```
|
40
42
|
|
41
|
-
|
42
|
-
including:
|
43
|
+
To get more variety in your images, you can instead pass a ratio:
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
```erb
|
46
|
+
<%= fill_murray :ratio => '1:2' %>
|
47
|
+
```
|
48
|
+
|
49
|
+
Note: The ratio should be a string of two numbers, separated by a `:`.
|
50
|
+
|
51
|
+
You can pass any two numbers if square. For example, `'500:500'` gets reduced to
|
52
|
+
`'1:1'`. Ratios are generated such that the larger dimension can never be
|
53
|
+
larger than `1000px`.
|
54
|
+
|
55
|
+
> Note: The ratio may never be greater or equal to than `10x`. In other words,
|
56
|
+
> it may never be greater than or equal to `'10:1'` or `'1:10'`. For example,
|
57
|
+
> `'1000:100'` will not work, but `'1000:101'` will.
|
47
58
|
|
48
|
-
|
59
|
+
#### Person / Subject
|
60
|
+
|
61
|
+
The default is an image of Bill Murray. If you'd rather use Nick Cage or Steven
|
62
|
+
Segal, you can pass a `:person` parameter. Acceptable values are:
|
63
|
+
|
64
|
+
* `'Nick'`, `'Cage'`, `'Nick Cage'`
|
65
|
+
* `'Steve'`, `'Steven'`, `'Segal'`, `'Steven Segal'`
|
66
|
+
|
67
|
+
Any other values with render an image of Bill Murray.
|
68
|
+
|
69
|
+
Examples:
|
49
70
|
|
50
71
|
```erb
|
51
|
-
<%= fill_murray
|
72
|
+
<%= fill_murray :person => 'Nick', :ratio => '9:1' %>
|
52
73
|
```
|
53
74
|
|
54
|
-
|
55
|
-
> options.
|
75
|
+
#### Effects
|
56
76
|
|
57
|
-
|
77
|
+
Each of the subjects can yield grey (black & white) images. Simply pass `:grey
|
78
|
+
=> true` for black and white images:
|
79
|
+
|
80
|
+
```erb
|
81
|
+
<%= fill_murray :person => 'Nick', :ratio => '9:1', :grey => true %>
|
82
|
+
```
|
58
83
|
|
59
|
-
|
60
|
-
|
84
|
+
Nick Cage has another option -- `:crazy` -- to render *crazy* images of Nick
|
85
|
+
Cage (which are approximately 50% of all images of Nick Cage).
|
86
|
+
|
87
|
+
```erb
|
88
|
+
<%= fill_murray :person => 'Nick', :ratio => '9:1', :crazy => true %>
|
89
|
+
```
|
90
|
+
|
91
|
+
A couple notes to consider:
|
92
|
+
|
93
|
+
* `:crazy` will not work if `:person => 'Nick'` has not been specified.
|
94
|
+
* `:grey` will always override `:crazy`. You may not pass both options.
|
95
|
+
|
96
|
+
#### Attributes
|
97
|
+
|
98
|
+
You can send some HTML attributes to the image tag:
|
99
|
+
|
100
|
+
* `alt` : adds alternate attribute to image tag
|
101
|
+
* `class` : adds class(es) to image tag
|
102
|
+
|
103
|
+
```erb
|
104
|
+
<%= fill_murray :grey => true, :class => "panoramic" %>
|
105
|
+
```
|
106
|
+
|
107
|
+
## The Future
|
61
108
|
|
62
|
-
|
63
|
-
|
64
|
-
* make it easier to pass parameters (options without dimensions)
|
65
|
-
* allow dimension ratio as an option for random images
|
109
|
+
Have an idea for adding something other subjects? Or maybe more options? Send me
|
110
|
+
a note.
|
66
111
|
|
67
112
|
## Contributing
|
68
113
|
|
data/fill_murray.gemspec
CHANGED
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = FillMurray::VERSION
|
9
9
|
spec.authors = ["Sean C. Davis"]
|
10
10
|
spec.email = ["scdavis41@gmail.com"]
|
11
|
-
spec.description = %q{Easily add photos of Bill Murray to your project, because
|
11
|
+
spec.description = %q{Easily add photos of Bill Murray, Nick Cage and Steven Segal to your project, because why not?}
|
12
12
|
spec.summary = %q{}
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://github.com/seancdavis/fill_murray"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/fill_murray/version.rb
CHANGED
@@ -1,19 +1,54 @@
|
|
1
1
|
module FillMurray
|
2
2
|
module ViewHelpers
|
3
3
|
|
4
|
-
def fill_murray(
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
4
|
+
def fill_murray(options = {})
|
5
|
+
|
6
|
+
## dimensions ##
|
7
|
+
if !options[:ratio].nil?
|
8
|
+
ratio = options[:ratio].split(':')
|
9
|
+
# if ratio[0].to_i > 1 and ratio[1].to_i > 1
|
10
|
+
if ratio[0].to_i < ratio[1].to_i
|
11
|
+
ratio[1] = ratio[1].to_i / ratio[0].to_i
|
12
|
+
ratio[0] = 1
|
13
|
+
max = 1000 / ratio[1].to_i
|
14
|
+
random = Random.new.rand(100...max)
|
15
|
+
else
|
16
|
+
ratio[0] = ratio[0].to_i / ratio[1].to_i
|
17
|
+
ratio[1] = 1
|
18
|
+
max = 1000 / ratio[0].to_i
|
19
|
+
random = Random.new.rand(100...max)
|
20
|
+
end
|
21
|
+
# else
|
22
|
+
# random = Random.new.rand(100...1000)
|
23
|
+
# end
|
24
|
+
options[:width] = ratio[0].to_i * random
|
25
|
+
options[:height] = ratio[1].to_i * random
|
26
|
+
elsif options[:height].nil? and options[:width].nil?
|
27
|
+
options[:width] = Random.new.rand(100...1000)
|
28
|
+
options[:height] = Random.new.rand(100...1000)
|
29
|
+
elsif options[:height].nil?
|
30
|
+
options[:height] = options[:width]
|
31
|
+
end
|
32
|
+
|
33
|
+
## person / subject ##
|
34
|
+
case options[:person]
|
35
|
+
when "Nick", "Cage", "Nick Cage"
|
36
|
+
site = 'http://www.placecage.com'
|
37
|
+
when "Steve", "Steven", "Segal", "Steven Segal"
|
38
|
+
site = 'http://www.stevensegallery.com'
|
39
|
+
else
|
40
|
+
site = 'http://www.fillmurray.com'
|
41
|
+
end
|
42
|
+
|
43
|
+
## effects ##
|
13
44
|
if options[:grey] == true
|
14
|
-
|
45
|
+
effect = 'g/'
|
46
|
+
elsif options[:crazy] == true and site == 'http://www.placecage.com'
|
47
|
+
effect = 'c/'
|
15
48
|
end
|
16
|
-
|
49
|
+
|
50
|
+
## image_tag markup ##
|
51
|
+
image_tag "#{site}/#{effect}#{options[:width]}/#{options[:height]}",
|
17
52
|
:alt => options[:alt] ? options[:alt] : nil,
|
18
53
|
:class => options[:class] ? options[:class] : nil
|
19
54
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fill_murray
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-12-
|
12
|
+
date: 2013-12-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -43,8 +43,8 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
description: Easily add photos of Bill Murray
|
47
|
-
|
46
|
+
description: Easily add photos of Bill Murray, Nick Cage and Steven Segal to your
|
47
|
+
project, because why not?
|
48
48
|
email:
|
49
49
|
- scdavis41@gmail.com
|
50
50
|
executables: []
|
@@ -61,7 +61,7 @@ files:
|
|
61
61
|
- lib/fill_murray/railtie.rb
|
62
62
|
- lib/fill_murray/version.rb
|
63
63
|
- lib/fill_murray/view_helpers.rb
|
64
|
-
homepage:
|
64
|
+
homepage: https://github.com/seancdavis/fill_murray
|
65
65
|
licenses:
|
66
66
|
- MIT
|
67
67
|
post_install_message:
|
@@ -76,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
segments:
|
78
78
|
- 0
|
79
|
-
hash:
|
79
|
+
hash: 2255891672464187906
|
80
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
81
|
none: false
|
82
82
|
requirements:
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash:
|
88
|
+
hash: 2255891672464187906
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
91
|
rubygems_version: 1.8.23
|