hiq 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0b32efd71e97bff2d927e2011ba99ba7953473f48e4c1006009109526589777
4
- data.tar.gz: bc77a0486a393cbe5dfbce67cd7fbed4b34c7ae74e55a48a370d38fff54ef330
3
+ metadata.gz: cd833461e418c6b7063c9fca031481cbcc56701dbe2eefbd199e62e024c0ccf5
4
+ data.tar.gz: '0758e4ffd51cd8535f8897d08609e318043b79a9c5678a6b6396abc835137c0e'
5
5
  SHA512:
6
- metadata.gz: e52601838f38c0880481672f69884b46a1be9b55779ee86de15fc277cfea20e1e104ca6985c316488c2b3a8a2d3edcb73cf7abc91a25f65c941703e9eae2774b
7
- data.tar.gz: ee1910c58e9c0458d281dcf476bcf90b3a74b0cf7797a94e1b2437f5f4fc35aace762db310dd78448167930867cbba411f00134dead04706eb500d49e4342ad0
6
+ metadata.gz: b7175772f454d0f840eb8633209f29db081fad385a05902a2b1ce4dcbf9556087dc5ab705d6c244b33be00ce5a1679ec61c519334b31df253e97fa9da91acea1
7
+ data.tar.gz: 36e2306085e7a93f9f1bf7b1cc39c61c8a5185d0f5911723bfb55133b79e9adc4a7e832a7f45e9c573dd22c7a706375da11177a9566f5baa2c6d1c2874ef2529
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ # rubocop:disable Metrics/MethodLength
4
+ # rubocop:disable Metrics/ClassLength
5
+
6
+ module Hiq
7
+ # Provided of filler for lines of haiku
8
+ class FillerLibrary
9
+ def self.interpolated_fillers
10
+ {
11
+ 1 => ['the X', 'a X', 'X house!'],
12
+ 2 => ['ghastly X', 'the pale X', 'fog X mince', 'No X jay', 'X the bottle', 'younger X', 'X bark tight',
13
+ 'with a X winds'],
14
+ 3 => ['shadow of X', 'X in silence', 'the subway X', 'In the pink X', 'behind an X', 'it bus X moon',
15
+ 'X the pages'],
16
+ 4 => ['X of my joy fade', 'X ends the autumn', 'letter to the X', 'X in the window', 'the lines of X',
17
+ 'the X scattered', 'flat fine go X call', 'from the childhood X'],
18
+ 5 => ['A spark of X above', 'Slayer wind the way X'],
19
+ 6 => ['the sad facade of X torn', 'afternoon from I wall X', 'X trees flutter over back ']
20
+ }
21
+ end
22
+
23
+ def self.fillers
24
+ {
25
+ 5 => [
26
+ 'empty riverside',
27
+ 'tears flow in the rain',
28
+ 'cheerful summer\'s charm',
29
+ 'A fallen leaves',
30
+ "New Year's 1ever",
31
+ 'of a dog hanged',
32
+ 'on the pavement',
33
+ "Valentine's Day",
34
+ 'a shadow boating',
35
+ 'airily balloons -',
36
+ 'cup on tea music',
37
+ 'evening coolness',
38
+ 'finally ad bass -',
39
+ 'override my amps',
40
+ 'A head lit shelter',
41
+ 'a bark flower pot',
42
+ 'and there escapes',
43
+ 'fan into too fast',
44
+ 'in the holy sense',
45
+ 'inside the sunset',
46
+ 'listening to down',
47
+ 'on a bird fingers',
48
+ 'the bag of autumn',
49
+ 'the bay of a dart',
50
+ 'the colored world',
51
+ 'after the pumpkin:',
52
+ 'at the sudden hair',
53
+ 'autumn leaf flames',
54
+ 'comes to an end...',
55
+ 'for the sun alone',
56
+ 'in the young weirs',
57
+ 'on a garbage truck',
58
+ 'snow fall of roses',
59
+ 'the saddled slower',
60
+ 'a wash before sheep',
61
+ 'affords hot the air',
62
+ 'in the Honkers mine',
63
+ 'in the fall flowing',
64
+ 'milk in the morning',
65
+ 'someone older bloom',
66
+ 'the ash leaves splay',
67
+ 'the lift of a moor,',
68
+ 'the same quiet rains',
69
+ '- A hole in the rise',
70
+ 'October wind through',
71
+ 'headlights, whiter-et',
72
+ 'i- two gold her hair',
73
+ 'just up kin oil beard',
74
+ 'passing my neighbor',
75
+ 'pierce drippy second',
76
+ 'shells in the mirror',
77
+ 'the sound of a trash',
78
+ 'the wild powder sack',
79
+ 'the mister rams trap',
80
+ 'from the first baleen',
81
+ 'my mind like a candle',
82
+ 'snow, leaves two pies',
83
+ 'the scent of red hair',
84
+ 'a flank of calm mosque',
85
+ 'a fan a across',
86
+ "sin's that dawn light tide"
87
+ ],
88
+ 7 => [
89
+ 'the vain wind of summer blows',
90
+ 'gentle breeze upon a mountain',
91
+ 'a frog jumps into a well',
92
+ 'around my of finally',
93
+ 'roses in the forecast',
94
+ 'follow just overflowed',
95
+ 'of a traveling machine',
96
+ 'of allowed in the blade',
97
+ 'under a clamping lilac -',
98
+ 'on the Pony.. and snuffer',
99
+ 'the blinded on a red road',
100
+ 'the scent of lemon petals',
101
+ 'the islands in the grab use',
102
+ 'the noise of a carrier bag',
103
+ 'young women clean morning -',
104
+ 'an expecting moon His breaks',
105
+ 'the boyfriend of my pocket -',
106
+ 'Spring warding stray or a glass',
107
+ 'and two pour face all the dock',
108
+ 'i wish i X on buy band train',
109
+ 'in the fresh of old plane candle',
110
+ "we're down the school of her hands"
111
+ ]
112
+ }
113
+ end
114
+
115
+ attr_reader :ifillers, :cfillers
116
+
117
+ def initialize
118
+ @ifillers = FillerLibrary.interpolated_fillers
119
+ @cfillers = FillerLibrary.fillers
120
+ end
121
+
122
+ def get_const_filler(filler_length)
123
+ cfillers[filler_length].delete(cfillers[filler_length].sample)
124
+ end
125
+
126
+ def get_interpolated_filler(filler_length)
127
+ ifillers[filler_length].delete(ifillers[filler_length].sample)
128
+ end
129
+ end
130
+ end
131
+ # rubocop:enable Metrics/MethodLength
132
+ # rubocop:enable Metrics/ClassLength
@@ -5,15 +5,16 @@ module Hiq
5
5
  class LineComposer
