ipsum 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 +4 -0
- data/Gemfile +3 -0
- data/Rakefile +2 -0
- data/ipsum.gemspec +21 -0
- data/lib/ipsum.rb +36 -0
- data/lib/ipsum/version.rb +3 -0
- metadata +70 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/ipsum.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ipsum/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ipsum"
|
7
|
+
s.version = Ipsum::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Clive Crous"]
|
10
|
+
s.email = ["clive@crous.co.za"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/ipsum"
|
12
|
+
s.summary = %q{Quickly generate text-like filler ala Lorem Ipsum}
|
13
|
+
s.description = %q{Generate words or sentences for filler text while developing anything which requires text. Most people know this as "Lorem Ipsum"}
|
14
|
+
|
15
|
+
s.rubyforge_project = "ipsum"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
data/lib/ipsum.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'ipsum/version'
|
2
|
+
|
3
|
+
class Ipsum
|
4
|
+
|
5
|
+
MAX_CHUNKS = 10
|
6
|
+
|
7
|
+
CHUNKS = [ %w|b c d f g h j k l m n p q r s t v w x y z st tr ch dr th sh gh|,
|
8
|
+
%w|a e i o u ou ae ai| ]
|
9
|
+
|
10
|
+
def self.word
|
11
|
+
chunks = 1 + rand(4)
|
12
|
+
chunks += 1 while chunks <= MAX_CHUNKS && rand(2) == 0
|
13
|
+
|
14
|
+
chunkset_counter = chunks == 1 ? 1 : rand(2)
|
15
|
+
|
16
|
+
word = ''
|
17
|
+
|
18
|
+
chunks.times do
|
19
|
+
chunkset = CHUNKS[ chunkset_counter % 2 ]
|
20
|
+
chunkset_counter += 1
|
21
|
+
word += chunkset[ rand( chunkset.length ) ]
|
22
|
+
end
|
23
|
+
|
24
|
+
word
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.sentence( words = rand(5) + 3 )
|
29
|
+
( [ nil ] * words ).map{|n|self.word}.join(' ').capitalize + '.'
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.sentences( amount = rand(5) + 3 )
|
33
|
+
( [ nil ] * amount ).map{|n|self.sentence}.join(' ')
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ipsum
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Clive Crous
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-01-18 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Generate words or sentences for filler text while developing anything which requires text. Most people know this as "Lorem Ipsum"
|
22
|
+
email:
|
23
|
+
- clive@crous.co.za
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
|
+
files:
|
31
|
+
- .gitignore
|
32
|
+
- Gemfile
|
33
|
+
- Rakefile
|
34
|
+
- ipsum.gemspec
|
35
|
+
- lib/ipsum.rb
|
36
|
+
- lib/ipsum/version.rb
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: http://rubygems.org/gems/ipsum
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
segments:
|
52
|
+
- 0
|
53
|
+
version: "0"
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
segments:
|
60
|
+
- 0
|
61
|
+
version: "0"
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project: ipsum
|
65
|
+
rubygems_version: 1.3.7
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: Quickly generate text-like filler ala Lorem Ipsum
|
69
|
+
test_files: []
|
70
|
+
|