jekyll-kw-loremipsum 0.1.1 → 0.2.0
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 +4 -4
- data/lib/Song.rb +25 -0
- data/lib/jekyll-kw-loremipsum/parser.rb +28 -50
- data/lib/jekyll-kw-loremipsum/parser_parameter.rb +72 -0
- data/lib/jekyll-kw-loremipsum/version.rb +2 -1
- data/lib/jekyll-kw-loremipsum.rb +20 -8
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f63b8df6e0a328a92eb4c51de81126a4f53cd58c1c78128e365b6014acdaa5c2
|
4
|
+
data.tar.gz: a1c94cdbec62ab6a8635d5451f807ab89a428a34c3d5e24dbd26c8a91eac43be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 166aa98bcd530347f672b9cdc696143cf6a05f2e98f3bb9c7e031f937bd0edd432c09f3714386c5fb9cfe266516d16211600537cedbdb055d8fc553595ca8ddc
|
7
|
+
data.tar.gz: cee0a4b3da309ea0d2e11d85dc8a3342fa49d6c39c4e8f5b446051e2da7eb6c0262ae623b62f4c8b4a7e0109d2e00bf7fab22a46271a061200306d54546fee8d
|
data/lib/Song.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module KargWare
|
4
|
+
# A class Song for music
|
5
|
+
class Song
|
6
|
+
attr_reader :name, :artist, :duration
|
7
|
+
|
8
|
+
# attr_reader :name, :artist
|
9
|
+
|
10
|
+
def initialize(name, artist, duration)
|
11
|
+
@name = name
|
12
|
+
@artist = artist
|
13
|
+
@duration = duration
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
# format('%s (%s) [ %s ]', @name, @artist, @duration)
|
18
|
+
"#{@name} (#{@artist}) [ #{@duration} ]"
|
19
|
+
end
|
20
|
+
|
21
|
+
def echo
|
22
|
+
puts to_s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,77 +1,55 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'jekyll-kw-loremipsum/parser_parameter'
|
4
|
+
|
3
5
|
module Jekyll
|
4
6
|
module KargWare
|
5
7
|
module LoremIpsum
|
6
8
|
# LoremIpsum parser class
|
7
9
|
class Parser
|
10
|
+
attr_reader :config
|
11
|
+
|
8
12
|
# https://loremipsum.de/downloads/original.txt
|
9
|
-
@@words_lorem_ipsum =
|
13
|
+
@@words_lorem_ipsum = 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.'
|
10
14
|
# @@words_lorem_ipsum = "Lorem ipsum dolor sit amet, consetetur sadipscing"
|
11
15
|
|
12
16
|
@@arr_words_lorem_ipsum = nil
|
13
17
|
def self.arr_words_lorem_ipsum
|
14
|
-
if @@arr_words_lorem_ipsum
|
15
|
-
@@arr_words_lorem_ipsum = @@words_lorem_ipsum.split(" ")
|
16
|
-
end
|
18
|
+
@@arr_words_lorem_ipsum = @@words_lorem_ipsum.split(' ') if @@arr_words_lorem_ipsum.nil?
|
17
19
|
@@arr_words_lorem_ipsum
|
18
20
|
end
|
19
21
|
|
20
|
-
def self.get_words(cnt, random=false)
|
21
|
-
if random
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def self.get_words(cnt, random = false)
|
23
|
+
arr_part = if random
|
24
|
+
arr_words_lorem_ipsum.sample(cnt)
|
25
|
+
else
|
26
|
+
arr_words_lorem_ipsum.slice(0, cnt)
|
27
|
+
end
|
26
28
|
|
27
|
-
arr_part.join(
|
29
|
+
arr_part.join(' ').chomp(',')
|
28
30
|
end
|
29
31
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
def self.create_parameters(input)
|
33
|
+
parameters = ParserParameter.new
|
34
|
+
parameters.init(input)
|
35
|
+
parameters
|
34
36
|
end
|
35
37
|
|
36
|
-
def
|
37
|
-
|
38
|
-
@words = 40
|
39
|
-
# 3p == 3 paragraphs (default -1)
|
40
|
-
# 7miw == 7 Min words in para (default 40)
|
41
|
-
# 15maw == 15 Max words in para (default 40)
|
42
|
-
@paras = -1
|
43
|
-
@minw = 40
|
44
|
-
@maxw = 40
|
45
|
-
# random == Should the words be random (or ordered) (default false)
|
46
|
-
@random = false
|
47
|
-
|
48
|
-
matched_words = str.strip.match(/\d+w/)
|
49
|
-
matched_paras = str.strip.match(/\d+p/)
|
50
|
-
matched_minw = str.strip.match(/\d+miw/)
|
51
|
-
matched_maxw = str.strip.match(/\d+maw/)
|
52
|
-
matched_random = str.strip.match(/random/)
|
53
|
-
|
54
|
-
# puts "Parser: W: %s P: %s MiW: %s MaW: %s Random: $s" % [matched_words, matched_paras, matched_minw, matched_maxw, matched_random]
|
55
|
-
|
56
|
-
@words = matched_words[0].strip.sub("w", "").to_i if matched_words
|
57
|
-
@paras = matched_paras[0].strip.sub("p", "").to_i if matched_paras
|
58
|
-
@minw = matched_minw[0].strip.sub("miw", "").to_i if matched_minw
|
59
|
-
@maxw = matched_maxw[0].strip.sub("maw", "").to_i if matched_maxw
|
60
|
-
@random = true if matched_random
|
38
|
+
def initialize(options = {})
|
39
|
+
@config = Jekyll::KargWare::LoremIpsum::Configuration.new(options)
|
61
40
|
end
|
62
41
|
|
63
|
-
|
64
|
-
|
65
|
-
|
42
|
+
# TODO: Fucntion "get_lorem_ipsum" should be parse
|
43
|
+
def get_lorem_ipsum(input)
|
44
|
+
parameters = Jekyll::KargWare::LoremIpsum::Parser.create_parameters(input)
|
66
45
|
|
67
|
-
|
68
|
-
|
69
|
-
Jekyll::KargWare::LoremIpsum::Parser.get_words(@words, @random)
|
46
|
+
if parameters.use_words
|
47
|
+
Jekyll::KargWare::LoremIpsum::Parser.get_words(parameters.words, parameters.random)
|
70
48
|
else
|
71
|
-
arr_oneliner =
|
72
|
-
for i in 1
|
73
|
-
r = rand(
|
74
|
-
arr_oneliner += [Jekyll::KargWare::LoremIpsum::Parser.get_words(r,
|
49
|
+
arr_oneliner = []
|
50
|
+
for i in 1..parameters.paras
|
51
|
+
r = rand(parameters.minw..parameters.maxw)
|
52
|
+
arr_oneliner += [Jekyll::KargWare::LoremIpsum::Parser.get_words(r, parameters.random)]
|
75
53
|
end
|
76
54
|
# arr_oneliner.join("\n") # No line wrap
|
77
55
|
# arr_oneliner.join("<br>") # OK, but no 2nd p
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Jekyll
|
4
|
+
module KargWare
|
5
|
+
module LoremIpsum
|
6
|
+
# Parameters for parser class
|
7
|
+
class ParserParameter
|
8
|
+
attr_reader :words, :paras, :minw, :maxw, :random
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
super
|
12
|
+
|
13
|
+
# 1w == 1 word (default 40)
|
14
|
+
@words = 40
|
15
|
+
# 3p == 3 paragraphs (default 1)
|
16
|
+
# 7miw == 7 Min words in para (default 40)
|
17
|
+
# 15maw == 15 Max words in para (default 40)
|
18
|
+
@paras = 1
|
19
|
+
@minw = 40
|
20
|
+
@maxw = 40
|
21
|
+
# random == Should the words be random (or ordered) (default false)
|
22
|
+
@random = false
|
23
|
+
end
|
24
|
+
|
25
|
+
def init(parameters = nil)
|
26
|
+
return if parameters.nil?
|
27
|
+
|
28
|
+
# TODO: Min > Max --> Warning
|
29
|
+
# TODO: unkown words, e.g. "p, word, min, max" --> Warning
|
30
|
+
|
31
|
+
matched_words = parameters.strip.match(/\d+w/)
|
32
|
+
matched_paras = parameters.strip.match(/\d+p/)
|
33
|
+
matched_minw = parameters.strip.match(/\d+miw/)
|
34
|
+
matched_maxw = parameters.strip.match(/\d+maw/)
|
35
|
+
matched_random = parameters.strip.match(/random/)
|
36
|
+
|
37
|
+
# puts "Parser: W: %s P: %s MiW: %s MaW: %s Random: $s" % [matched_words, matched_paras, matched_minw, matched_maxw, matched_random]
|
38
|
+
|
39
|
+
@words = matched_words[0].strip.sub('w', '').to_i if matched_words
|
40
|
+
@paras = matched_paras[0].strip.sub('p', '').to_i if matched_paras
|
41
|
+
@minw = matched_minw[0].strip.sub('miw', '').to_i if matched_minw
|
42
|
+
@maxw = matched_maxw[0].strip.sub('maw', '').to_i if matched_maxw
|
43
|
+
@random = true if matched_random
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_str_random
|
47
|
+
@random ? 'random' : 'sorted'
|
48
|
+
end
|
49
|
+
|
50
|
+
def use_words
|
51
|
+
@paras.nil? || @paras == 1
|
52
|
+
end
|
53
|
+
|
54
|
+
def use_paragraphs
|
55
|
+
!use_words
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_s
|
59
|
+
if use_words
|
60
|
+
format('W: %04d (%s)', @words, to_str_random)
|
61
|
+
else
|
62
|
+
format('P: %04d (%s) MiW: %04d MaW: %04d', @paras, to_str_random, @minw, @maxw)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def echo
|
67
|
+
puts to_s
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/jekyll-kw-loremipsum.rb
CHANGED
@@ -1,30 +1,42 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'jekyll-kw-loremipsum/parser'
|
4
|
+
|
3
5
|
module Jekyll
|
4
6
|
module KargWare
|
5
7
|
module LoremIpsum
|
6
8
|
class Error < StandardError; end
|
7
9
|
class Exception < Gem::Exception; end
|
8
10
|
|
11
|
+
module_function def get_plugin_config(context)
|
12
|
+
if defined? context.registers[:site].config
|
13
|
+
context.registers[:site].config[Jekyll::KargWare::LoremIpsum::RUBYGEM_NAME] || {}
|
14
|
+
else
|
15
|
+
{}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# LoremIpsum tag {% kw_lorem_ipsum input %} for Jekyll
|
9
20
|
class LoremIpsumTag < Liquid::Tag
|
10
21
|
# safe true
|
11
22
|
# priority :low
|
12
23
|
|
13
|
-
def initialize(tag_name,
|
24
|
+
def initialize(tag_name, input, tokens)
|
14
25
|
super
|
15
|
-
@
|
16
|
-
tokens = tokens
|
17
|
-
|
18
|
-
@parser = Jekyll::KargWare::LoremIpsum::Parser.new(@text)
|
19
|
-
# @parser.echo_config
|
26
|
+
@input = input.to_s.strip
|
20
27
|
end
|
21
28
|
|
22
29
|
def render(context)
|
23
|
-
|
30
|
+
parser = Jekyll::KargWare::LoremIpsum::Parser.new(
|
31
|
+
Jekyll::KargWare::LoremIpsum.get_plugin_config(context)
|
32
|
+
)
|
33
|
+
|
34
|
+
# parser = Jekyll::KargWare::LoremIpsum::Parser.new(@input)
|
35
|
+
parser.get_lorem_ipsum(@input)
|
24
36
|
end
|
25
37
|
end
|
26
38
|
end
|
27
39
|
end
|
28
40
|
end
|
29
41
|
|
30
|
-
Liquid::Template.register_tag(
|
42
|
+
Liquid::Template.register_tag(Jekyll::KargWare::LoremIpsum::JEKYLL_TAGNAME, Jekyll::KargWare::LoremIpsum::LoremIpsumTag)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-kw-loremipsum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicolas Karg
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-03-
|
12
|
+
date: 2022-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jekyll
|
@@ -43,9 +43,11 @@ extensions: []
|
|
43
43
|
extra_rdoc_files: []
|
44
44
|
files:
|
45
45
|
- README.md
|
46
|
+
- lib/Song.rb
|
46
47
|
- lib/jekyll-kw-loremipsum.rb
|
47
48
|
- lib/jekyll-kw-loremipsum/configuration.rb
|
48
49
|
- lib/jekyll-kw-loremipsum/parser.rb
|
50
|
+
- lib/jekyll-kw-loremipsum/parser_parameter.rb
|
49
51
|
- lib/jekyll-kw-loremipsum/version.rb
|
50
52
|
homepage: https://notes.n13.org/rubygems
|
51
53
|
licenses:
|