6
6
  include Syllabizable
7
7
 
8
- attr_reader :line, :target_syllable_length
8
+ attr_reader :line, :target_syllable_length, :library
9
9
 
10
- def self.call(line, target_syllable_length:)
11
- new(line, target_syllable_length: target_syllable_length).call
10
+ def self.call(line, target_syllable_length:, library:)
11
+ new(line, target_syllable_length: target_syllable_length, library: library).call
12
12
  end
13
13
 
14
- def initialize(line, target_syllable_length:)
14
+ def initialize(line, target_syllable_length:, library:)
15
15
  @line = line
16
16
  @target_syllable_length = target_syllable_length
17
+ @library = library
17
18
  end
18
19
 
19
20
  def call
@@ -29,35 +30,9 @@ module Hiq
29
30
  end
30
31
 
31
32
  def filled_line
32
- return [fillers[target_syllable_length].sample] if line.empty?
33
+ return [library.get_const_filler(target_syllable_length)] if line.empty?
33
34
 
34
- [interpolated_fillers[target_syllable_length][syllable_gap_size].gsub('X', line.first)]
35
- end
36
-
37
- def interpolated_fillers
38
- {
39
- 5 => {
40
- 1 => 'the X',
41
- 2 => 'ghastly X',
42
- 3 => 'shadow of X',
43
- 4 => 'X of my joy fade'
44
- },
45
- 7 => {
46
- 1 => 'a X',
47
- 2 => 'the pale X',
48
- 3 => 'X in silence',
49
- 4 => 'X ends the autumn',
50
- 5 => 'A spark of X above',
51
- 6 => 'the sad facade of X torn'
52
- }
53
- }
54
- end
55
-
56
- def fillers
57
- {
58
- 5 => ['empty riverside', 'tears flow in the rain', 'cheerful summer\'s charm'],
59
- 7 => ['the vain wind of summer blows', 'gentle breeze upon a mountain', 'a frog jumps into a well']
60
- }
35
+ [library.get_interpolated_filler(syllable_gap_size).gsub('X', line.first)]
61
36
  end
62
37
  end
63
38
  end
data/lib/hiq/haiku.rb CHANGED
@@ -20,8 +20,10 @@ module Hiq
20
20
  def haiku_lines
21
21
  WordChecker.validate!(words)
22
22
 
23
+ library = FillerLibrary.new
24
+
23
25
  [5, 7, 5].zip(line_templates).map do |syllabes, line|
24
- LineComposer.call(line, target_syllable_length: syllabes)
26
+ LineComposer.call(line, target_syllable_length: syllabes, library: library)
25
27
  end
26
28
  end
27
29
 
data/lib/hiq/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hiq
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
data/lib/hiq.rb CHANGED
@@ -4,6 +4,7 @@ require 'hiq/version'
4
4
  require 'hiq/syllabizable'
5
5
  require 'hiq/exceptions'
6
6
  require 'hiq/domain/word_checker'
7
+ require 'hiq/domain/filler_library'
7
8
  require 'hiq/domain/line_composer'
8
9
  require 'hiq/haiku'
9
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Taras
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-20 00:00:00.000000000 Z
11
+ date: 2022-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -87,6 +87,7 @@ extensions: []
87
87
  extra_rdoc_files: []
88
88
  files:
89
89
  - lib/hiq.rb
90
+ - lib/hiq/domain/filler_library.rb
90
91
  - lib/hiq/domain/line_composer.rb
91
92
  - lib/hiq/domain/word_checker.rb
92
93
  - lib/hiq/exceptions.rb