kanal 0.4.1 → 0.4.3

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: 22224712e17434c60d3b437d44a35a5a997dd739cddcf53eb365d588fdf19fcd
4
- data.tar.gz: f6677a4a8bc6eacf2e41469ba4a36da1b324d3b7d9092ae9271aa1b9f3fa8be6
3
+ metadata.gz: b0a793b05b3b6a5848b173907c41e64b0fd40c1a68b7b992c784923dbd34c1df
4
+ data.tar.gz: 01cab2e1b68b1c0d7559208a47883caccfd7a7c1019f4e740c12bdb28129e329
5
5
  SHA512:
6
- metadata.gz: 5e1416fb809513b53627cb120d8b09dfb76cae30f952de0212a1c2edde48e01d733afb122189230d0e6426dba812d143a8b2fc35b8561fba95954ea0b0bccbe2
7
- data.tar.gz: 3dcc90d49fa16f4df0482d77a94f3f21a7ddc12742983a8925714199100284bfb4d84a96bef19aa289c3ad1ebcc21996d3a27fb9874837b24ca343ba53f700d6
6
+ metadata.gz: dca772528cfca7d06de8f48c2a3da90fc99615d1ad06b2dd0b6d6254e68e989937fb22b884aef9219a3a9d139dc2dc7a8d8e786e999dd52e81209739fc6d2d28
7
+ data.tar.gz: 7d8c3a80d26ceb6245154b694cafc8ca08fd742468cbf3fb6c332a3f064eee84ec20539a973d77494483f2a716d768a0c25fd80d06d9afba27d6d529f1d87882
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.3] 2023-03-30
4
+ - New condition for button pressed
5
+ - Input property button_pressed
6
+
7
+ ## [0.4.2] 2023-03-22
8
+ - Adding any number of loggers can be now done with core.add_logger(l) - where l is logger that have same methods as default ruby logger (debug, warn, fatal, etc)
9
+ - To get logger into your class you can include Kanal::Core::Logging::Logger - this will give you method .logger to get logger
10
+ - Batteries now have .keyboard output property and several conditions for input
11
+
3
12
  ## [0.4.1] 2023-03-16
4
13
  - Added Attachment that can be used inside new input parameters in Batteries plugin
5
14
  - New input and output parameters in Batteries plugin: image, audio, file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kanal (0.5.0)
