random_ipsum 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile ADDED
@@ -0,0 +1,60 @@
1
+ h1. random_ipsum - randomized _Lorem ipsum_
2
+
3
+ We were sick of the ever-same blindtext made by TextMate etc. So here you go:
4
+
5
+ <pre>
6
+ >> require "random_ipsum"
7
+ => true
8
+ >> RandomIpsum.words
9
+ => "Purus vulputate congue scelerisque a"
10
+ >> RandomIpsum.words(2)
11
+ => "Justo viverra"
12
+ >> RandomIpsum.words(2)
13
+ => "Sed ut"
14
+ >> RandomIpsum.sentence
15
+ => "Cras sapien lobortis Eleifend faucibus Porttitor fermentum, commodo eros amet."
16
+ >> RandomIpsum.sentence(5)
17
+ => "In risus posuere sit tellus."
18
+ >> RandomIpsum.paragraphs
19
+ => "Volutpat commodo ligula tempus blandit dui Suscipit Ornare sem praesent nam cursus. Nisi Nonummy ullamcorper duis auctor lacus phasellus massa, lorem pede.\n\nElit metus tristique augue, tortor Gravida Lobortis Auctor suscipit vel porta tincidunt donec. Amet porta venenatis consequat bibendum integer Morbi et fames, euismod."
20
+ </pre>
21
+
22
+ h2. Method Signatures
23
+
24
+ <tt>RandomIpsum.words(nomber_of_words)</tt>
25
+
26
+ <tt>RandomIpsum.sentence(number_of_words)</tt>
27
+
28
+ <tt>RandomIpsum.paragraphs(number_of_paragraphs, number_of_sentences, number_of_words)</tt>
29
+
30
+ h2. Dependencies
31
+
32
+ We use
33
+ * <a href="http://github.com/provideal/whiny_hash">whiny_hash</a> to handle the options in a fail-early-manner,
34
+ * <a href="http://github.com/provideal/id_stuffer">id_stuffer</a> to compress the _remembered_ ids.
35
+ * And... eh... It's an extension for Rails 3, so it might be handy to have a version of Rails 3 and Ruby 1.8.? or 1.9.?.
36
+
37
+ h2. Bugs
38
+
39
+ If you find a bug, please let me know using the <a href="https://github.com/provideal/random_ipsum/issues">GitHub Bugtracker</a>.
40
+
41
+ h2. Contributing to random_ipsum
42
+
43
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
44
+ * Check out the <a href="https://github.com/provideal/random_ipsum/issues">issue tracker</a> to make sure someone already hasn't requested it and/or contributed it
45
+ * Fork the project
46
+ * Start a feature/bugfix branch
47
+ * Commit and push until you are happy with your contribution
48
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
49
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
50
+ * Feel free to send a pull request if you think others (me, for example) would like to have your change incorporated into future versions of random_ipsum.
51
+
52
+ h2. License
53
+
54
+ Copyright (c) 2010-2011 Peter Horn, <a href="http://www.provideal.net" target="_blank">Provideal GmbH</a>
55
+
56
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
57
+
58
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
59
+
60
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ module RandomIpsum
2
+
3
+ Words = %w{a ac accumsan adipiscing aenean aliquam aliquet amet ante
4
+ arcu at auctor augue bibendum blandit commodo condimentum congue
5
+ consectetuer consequat convallis cras curabitur cursus dapibus
6
+ diam dictum dignissim dolor donec dui duis egestas eget
7
+ eleifend elementum elit enim erat eros est et etiam eu euismod
8
+ facilisi facilisis fames faucibus felis fermentum feugiat
9
+ fringilla fusce gravida habitant hendrerit iaculis id imperdiet
10
+ in integer interdum ipsum justo lacinia lacus laoreet lectus
11
+ leo libero ligula lobortis lorem luctus maecenas magna
12
+ malesuada massa mattis mauris metus mi molestie mollis morbi
13
+ nam nec neque netus nibh nisi nisl non nonummy nulla nullam
14
+ nunc odio orci ornare pede pellentesque pharetra phasellus
15
+ placerat porta porttitor posuere praesent pretium proin
16
+ pulvinar purus quam quis quisque rhoncus risus rutrum sagittis
17
+ sapien scelerisque sed sem semper senectus sit sodales
18
+ sollicitudin suscipit suspendisse tellus tempor tempus
19
+ tincidunt tortor tristique turpis ullamcorper ultrices
20
+ ultricies urna ut varius vehicula vel velit venenatis
21
+ vestibulum vitae vivamus viverra volutpat vulputate}
22
+ N = Words.length
23
+ CapitalizedPercent = 15
24
+ CommaPercent = 18
25
+ ParagraphJoiner = "\n"
26
+ SentenceJoiner = " "
27
+
28
+ def self.words(n=5)
29
+ (1..n).map {
30
+ Words[rand(N)]
31
+ }.join(" ").capitalize
32
+ end
33
+
34
+ def self.sentence(words=10)
35
+ (1..words).map { |i|
36
+ w = Words[rand(N)]
37
+ w = w.capitalize if (i==1 or rand(100) < CapitalizedPercent)
38
+ w = w+"," if (i < words and rand(100) < CommaPercent)
39
+ w
40
+ }.join(" ") + "."
41
+ end
42
+
43
+ def self.paragraphs(n=2, s=2, w=12)
44
+ (1..n).map { |i|
45
+ (1..s).map { |j|
46
+ sentence(w + rand(4) - 2)
47
+ }.join(SentenceJoiner)
48
+ }.join(ParagraphJoiner)
49
+ end
50
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "random_ipsum"
6
+ s.version = "0.0.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.summary = "A randomized embedded lorem ipsum generator"
9
+ s.email = "info@provideal.net"
10
+ s.homepage = "http://github.com/provideal/random_ipsum"
11
+ s.description = "A randomized embedded lorem ipsum generator that can generate words, sentences, or paragraphs."
12
+ s.authors = ['Peter Horn']
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: random_ipsum
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Peter Horn
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-17 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: A randomized embedded lorem ipsum generator that can generate words, sentences, or paragraphs.
23
+ email: info@provideal.net
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - README.textile
32
+ - lib/random_ipsum.rb
33
+ - random_ipsum.gemspec
34
+ has_rdoc: true
35
+ homepage: http://github.com/provideal/random_ipsum
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ hash: 3
49
+ segments:
50
+ - 0
51
+ version: "0"
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.7
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: A randomized embedded lorem ipsum generator
68
+ test_files: []
69
+