glueckskeks 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: c8d596fe9089e8325ffdda0c275925c96df62946
4
- data.tar.gz: e76338be2e23856908d413b9a2528c5a2a753dcf
2
+ SHA256:
3
+ metadata.gz: 35776ff5d4ad9e9ee99f89eb12bade8e7d931bd56bb1776ead124d2c3e6afd43
4
+ data.tar.gz: 9602d4f151f178c0ec382a8a3e9e572516293ec573b800ea2e66b8e471d5fa9a
5
5
  SHA512:
6
- metadata.gz: 91215a0d6b09e922b73d9d7b6106868e48a09795624453c05fd2c2c759cfabe6d3228f64fec859100d7722595ed769a8e6692d1cd690d256184feb387775916c
7
- data.tar.gz: d984b3216a4b6c19fff24fb31d03ac6f034517cefb424db94f5b5383cf9f59c4788ab0946c9d013207ba4933bffe7b665662a0959013469cad4a25b8b96ea59d
6
+ metadata.gz: 7d356831577a396c218aa7a6ad269ba41bf5b6d42584f1fa169d277972f2e32407301a1d7410dbd33b702c1fb4213666504054ec38413ade762e439c994c9ac8
7
+ data.tar.gz: a1455eff941a54c79b8be1e3c0844e9149b78553413c405745167e851756dc4ecdd11d43bb818032e19ce84a3df8a6961bc7421ca5e1d00c8177a711eb069fed
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # Glueckskeks
2
2
 
3
- Use 'corpus' files specified in `corpus/` to create random phrases (or other things).
3
+ Use 'corpus' files specified in `corpus/` to create random phrases (or other things) on the command line.
4
4
 
5
5
  To experiment with that code, run `bin/console` for an interactive prompt.
6
6
 
7
- Licensed under the GPLv3+ (see the `COPYING` file included) , Copyright 2017 Felix Wolfsteller.
7
+ Licensed under the GPLv3+ (see the `COPYING` file included) , Copyright 2017,2019 Felix Wolfsteller.
8
8
 
9
9
  ## Installation
10
10
 
@@ -38,7 +38,7 @@ dog
38
38
  ```
39
39
 
40
40
  . That example should show that there are three files, `corpus/base.corpus`, `corpus/adj.corpus` and `corpus/noun.corpus` with the respective content.
41
- The `base.corpus` file will be read first and stuff in dangerous brackets (`<stuff>`) will be replaced by **one of the values of the respective file** (`corpus/stuff.corpus`, or in the example above, `adj.corpus` and `noun.corpus` respectively. Note that thes "variable"-names do not include the file ending `.corpus`.
41
+ The `base.corpus` file will be read first and stuff in dangerous brackets (`<stuff>`) will be replaced by **one of the values (== lines) of the respective file** (`corpus/stuff.corpus`, or in the example above, `adj.corpus` and `noun.corpus` respectively). Note that thes "variable"-names do not include the file ending `.corpus`.
42
42
 
43
43
  To produce a random selection, execute `glueckskeks` (depending on your setup this might be `bundle exec exe/glueckskeks`), e.g.
44
44
 
@@ -48,11 +48,26 @@ black cat
48
48
  -> bc
49
49
  ```
50
50
 
51
- The last line will be your phrase in passwordish-abbreviation.
51
+ The last line ("bc" in that example) will be your phrase in passwordish-abbreviation.
52
+
53
+ Note that the starting node ('base') and the directory where the corpus files are located can be changed. Run `glueckskeks --help` to get this or a similar output:
54
+
55
+ $ glueckskeks --help
56
+ Usage: exe/glueckskeks
57
+
58
+ Generate phrase from files (default: in corpus/).
59
+
60
+ -b, --base=BASE Start extension from BASE file (default: 'base')
61
+ -c, --corpus=DIRECTORY Read .corpus files from DIRECTORY (default: './corpus')
62
+ -d, --debug Print debug messages to STDOUT
63
+ --[no-]capitalize Capitalize first letter of output (default: true)
64
+ -h, --help Show this help and exit.
65
+ --version Show version and exit.
66
+
52
67
 
53
68
  ## "Gluckskeks" wtf - where are the vowels
54
69
 
55
- "Glueckskeks" is the German term for the wisdom-containing thing that you get served e.g. in chinese restaurants (in Germany).
70
+ "Glueckskeks" is the German term for the wisdom-containing thing that you get served e.g. in chinese restaurants (in Germany). Like, remember the internet-meme "That wasn't chicken"".
56
71
 
57
72
  ## Development
58
73
 
data/exe/glueckskeks CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'glueckskeks'
4
4
  require 'optparse'
5
5
 