4
+ kanal (0.4.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -105,4 +105,4 @@ DEPENDENCIES
105
105
  yard
106
106
 
107
107
  BUNDLED WITH
108
- 2.3.19
108
+ 2.4.5
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../logger/logging"
3
+ require_relative "../logging/logger"
4
4
 
5
5
  module Kanal
6
6
  module Core
@@ -8,7 +8,7 @@ module Kanal
8
8
  # Base class for conditions
9
9
  # with this class you can
10
10
  class Condition
11
- include Logging
11
+ include Logging::Logger
12
12
 
13
13
  attr_reader :name
14
14
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../logger/logging"
3
+ require_relative "../logging/logger"
4
4
 
5
5
  module Kanal
6
6
  module Core
@@ -8,7 +8,7 @@ module Kanal
8
8
  # This class helps creating conditions in dsl way,
9
9
  # with using helper methods
10
10
  class ConditionCreator
11
- include Logging
11
+ include Logging::Logger
12
12
 
13
13
  def initialize(name)
14
14
  @name = name
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "./condition"
4
4
  require_relative "./condition_creator"
5
- require_relative "../logger/logging"
5
+ require_relative "../logging/logger"
6
6
 
7
7
  module Kanal
8
8
  module Core
@@ -11,7 +11,7 @@ module Kanal
11
11
  # It is served as some kind of namespace for conditions, with specific
12
12
  # name of pack and helper methods
13
13
  class ConditionPack
14
- include Logging
14
+ include Logging::Logger
15
15
 
16
16
  attr_reader :name
17
17
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "./condition_pack"
4
4
  require_relative "./condition_creator"
5
- require_relative "../logger/logging"
5
+ require_relative "../logging/logger"
6
6
 
7
7
  module Kanal
8
8
  module Core
@@ -10,7 +10,7 @@ module Kanal
10
10
  # This class helps in condition pack creation
11
11
  # with the help of dsl
12
12
  class ConditionPackCreator
13
- include Logging
13
+ include Logging::Logger
14
14
 
15
15
  TEMP_NAME = :temp_name
16
16
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../logger/logging"
3
+ require_relative "../logging/logger"
4
4
 
5
5
  module Kanal
6
6
  module Core
@@ -8,7 +8,7 @@ module Kanal
8
8
  # This class contains all needed functionality to store,
9
9
  # search conditions
10
10
  class ConditionStorage
11
- include Logging
11
+ include Logging::Logger
12
12
 
13
13
  def initialize
14
14
  @condition_packs = []
@@ -8,8 +8,8 @@ require_relative "./helpers/parameter_registrator"
8
8
  require_relative "./plugins/plugin"
9
9
  require_relative "./input/input"
10
10
  require_relative "./services/service_container"
11
- require_relative "./logger/logging"
12
-
11
+ require_relative "./logging/logger"
12
+ require_relative "./logging/configuration"
13
13
 
14
14
  module Kanal
15
15
  module Core
@@ -36,6 +36,7 @@ module Kanal
36
36
  include Plugins
37
37
  include Hooks
38
38
  include Services
39
+ include Logging::Logger
39
40
  include Logging
40
41
 
41
42
  # @return [Kanal::Core::Conditions::ConditionStorage]
@@ -223,9 +224,14 @@ module Kanal
223
224
  def register_hooks
224
225
  @hooks.register :input_just_created # input
225
226
  @hooks.register :input_before_router # input
227
+ @hooks.register :output_just_created # input, output
226
228
  @hooks.register :output_before_returned # input, output
227
229
  end
228
230
 
231
+ def add_logger(logger)
232
+ Kanal::Core::Logging::Configuration.add_logger logger
233
+ end
234
+
229
235
  private :register_hooks
230
236
  end
231
237
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "parameter_bag"
4
- require_relative "../logger/logging"
4
+ require_relative "../logging/logger"
5
5
 
6
6
  module Kanal
7
7
  module Core
@@ -10,7 +10,7 @@ module Kanal
10
10
  # and if they are has needed by registrator allowances, types etc, whatever
11
11
  # registrator rules are stored for property
12
12
  class ParameterBagWithRegistrator < ParameterBag
13
- include Logging
13
+ include Logging::Logger
14
14
 
15
15
  def initialize(registrator)
16
16
  super()
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "../logging/composite_logger"
4
+
3
5
  module Kanal
4
6
  module Core
5
7
  module Helpers
@@ -8,22 +10,32 @@ module Kanal
8
10
  # get(name)
9
11
  # transforms unknown methods to setters/getters for parameters
10
12
  module ParameterFinderWithMethodMissingMixin
11
- def method_missing(symbol, *args)
13
+ include Logging::Logger
14
+
15
+ def method_missing(symbol, *args, &block)
16
+ if block && !args.first.nil?
17
+ logger.error "Block and arg given simultaneously. Parameter name: '#{symbol.to_s}, arg: #{args.first}'"
18
+
19
+ raise "Block and arg given simultaneously for parameter #{symbol.to_s}"
20
+ end
21
+
12
22
  parameter_name = symbol.to_s
13
23
  parameter_name.sub! "=", ""
14
24
 
15
25
  parameter_name = parameter_name.to_sym
16
26
 
27
+ value = block_given? ? block : args.first
28
+
17
29
  # standard workflow with settings properties with
18
30
  # input.prop = 123
19
31
  if symbol.to_s.include? "="
20
- @parameter_bag.set parameter_name, args.first
21
- elsif !args.empty?
32
+ @parameter_bag.set parameter_name, value
33
+ elsif !args.empty? || block_given?
22
34
  # this approach can be used also in dsl
23
35
  # like that
24
36
  # setters: prop value
25
37
  # getters: prop
26
- @parameter_bag.set(parameter_name, *args)
38
+ @parameter_bag.set parameter_name, value
27
39
  # means it is used as setter in dsl,
28
40
  # method call with argument
29
41
  else
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../logger/logging"
3
+ require_relative "../logging/logger"
4
4
 
5
5
  module Kanal
6
6
  module Core
@@ -21,7 +21,7 @@ module Kanal
21
21
  # Class holds parameter names that are allowed
22
22
  # to be used.
23
23
  class ParameterRegistrator
24
- include Logging
24
+ include Logging::Logger
25
25
 
26
26
  def initialize
27
27
  @parameters_by_name = {}
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "../output/output"
4
- require_relative "../logger/logging"
4
+ require_relative "../logging/logger"
5
5
 
6
6
  module Kanal
7
7
  module Core
8
8
  module Helpers
9
9
  class ResponseExecutionBlock
10
10
  include Output
11
- include Logging
11
+ include Logging::Logger
12
12
 
13
13
  attr_reader :response_block, :input
14
14
 
@@ -40,6 +40,8 @@ module Kanal
40
40
  output = Output::Output.new core.output_parameter_registrator, input, core
41
41
 
42
42
  begin
43
+ core.hooks.call :output_just_created, input, output
44
+
43
45
  output.instance_eval(&@response_block.block)
44
46
 
45
47
  core.hooks.call :output_before_returned, input, output
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../logger/logging"
3
+ require_relative "../logging/logger"
4
4
 
5
5
  module Kanal
6
6
  module Core
@@ -10,7 +10,7 @@ module Kanal
10
10
  # attaching to hooks, calling hooks with arguments
11
11
  #
12
12
  class HookStorage
13
- include Logging
13
+ include Logging::Logger
14
14
 
15
15
  def initialize
16
16
  @listeners = {}
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Kanal
4
+ module Core
5
+ module Logging
6
+ class CompositeLogger
7
+ # Property allowed_methods defines which methods can be called.
8
+ # These methods mirror standard Logger methods.
9
+ def initialize
10
+ @loggers = []
11
+ @allowed_methods = [:debug, :info, :warn, :error, :fatal, :unknown]
12
+ end
13
+
14
+ def add_logger(logger)
15
+ @loggers << logger
16
+ end
17
+
18
+ # This method gets called when calling any method in @allowed_methods.
19
+ # It passes message string to method call of every added logger.
20
+ #
21
+ # @param method [Symbol]
22
+ # @param message [String]
23
+ def method_missing(method, message)
24
+ # Getting caller class name to put into log message later.
25
+ begin
26
+ caller_class_name = "[" + caller[0].split(".rb").first.split("/").last.split('_').collect(&:capitalize).join + "]"
27
+ rescue
28
+ caller_class_name = "[ErrorGettingClassName]"
29
+ end
30
+
31
+ raise "Wrong method called for CompositeLogger" unless @allowed_methods.include? method
32
+
33
+ @loggers.each do |logger|
34
+ # progname is a property of standard Logger. It is a prefix for log message.
35
+ # In our case progname is used to store class name of class which calls for CompositeLogger methods.
36
+ logger.progname = caller_class_name
37
+ logger.send method, message
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "composite_logger"
4
+
5
+ module Kanal
6
+ module Core
7
+ module Logging
8
+ module Configuration
9
+ class << self
10
+ def composite_logger
11
+ get_or_create_composite_logger
12
+ end
13
+
14
+ def add_logger(logger)
15
+ @composite_logger.add_logger logger
16
+ end
17
+
18
+ private
19
+
20
+ def get_or_create_composite_logger
21
+ @composite_logger ||= CompositeLogger.new
22
+
23
+ @composite_logger
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "logger"
4
+
5
+ module Kanal
6
+ module Core
7
+ module Logging
8
+ # Mixing in Logger in some class to get access to logger method
9
+ module Logger
10
+ # @return [CompositeLogger]
11
+ def logger
12
+ Kanal::Core::Logging::Configuration.composite_logger
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -3,7 +3,7 @@
3
3
  require_relative "./router_node"
4
4
  require_relative "../helpers/queue"
5
5
  require_relative "../helpers/response_execution_block"
6
- require_relative "../logger/logging"
6
+ require_relative "../logging/composite_logger"
7
7
 
8
8
  module Kanal
9
9
  module Core
@@ -14,7 +14,7 @@ module Kanal
14
14
  # router nodes and have a name.
15
15
  class Router
16
16
  include Helpers
17
- include Logging
17
+ include Logging::Logger
18
18
 
19
19
  attr_reader :name, :core, :output_ready_block
20
20
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "../output/output"
4
4
  require_relative "../helpers/response_block"
5
- require_relative "../logger/logging"
5
+ require_relative "../logging/composite_logger"
6
6
 
7
7
  module Kanal
8
8
  module Core
@@ -14,7 +14,7 @@ module Kanal
14
14
  class RouterNode
15
15
  include Output
16
16
  include Helpers
17
- include Logging
17
+ include Logging::Logger
18
18
 
19
19
  attr_reader :parent,
20
20
  :children
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "../logger/logging"
3
+ require_relative "../logging/logger"
4
4
 
5
5
  module Kanal
6
6
  module Core
@@ -28,7 +28,7 @@ module Kanal
28
28
  # lifespan types.
29
29
  #
30
30
  class ServiceContainer
31
- include Logging
31
+ include Logging::Logger
32
32
 
33
33
  TYPE_SINGLETON = :singleton
34
34
  TYPE_TRANSIENT = :transient
@@ -15,76 +15,25 @@ module Kanal
15
15
  @url = url
16
16
  end
17
17
 
18
- def audio?
19
- mp3? || wav? || ogg?
20
- end
21
-
22
- def mp3?
23
- extension == "mp3"
24
- end
25
-
26
- def wav?
27
- extension == "wav"
28
- end
29
-
30
- def ogg?
31
- extension == "ogg"
32
- end
33
-
34
- def document?
35
- doc? || docx? || odf?
36
- end
37
-
38
- def doc?
39
- extension == "doc"
40
- end
41
-
42
- def docx?
43
- extension == "docx"
44
- end
45
-
46
- def odf?
47
- extension == "odf"
18
+ # Extension checks like jpg?, mp3?, mp4?, doc? etc. fall here
19
+ def method_missing(method)
20
+ extension == method.to_s.delete("?")
48
21
  end
49
22
 
50
23
  def image?
51
- jpg? || jpeg? || png? || bpm? || gif?
52
- end
53
-
54
- def jpg?
55
- extension == "jpg"
56
- end
57
-
58
- def jpeg?
59
- extension == "jpeg"
60
- end
61
-
62
- def png?
63
- extension == "png"
24
+ [jpg?, jpeg?, png?, bmp?, gif?].any?
64
25
  end
65
26
 
66
- def bpm?
67
- extension == "bpm"
68
- end
69
-
70
- def gif?
71
- extension == "gif"
27
+ def audio?
28
+ [mp3?, wav?, ogg?].any?
72
29
  end
73
30
 
74
31
  def video?
75
- mp4? || mov? || mkv?
76
- end
77
-
78
- def mp4?
79
- extension == "mp4"
32
+ [mp4?, mov?, mkv?].any?
80
33
  end
81
34
 
82
- def mov?
83
- extension == "mov"
84
- end
85
-
86
- def mkv?
87
- extension == "mkv"
35
+ def document?
36
+ [doc?, docx?, odf?].any?
88
37
  end
89
38
 
90
39
  #
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "kanal/core/plugins/plugin"
4
+ require_relative "keyboard"
4
5
 
5
6
  module Kanal
6
7
  module Plugins
@@ -8,6 +9,8 @@ module Kanal
8
9
  module Batteries
9
10
  # Plugin with some batteries like .body property etc
10
11
  class BatteriesPlugin < Core::Plugins::Plugin
12
+
13
+
11
14
  def name
12
15
  :batteries
13
16
  end
@@ -17,7 +20,9 @@ module Kanal
17
20
  body_batteries core
18
21
  flow_batteries core
19
22
  attachments_batteries core
20
- reply_markup_batteries core
23
+ keyboard_batteries core
24
+ username_batteries core
25
+ button_batteries core
21
26
  end
22
27
 
23
28
  def flow_batteries(core)
@@ -116,15 +121,121 @@ module Kanal
116
121
  def attachments_batteries(core)
117
122
  core.register_input_parameter :image
118
123
  core.register_input_parameter :audio
119
- core.register_input_parameter :file
124
+ core.register_input_parameter :video
125
+ core.register_input_parameter :document
120
126
 
121
127
  core.register_output_parameter :image
122
128
  core.register_output_parameter :audio
123
- core.register_output_parameter :file
129
+ core.register_output_parameter :video
130
+ core.register_output_parameter :document
131
+
132
+ _this = self
133
+
134
+ core.add_condition_pack :image do
135
+ add_condition :exists do
136
+ met? do |input, _core, _argument|
137
+ !input.image.nil?
138
+ end
139
+ end
140
+
141
+ add_condition :is do
142
+ with_argument
143
+
144
+ met? do |input, _, argument|
145
+ if input.image.image? && input.image.send((argument.to_s + "?").to_sym)
146
+ true
147
+ else
148
+ false
149
+ end
150
+ end
151
+ end
152
+ end
153
+
154
+ core.add_condition_pack :audio do
155
+ add_condition :exists do
156
+ met? do |input, _core, _argument|
157
+ !input.audio.nil?
158
+ end
159
+ end
160
+
161
+ add_condition :is do
162
+ with_argument
163
+
164
+ met? do |input, _, argument|
165
+ if input.audio.audio? && input.audio.send((argument.to_s + "?").to_sym)
166
+ true
167
+ else
168
+ false
169
+ end
170
+ end
171
+ end
172
+ end
173
+
174
+ core.add_condition_pack :video do
175
+ add_condition :exists do
176
+ met? do |input, _core, _argument|
177
+ !input.video.nil?
178
+ end
179
+ end
180
+
181
+ add_condition :is do
182
+ with_argument
183
+
184
+ met? do |input, _, argument|
185
+ if input.video.video? && input.video.send((argument.to_s + "?").to_sym)
186
+ true
187
+ else
188
+ false
189
+ end
190
+ end
191
+ end
192
+ end
193
+
194
+ core.add_condition_pack :document do
195
+ add_condition :exists do
196
+ met? do |input, _core, _argument|
197
+ !input.document.nil?
198
+ end
199
+ end
200
+
201
+ add_condition :is do
202
+ with_argument
203
+
204
+ met? do |input, _, argument|
205
+ if input.document.document? && input.document.send((argument.to_s + "?").to_sym)
206
+ true
207
+ else
208
+ false
209
+ end
210
+ end
211
+ end
212
+ end
124
213
  end
125
214
 
126
- def reply_markup_batteries(core)
127
- core.register_output_parameter :reply_markup
215
+ def keyboard_batteries(core)
216
+ core.register_output_parameter :keyboard
217
+
218
+ core.hooks.attach :output_just_created do |input, output|
219
+ output.keyboard = Keyboard.new
220
+ end
221
+ end
222
+
223
+ def username_batteries(core)
224
+ core.register_input_parameter :username
225
+ end
226
+
227
+ def button_batteries(core)
228
+ core.register_input_parameter :button_pressed
229
+
230
+ core.add_condition_pack :button do
231
+ add_condition :pressed do
232
+ with_argument
233
+
234
+ met? do |input, _, argument|
235
+ input.button_pressed == argument
236
+ end
237
+ end
238
+ end
128
239
  end
129
240
  end
130
241
  end
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "kanal/core/logging/composite_logger"
4
+
5
+ module Kanal
6
+ module Plugins
7
+ module Batteries
8
+ #
9
+ # This class provides methods to construct and get keyboard.
10
+ # You can construct keyboard inside respond do block in router.
11
+ # There are two ways of constructing a keyboard
12
+ # 1. Using #to_array method: provide 2-dimensional array of button names
13
+ # 2. Using #build method: provide block with calls to DSL method #row with button names as arguments
14
+ #
15
+ class Keyboard
16
+ include Kanal::Core::Logging
17
+
18
+ def initialize
19
+ @layout = []
20
+ end
21
+
22
+ # Use this method to pass names for buttons in 2-dimensional array of strings.
23
+ # Each sub-array represents a row of button names.
24
+ # Example call below is two rows of button names:
25
+ # keyboard.from_array [["B1", "B2"], ["B3"]]
26
+ #
27
+ # @param array [Array<Array<String>>]
28
+ #
29
+ def from_array(array)
30
+ unless array.instance_of? Array
31
+ logger.error "2-dimensional array was not provided. Type of provided object is #{array.class.name}"
32
+
33
+ raise "2-dimensional array was not provided"
34
+ end
35
+
36
+ array.each do |sub_array|
37
+ unless sub_array.instance_of? Array
38
+ logger.error "Value provided as row is not of Array type. Type of provided object is #{sub_array.class.name}"
39
+
40
+ raise "Value provided as row is not of Array type"
41
+ end
42
+
43
+ sub_array.each do |value|
44
+ unless value.instance_of? String
45
+ logger.error "Value provided as button name is not of String type. Type of provided object is #{sub_array.class.name}"
46
+
47
+ raise "Value provided as button name is not of String type"
48
+ end
49
+ end
50
+ end
51
+
52
+ @layout = array
53
+ end
54
+
55
+ #
56
+ # Use this method to pass block. Code inside block should call for DSL method row.
57
+ # Example below is two rows of button names
58
+ # keyboard.build do
59
+ # row "B", "B2"
60
+ # row "B3"
61
+ # end
62
+ #
63
+ # @param block [Proc]
64
+ #
65
+ def build(&block)
66
+ instance_eval &block
67
+ end
68
+
69
+ #
70
+ # Creates a row of button names, takes each provided arg and adds it to a row
71
+ #
72
+ # @param args [Array<String>]
73
+ #
74
+ def row(*args)
75
+ args.each do |value|
76
+ unless value.instance_of? String
77
+ logger.error "Value provided as button name is not of String type. Type of provided object is #{sub_array.class.name}"
78
+
79
+ raise "Value provided as button name is not of String type"
80
+ end
81
+ end
82
+
83
+ @layout.append args
84
+ end
85
+
86
+ #
87
+ # Returns constructed 2-dimensional array of strings.
88
+ # Each sub-array represents a row of button names.
89
+ #
90
+ # @return [Array<Array<String>>]
91
+ #
92
+ def to_a
93
+ @layout
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
data/lib/kanal/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kanal
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.3"
5
5
  end
data/lib/kanal.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require_relative "kanal/version"
4
4
  require_relative "kanal/core/core"
5
5
  require_relative "kanal/core/plugins/plugin"
6
+ require_relative "shortcuts"
6
7
 
7
8
  # This module used as a main entry point into kanal-core library
8
9
  module Kanal
data/lib/shortcuts.rb ADDED
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "./kanal/core/logging/logger"
4
+
5
+ module Kanal
6
+ module Logger
7
+ include Kanal::Core::Logging::Logger
8
+ end
9
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - idchlife
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-16 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Thanks to the core library, ecosystem of Kanal tools can be extendted
14
14
  to use with input-output bot-like behaviour, with routing
@@ -29,7 +29,6 @@ files:
29
29
  - LICENSE.txt
30
30
  - README.md
31
31
  - Rakefile
32
- - kanal.gemspec
33
32
  - lib/kanal.rb
34
33
  - lib/kanal/core/conditions/condition.rb
35
34
  - lib/kanal/core/conditions/condition_creator.rb
@@ -49,7 +48,9 @@ files:
49
48
  - lib/kanal/core/hooks/hook_storage.rb
50
49
  - lib/kanal/core/input/input.rb
51
50
  - lib/kanal/core/interfaces/interface.rb
52
- - lib/kanal/core/logger/logging.rb
51
+ - lib/kanal/core/logging/composite_logger.rb
52
+ - lib/kanal/core/logging/configuration.rb
53
+ - lib/kanal/core/logging/logger.rb
53
54
  - lib/kanal/core/output/output.rb
54
55
  - lib/kanal/core/output/output_creator.rb
55
56
  - lib/kanal/core/plugins/plugin.rb
@@ -60,7 +61,9 @@ files:
60
61
  - lib/kanal/interfaces/simple_cli/simple_cli_interface.rb
61
62
  - lib/kanal/plugins/batteries/attachments/attachment.rb
62
63
  - lib/kanal/plugins/batteries/batteries_plugin.rb
64
+ - lib/kanal/plugins/batteries/keyboard.rb
63
65
  - lib/kanal/version.rb
66
+ - lib/shortcuts.rb
64
67
  - sig/kanal.rbs
65
68
  - sig/kanal/core/conditions/condition_pack.rbs
66
69
  - sig/kanal/core/conditions/condition_storage.rbs
@@ -73,7 +76,7 @@ metadata:
73
76
  source_code_uri: https://github.com/idchlife/kanal
74
77
  changelog_uri: https://github.com/idchlife/kanal/CHANGELOG.md
75
78
  rubygems_mfa_required: 'true'
76
- post_install_message:
79
+ post_install_message:
77
80
  rdoc_options: []
78
81
  require_paths:
79
82
  - lib
@@ -89,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
92
  version: '0'
90
93
  requirements: []
91
94
  rubygems_version: 3.1.6
92
- signing_key:
95
+ signing_key:
93
96
  specification_version: 4
94
97
  summary: Kanal library
95
98
  test_files: []
data/kanal.gemspec DELETED
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/kanal/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "kanal"
7
- spec.version = Kanal::VERSION
8
- spec.authors = ["idchlife"]
9
- spec.email = ["idchlife@gmail.com"]
10
-
11
- spec.summary = "Kanal library"
12
- spec.description = "Thanks to the core library, ecosystem of Kanal tools can be extendted to use with input-output bot-like behaviour, with routing"
13
- spec.homepage = "https://idchlife.github.io/kanal-documentation/"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.7.6"
16
-
17
- spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
-
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/idchlife/kanal"
21
- spec.metadata["changelog_uri"] = "https://github.com/idchlife/kanal/CHANGELOG.md"
22
-
23
- # Specify which files should be added to the gem when it is released.
24
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
- spec.files = Dir.chdir(__dir__) do
26
- `git ls-files -z`.split("\x0").reject do |f|
27
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
- end
29
- end
30
- spec.bindir = "exe"
31
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
- spec.require_paths = ["lib"]
33
-
34
- # Uncomment to register a new dependency of your gem
35
- # spec.add_dependency "example-gem", "~> 1.0"
36
-
37
- # For more information and examples about making a new gem, check out our
38
- # guide at: https://bundler.io/guides/creating_gem.html
39
- spec.metadata["rubygems_mfa_required"] = "true"
40
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "logger"
4
-
5
- module Kanal
6
- module Core
7
- module Logging
8
- # Logger instance will be saved inside class itself for future calls
9
- @logger_instance
10
-
11
- # Mixing in Logger in some class adds possibility to use logger instance method
12
- def logger
13
- @logger_instance ||= Logging.create_logger self.class.name
14
- end
15
-
16
- class << self
17
- def create_logger(class_name)
18
- logger = Logger.new STDOUT
19
- logger.progname = class_name.rpartition(':').last
20
- logger.datetime_format = "%d-%m-%Y %H:%M:%S"
21
- logger
22
- end
23
- end
24
- end
25
- end
26
- end