lorempixel_helper 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.
- data/.gitignore +34 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +31 -0
- data/LICENSE.txt +22 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/lib/lorempixel_helper/railtie.rb +7 -0
- data/lib/lorempixel_helper/version.rb +3 -0
- data/lib/lorempixel_helper.rb +51 -0
- data/lorempixel_helper.gemspec +24 -0
- data/spec/lorempixel_spec.rb +37 -0
- data/spec/spec_helper.rb +8 -0
- metadata +108 -0
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lorempixel_helper (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
rake (10.3.2)
|
11
|
+
rspec (3.0.0)
|
12
|
+
rspec-core (~> 3.0.0)
|
13
|
+
rspec-expectations (~> 3.0.0)
|
14
|
+
rspec-mocks (~> 3.0.0)
|
15
|
+
rspec-core (3.0.1)
|
16
|
+
rspec-support (~> 3.0.0)
|
17
|
+
rspec-expectations (3.0.1)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.0.0)
|
20
|
+
rspec-mocks (3.0.1)
|
21
|
+
rspec-support (~> 3.0.0)
|
22
|
+
rspec-support (3.0.0)
|
23
|
+
|
24
|
+
PLATFORMS
|
25
|
+
ruby
|
26
|
+
|
27
|
+
DEPENDENCIES
|
28
|
+
bundler (~> 1.3)
|
29
|
+
lorempixel_helper!
|
30
|
+
rake
|
31
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Prabu D
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# LorempixelHelper
|
2
|
+
|
3
|
+
A Rails view helper for placeholder images via http://lorempixel.com
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'lorempixel_helper'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install lorempixel_helper
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
to get a random picture of 400 x 400 pixels
|
22
|
+
|
23
|
+
<%= lorempixel_image_tag "400" %>
|
24
|
+
|
25
|
+
to get a random picture of 400 x 200 pixels
|
26
|
+
|
27
|
+
<%= lorempixel_image_tag "400x200" %>
|
28
|
+
|
29
|
+
to get a random gray picture of 400 x 400 pixels
|
30
|
+
|
31
|
+
<%= lorempixel_image_tag "400" , :type => "g"%>
|
32
|
+
|
33
|
+
to get a random picture of the any category given below:
|
34
|
+
|
35
|
+
[abstract , animals, business, cats, city, food, nightlife, fashion, people, nature, sports, technics, transport ]
|
36
|
+
|
37
|
+
<%= lorempixel_image_tag "400", :category => "sports" %>
|
38
|
+
|
39
|
+
to get picture no. 1/10 from the sports category
|
40
|
+
|
41
|
+
<%= lorempixel_image_tag "400", :category => "sports", :item => 1 %>
|
42
|
+
|
43
|
+
...with a custom text on the random Picture
|
44
|
+
|
45
|
+
<%= lorempixel_image_tag "400", :category => "sports", :text => "Dummy-Text" %>
|
46
|
+
|
47
|
+
...with a custom text on the selected Picture
|
48
|
+
|
49
|
+
<%= lorempixel_image_tag "400x200", :category => "sports", :item => 1, :text => "Dummy-Text" %>
|
50
|
+
|
51
|
+
Alternatively, calling lorempixel will work as well:
|
52
|
+
|
53
|
+
<%= lorempixel "400" %>
|
54
|
+
|
55
|
+
Testing
|
56
|
+
|
57
|
+
rspec spec/
|
58
|
+
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
1. Fork it
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
66
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require "lorempixel_helper/version"
|
2
|
+
|
3
|
+
module LorempixelHelper
|
4
|
+
module ViewHelpers
|
5
|
+
def lorempixel_image_tag(size, opts={})
|
6
|
+
size = "#{size.to_s}" unless size.is_a?(String)
|
7
|
+
config = {
|
8
|
+
:alt => (opts[:text] || "A lorempixel image"),
|
9
|
+
:height => (size.split('x')[1] || size.split('x')[0]),
|
10
|
+
:width => size.split('x')[0],
|
11
|
+
:item => opts[:item],
|
12
|
+
:text => opts[:text].to_s.gsub(/\s+/, "-"),
|
13
|
+
:title => opts[:text] || "A lorempixel image",
|
14
|
+
:category => opts[:category],
|
15
|
+
:type => opts[:type]
|
16
|
+
}.merge!(opts)
|
17
|
+
|
18
|
+
src = "http://lorempixel.com/#{config[:width]}/#{config[:height]}"
|
19
|
+
|
20
|
+
# lorempixel option
|
21
|
+
|
22
|
+
if config[:type]
|
23
|
+
src = "http://lorempixel.com/#{config[:type]}/#{config[:width]}/#{config[:height]}"
|
24
|
+
end
|
25
|
+
|
26
|
+
if config[:category]
|
27
|
+
src += "/#{config[:category]}"
|
28
|
+
if config[:item]
|
29
|
+
src += "/#{config[:item]}"
|
30
|
+
if config[:text]
|
31
|
+
src += "/#{config[:text]}"
|
32
|
+
end
|
33
|
+
elsif config[:text]
|
34
|
+
src += "/#{config[:text]}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
image_tag = "<img src='#{src}' alt='#{config[:alt]}' height='#{config[:height]}' width='#{config[:width]}'"
|
40
|
+
image_tag += " title='#{config[:title]}'"
|
41
|
+
image_tag += " />"
|
42
|
+
return image_tag.html_safe if defined?(Rails)
|
43
|
+
image_tag
|
44
|
+
end
|
45
|
+
|
46
|
+
alias :lorempixel :lorempixel_image_tag
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
require "lorempixel_helper/railtie" if defined?(Rails)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'lorempixel_helper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "lorempixel_helper"
|
8
|
+
spec.version = LorempixelHelper::VERSION
|
9
|
+
spec.authors = ["Prabu D"]
|
10
|
+
spec.email = ["prabud@spritle.com"]
|
11
|
+
spec.description = %q{A Rails view images via http://lorempixel.com}
|
12
|
+
spec.summary = %q{A Rails view helper place an images via http://lorempixel.com}
|
13
|
+
spec.homepage = "https://github.com/spritlesoftware/lorempixel"
|
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_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class LorempixelHelperView
|
4
|
+
include LorempixelHelper::ViewHelpers
|
5
|
+
end
|
6
|
+
|
7
|
+
describe LorempixelHelper::ViewHelpers do
|
8
|
+
let(:myview) { LorempixelHelperView.new }
|
9
|
+
|
10
|
+
it "should accept a string" do
|
11
|
+
myview.lorempixel_image_tag("400").should == "<img src='http://lorempixel.com/400/400' alt='A lorempixel image' height='400' width='400' title='A lorempixel image' />"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should accept a integer" do
|
15
|
+
myview.lorempixel_image_tag(400).should == "<img src='http://lorempixel.com/400/400' alt='A lorempixel image' height='400' width='400' title='A lorempixel image' />"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should accept a componded WxH" do
|
19
|
+
myview.lorempixel_image_tag("400x200").should == "<img src='http://lorempixel.com/400/200' alt='A lorempixel image' height='200' width='400' title='A lorempixel image' />"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should accept category" do
|
23
|
+
myview.lorempixel_image_tag("400", :category=> "sports").should == "<img src='http://lorempixel.com/400/400/sports/' alt='A lorempixel image' height='400' width='400' title='A lorempixel image' />"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should accept category with custom text" do
|
27
|
+
myview.lorempixel_image_tag("400x200", :text=> 'Dummy-Text', :category=> "sports").should == "<img src='http://lorempixel.com/400/200/sports/Dummy-Text' alt='Dummy-Text' height='200' width='400' title='Dummy-Text' />"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should accept selected picture in category" do
|
31
|
+
myview.lorempixel_image_tag("400", :category=> "sports", :item => 2).should == "<img src='http://lorempixel.com/400/400/sports/2/' alt='A lorempixel image' height='400' width='400' title='A lorempixel image' />"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should accept selected picture in category with custom text" do
|
35
|
+
myview.lorempixel_image_tag("400", :text=> 'Dummy-Text', :category=> "sports", :item => 1).should == "<img src='http://lorempixel.com/400/400/sports/1/Dummy-Text' alt='Dummy-Text' height='400' width='400' title='Dummy-Text' />"
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lorempixel_helper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Prabu D
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2014-06-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: A Rails view images via http://lorempixel.com
|
63
|
+
email:
|
64
|
+
- prabud@spritle.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- Gemfile.lock
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.md
|
74
|
+
- Rakefile
|
75
|
+
- lib/lorempixel_helper.rb
|
76
|
+
- lib/lorempixel_helper/railtie.rb
|
77
|
+
- lib/lorempixel_helper/version.rb
|
78
|
+
- lorempixel_helper.gemspec
|
79
|
+
- spec/lorempixel_spec.rb
|
80
|
+
- spec/spec_helper.rb
|
81
|
+
homepage: https://github.com/spritlesoftware/lorempixel
|
82
|
+
licenses:
|
83
|
+
- MIT
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 1.8.25
|
103
|
+
signing_key:
|
104
|
+
specification_version: 3
|
105
|
+
summary: A Rails view helper place an images via http://lorempixel.com
|
106
|
+
test_files:
|
107
|
+
- spec/lorempixel_spec.rb
|
108
|
+
- spec/spec_helper.rb
|