6
- options = {corpus: 'corpus', base: 'base'}
6
+ options = {corpus: 'corpus', base: 'base', capitalize: true}
7
7
 
8
8
  optparse = OptionParser.new do |opts|
9
9
  opts.banner = "Usage: #{$PROGRAM_NAME}"
@@ -14,12 +14,15 @@ optparse = OptionParser.new do |opts|
14
14
  opts.on('-b', '--base=BASE', 'Start extension from BASE file (default: \'base\')') do |b|
15
15
  options[:base] = b
16
16
  end
17
- opts.on('-c', '--corpus=DIRECTORY', 'Read .corpus files from DIRECTORY (default: \'./corpus\'') do |c|
17
+ opts.on('-c', '--corpus=DIRECTORY', 'Read .corpus files from DIRECTORY (default: \'./corpus\')') do |c|
18
18
  options[:corpus] = c
19
19
  end
20
20
  opts.on('-d', '--debug', 'Print debug messages to STDOUT') do |d|
21
21
  options[:debug] = d
22
22
  end
23
+ opts.on('--[no-]capitalize', 'Capitalize first letter of output (default: true)') do |c|
24
+ options[:capitalize] = c
25
+ end
23
26
  opts.on_tail('--version', 'Show version and exit.') do
24
27
  puts "#{$PROGRAM_NAME} #{Glueckskeks::VERSION}"
25
28
  exit 0
@@ -33,5 +36,12 @@ end.parse!
33
36
  Glueckskeks.logger.level = options[:debug] ? Logger::DEBUG : Logger::INFO
34
37
 
35
38
  phrase = Glueckskeks.generate(options[:corpus], options[:base])
39
+ if options[:capitalize]
40
+ phrase = phrase[0].upcase + phrase[1..-1]
41
+ end
42
+
36
43
  puts phrase
37
44
  puts Glueckskeks::Collapser.collapse(phrase)
45
+
46
+ # Leave the stage with grace.
47
+ exit 0
data/glueckskeks.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.13"
24
+ spec.add_development_dependency "bundler", "> 1.13"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "minitest", "~> 5.0"
27
27
  end
@@ -1,5 +1,7 @@
1
1
  module Glueckskeks
2
2
  class CorpusReader
3
+ # Returned "Corpus"" is a map from a name (originating from filename)
4
+ # to the lines of that file
3
5
  def self.read_corpus_files(corpus_dir='corpus')
4
6
  result_map = {}
5
7
 
@@ -6,8 +6,8 @@ module Glueckskeks
6
6
  if !(corpus.has_key? type)
7
7
  Glueckskeks.logger.error "No corpus entry for #{type} found"
8
8
  end
9
- replace_with = corpus[type].sample
10
- str.gsub!("\<#{type}\>", replace_with)
9
+ replace_with = corpus[type].sample
10
+ str.sub!("\<#{type}\>", replace_with)
11
11
  end
12
12
  str
13
13
  end
@@ -1,5 +1,6 @@
1
1
  module Glueckskeks
2
2
  class Templater
3
+ # param @tmpl can contain variables (like "<word> <sign>")
3
4
  def self.fill(tmpl, corpus)
4
5
  orig_tmpl = tmpl.dup
5
6
  while (tmpl=Substitutor.replace(tmpl, corpus)) != orig_tmpl
@@ -1,3 +1,3 @@
1
1
  module Glueckskeks
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2".freeze
3
3
  end
data/lib/glueckskeks.rb CHANGED
@@ -19,13 +19,14 @@ module Glueckskeks
19
19
  def self.generate(corpus_dir='corpus', entry='base')
20
20
  @corpus = CorpusReader.read_corpus_files(corpus_dir)
21
21
  if @corpus && @corpus.empty?
22
- STDERR.puts "Empty corpus, are any data files present in ./corpus ?"
22
+ STDERR.puts "Empty corpus, are any data files present in ./corpus/ ?"
23
23
  exit 1
24
24
  end
25
25
  if @corpus[entry].nil? || @corpus[entry].empty?
26
26
  STDERR.puts "Corpus does not contain a base (corpus/base.corpus) file, or it does not contain any patterns."
27
27
  exit 2
28
28
  end
29
+ # Start with a line from entry corpus
29
30
  Templater.fill(@corpus[entry].sample, @corpus)
30
31
  end
31
32
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: glueckskeks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Wolfsteller
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-26 00:00:00.000000000 Z
11
+ date: 2019-11-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.13'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.13'
27
27
  - !ruby/object:Gem::Dependency
@@ -97,8 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 2.6.12
100
+ rubygems_version: 3.0.3
102
101
  signing_key:
103
102
  specification_version: 4
104
103
  summary: Use grammar(ish) files to create random phrases.