lolem 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 ADDED
@@ -0,0 +1,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lolem.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/bin/lolem ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'lolem'
5
+
6
+ lolem = Lolem.new
7
+
8
+ words = ARGV.length > 0 ? ARGV[0].to_i : 30
9
+
10
+ puts lolem.words words
11
+
@@ -0,0 +1,45 @@
1
+ # This is a dumbed down markov chain implementation
2
+ # not very efficient, but works for what we need it for
3
+ class Generator
4
+
5
+ def initialize start = ''
6
+ # hash with a default value of another
7
+ # hash with a default value of zero
8
+ @map = Hash.new {|h,k| h[k] = Hash.new 0}
9
+ @last = start
10
+ end
11
+
12
+
13
+ # Link this thing to the one before
14
+ def add thing
15
+ @map[@last][@last = thing] += 1
16
+ end
17
+
18
+
19
+ # Get a statistically appropriate next item
20
+ def get given
21
+
22
+ # proportional to the total or the values
23
+ total = @map[given].values.inject {|a,b| a + b}
24
+ index = rand(total)
25
+
26
+ @map[given].each do |k,v|
27
+ return k if (index -= v) < 0
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+
34
+ # g = Generator.new
35
+ #
36
+ # t = 'this is a test, this'
37
+ # t.split(' ').each do |tok|
38
+ # g.add tok
39
+ # end
40
+ #
41
+ # last = ''
42
+ # for i in 0..20
43
+ # print last, ' '
44
+ # last = g.get last
45
+ # end
@@ -0,0 +1,3 @@
1
+ module Lolem
2
+ VERSION = "0.0.1"
3
+ end
data/lib/lolem.rb ADDED
@@ -0,0 +1,39 @@
1
+ require 'lolem/generator'
2
+
3
+ # This trains the generator with some source text
4
+ # which is then used to output something similiar
5
+ class Lolem
6
+
7
+ def initialize
8
+ @generator = Generator.new
9
+
10
+ SOURCE.split.each {|word| @generator.add word}
11
+ end
12
+
13
+ def words n
14
+ words = []
15
+ word = ''
16
+ (0...n).each do
17
+ word = @generator.get word
18
+ words << word
19
+ end
20
+
21
+ words.join ' '
22
+ end
23
+
24
+ SOURCE = <<-END
25
+ Lolem ipsum loller sit amet, consectetur adipisicing elit,
26
+ sed do eiusmod tempor incididunt ut lolerskates et dolore magna
27
+ aliqua. Ut enim lol ad minim veniam, quis nostrud exercitation
28
+ ullamco. Lol-athon nisi ut aliquip ex ea commodo consequat.
29
+ Duis aute irure loller in reprehenderit in voluptate velit
30
+ esse cillum dolore eu fugiat nulla pariatur. Lolburger sint
31
+ occaecat cupidatat non proident, sunt in lolcano qui officia
32
+ deserunt mollit lolz anim id est laborum.
33
+ END
34
+
35
+
36
+ end
37
+
38
+ #l = Lolem.new
39
+ #puts l.words(30).inspect
data/lolem.gemspec ADDED
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "lolem/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "lolem"
7
+ s.version = Lolem::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Ben Foxall"]
10
+ s.email = ["benfoxall@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Lorem Ipsum with more lol}
13
+ s.description = %q{Outputs lorem ipsum, with some lolz put in for good measure}
14
+
15
+ s.rubyforge_project = "lolem"
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
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lolem
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Ben Foxall
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-04 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Outputs lorem ipsum, with some lolz put in for good measure
23
+ email:
24
+ - benfoxall@gmail.com
25
+ executables:
26
+ - lolem
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - Rakefile
35
+ - bin/lolem
36
+ - lib/lolem.rb
37
+ - lib/lolem/generator.rb
38
+ - lib/lolem/version.rb
39
+ - lolem.gemspec
40
+ has_rdoc: true
41
+ homepage: ""
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ hash: 3
55
+ segments:
56
+ - 0
57
+ version: "0"
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project: lolem
70
+ rubygems_version: 1.4.2
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Lorem Ipsum with more lol
74
+ test_files: []
75
+