student_mvp 0.1.7 → 0.1.9

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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/doc/App_logger.html +47 -33
  3. data/doc/DB_client.html +20 -10
  4. data/doc/created.rid +10 -44
  5. data/doc/index.html +2 -81
  6. data/doc/js/search_index.js +1 -1
  7. data/doc/js/search_index.js.gz +0 -0
  8. data/doc/table_of_contents.html +9 -697
  9. data/lib/data_access/DB_client/DB_client.rb +20 -1
  10. data/lib/logger/logger.rb +36 -1
  11. data/lib/student_mvp/version.rb +1 -1
  12. metadata +55 -34
  13. data/doc/Binary_tree.html +0 -300
  14. data/doc/Binary_tree_iterator.html +0 -217
  15. data/doc/Contact_sort_decorator.html +0 -219
  16. data/doc/Data_list.html +0 -625
  17. data/doc/Data_list_student_short.html +0 -148
  18. data/doc/Data_storage_strategy.html +0 -178
  19. data/doc/Data_table.html +0 -264
  20. data/doc/Deep_dup.html +0 -152
  21. data/doc/Field_filter_decorator.html +0 -219
  22. data/doc/Filter.html +0 -148
  23. data/doc/Filter_decorator.html +0 -209
  24. data/doc/Full_name_filter_decorator.html +0 -211
  25. data/doc/Full_name_sort_decorator.html +0 -217
  26. data/doc/Gemfile.html +0 -98
  27. data/doc/Git_sort_decorator.html +0 -220
  28. data/doc/Has_not_field_filter_decorator.html +0 -209
  29. data/doc/JSON_storage_strategy.html +0 -183
  30. data/doc/Person.html +0 -511
  31. data/doc/README_md.html +0 -147
  32. data/doc/Rakefile.html +0 -94
  33. data/doc/Sort_decorator.html +0 -214
  34. data/doc/Student.html +0 -755
  35. data/doc/StudentMvp/Error.html +0 -105
  36. data/doc/StudentMvp.html +0 -111
  37. data/doc/Student_short.html +0 -398
  38. data/doc/Students_list.html +0 -341
  39. data/doc/Students_list_DB.html +0 -361
  40. data/doc/Students_list_file.html +0 -460
  41. data/doc/Students_list_file_adapter.html +0 -341
  42. data/doc/Students_list_interface.html +0 -298
  43. data/doc/YAML_storage_strategy.html +0 -183
  44. data/doc/bin/setup.html +0 -96
@@ -1,21 +1,40 @@
1
1
  require 'mysql2'
2
2
 
3
+ # == DB_client
4
+ # Клиент базы данных MySQL
3
5
  class DB_client
4
6
  private_class_method :new
5
7
 
8
+ # Инициализация объекта класса БД.
9
+ #
10
+ # @param [Hash] db_config - конфигурация базы данных.
11
+ # @raise [Error] Не указана конфигурация базы данных.
6
12
  def initialize(db_config)
7
- raise 'Database configuration is required' unless db_config
13
+ raise 'Не указана конфигурация базы данных' unless db_config
8
14
  self.client = Mysql2::Client.new(db_config)
9
15
  end
10
16
 
17
+ # Получение или создание объекта клиента базы данных.
18
+ # Конфигурацию БД достаточно задать 1 раз.
19
+ #
20
+ # @param [Hash] db_config - конфигурация базы данных.
21
+ # @raise [Error] Не указана конфигурация базы данных.
22
+ # @return [Mysql2::Client] - объект клиента базы данных.
11
23
  def self.instance(db_config = nil)
12
24
  @instance ||= new(db_config)
13
25
  end
14
26
 
27
+ # Выполнение SQL запроса.
28
+ #
29
+ # @param [String] query - SQL запрос.
30
+ # @param [Array] params - массив параметров для SQL запроса (необязательно)
31
+ # @return [Mysql2::Hash] - результат выполнения запроса.
15
32
  def query(query, params=[])
16
33
  self.client.prepare(query).execute(*params)
17
34
  end
18
35
 
36
+ # Закрытие объекта клиента базы данных.
37
+ #
19
38
  def close
20
39
  self.client.close
21
40
  end
data/lib/logger/logger.rb CHANGED
@@ -1,11 +1,20 @@
1
1
  require 'logger'
2
2
 
3
+ # == App_logger
4
+ # Логгер приложения
3
5
  class App_logger
4
6
  private_class_method :new
5
7
 
8
+ # Инициализация объекта логгера.
9
+ #
10
+ # @param [String] file_path - путь к файлу логов.
11
+ # @raise [Error] Не указан путь к файлу логов.
6
12
  def initialize(file_path)
7
- ensure_log_directory
13
+ if file_path.nil? || file_path.empty?
14
+ raise Error, 'Не указан путь к файлу логов'
15
+ end
8
16
  self.file_path = file_path
17
+ ensure_log_directory
9
18
  self.logger = Logger.new(self.file_path)
10
19
  self.logger.formatter = proc do |severity, datetime, progname, msg|
11
20
  "[#{datetime}] #{severity}: #{msg}\n"
@@ -13,30 +22,56 @@ class App_logger
13
22
  setup_log_level
14
23
  end
15
24
 
25
+ # Получение или создание объекта логгера
26
+ # Путь задать достаточно всего один раз. Если он не задан перед первым использованием логгера, то выбрасывается исключение.
27
+ #
28
+ # @param [String, nil] file_path - путь к файлу логов.
29
+ # @raise [Error] Не указан путь к файлу логов.
30
+ # @return [App_logger] - объект логгера.
16
31
  def self.instance(file_path = nil)
17
32
  @instance ||= new(file_path)
18
33
  end
19
34
 
35
+ # Запись сообщения в лог
36
+ #
37
+ # @param [Symbol] severity - тип сообщения
38
+ # @param [String] message - сообщение
20
39
  def log(severity, message)
21
40
  self.logger.send(severity, message)
22
41
  end
23
42
 
43
+
44
+ # Запись информационного сообщения в лог
45
+ #
46
+ # @param [String] message - сообщение
24
47
  def info(message)
25
48
  log(:info, message)
26
49
  end
27
50
 
51
+ # Запись сообщения для дебага в лог
52
+ #
53
+ # @param [String] message - сообщение
28
54
  def debug(message)
29
55
  log(:debug, message)
30
56
  end
31
57
 
58
+ # Запись сообщения ошибки в лог
59
+ #
60
+ # @param [String] message - сообщение
32
61
  def error(message)
33
62
  log(:error, message)
34
63
  end
35
64
 
65
+ # Запись сообщения предупреждения в лог
66
+ #
67
+ # @param [String] message - сообщение
36
68
  def warn(message)
37
69
  log(:warn, message)
38
70
  end
39
71
 
72
+ # Запись сообщения фатальной ошибки в лог
73
+ #
74
+ # @param [String] message - сообщение
40
75
  def fatal(message)
41
76
  log(:fatal, message)
42
77
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StudentMvp
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.9"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: student_mvp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - ZaiiiRan
@@ -101,51 +101,72 @@ email:
101
101
  - a1b075753@gmail.com
102
102
  executables: []
103
103
  extensions: []
104
- extra_rdoc_files: []
104
+ extra_rdoc_files:
105
+ - doc/Add_student_presenter.html
106
+ - doc/App_logger.html
107
+ - doc/Base_presenter.html
108
+ - doc/DB_client.html
109
+ - doc/Edit_contacts_presenter.html
110
+ - doc/Edit_git_presenter.html
111
+ - doc/Edit_student_presenter.html
112
+ - doc/Replace_student_presenter.html
113
+ - doc/Student_list_presenter.html
114
+ - doc/created.rid
115
+ - doc/css/fonts.css
116
+ - doc/css/rdoc.css
117
+ - doc/fonts/Lato-Light.ttf
118
+ - doc/fonts/Lato-LightItalic.ttf
119
+ - doc/fonts/Lato-Regular.ttf
120
+ - doc/fonts/Lato-RegularItalic.ttf
121
+ - doc/fonts/SourceCodePro-Bold.ttf
122
+ - doc/fonts/SourceCodePro-Regular.ttf
123
+ - doc/images/add.png
124
+ - doc/images/arrow_up.png
125
+ - doc/images/brick.png
126
+ - doc/images/brick_link.png
127
+ - doc/images/bug.png
128
+ - doc/images/bullet_black.png
129
+ - doc/images/bullet_toggle_minus.png
130
+ - doc/images/bullet_toggle_plus.png
131
+ - doc/images/date.png
132
+ - doc/images/delete.png
133
+ - doc/images/find.png
134
+ - doc/images/loadingAnimation.gif
135
+ - doc/images/macFFBgHack.png
136
+ - doc/images/package.png
137
+ - doc/images/page_green.png
138
+ - doc/images/page_white_text.png
139
+ - doc/images/page_white_width.png
140
+ - doc/images/plugin.png
141
+ - doc/images/ruby.png
142
+ - doc/images/tag_blue.png
143
+ - doc/images/tag_green.png
144
+ - doc/images/transparent.png
145
+ - doc/images/wrench.png
146
+ - doc/images/wrench_orange.png
147
+ - doc/images/zoom.png
148
+ - doc/index.html
149
+ - doc/js/darkfish.js
150
+ - doc/js/navigation.js
151
+ - doc/js/navigation.js.gz
152
+ - doc/js/search.js
153
+ - doc/js/search_index.js
154
+ - doc/js/search_index.js.gz
155
+ - doc/js/searcher.js
156
+ - doc/js/searcher.js.gz
157
+ - doc/table_of_contents.html
105
158
  files:
106
159
  - README.md
107
160
  - Rakefile
108
161
  - doc/Add_student_presenter.html
109
162
  - doc/App_logger.html
110
163
  - doc/Base_presenter.html
111
- - doc/Binary_tree.html
112
- - doc/Binary_tree_iterator.html
113
- - doc/Contact_sort_decorator.html
114
164
  - doc/DB_client.html
115
- - doc/Data_list.html
116
- - doc/Data_list_student_short.html
117
- - doc/Data_storage_strategy.html
118
- - doc/Data_table.html
119
- - doc/Deep_dup.html
120
165
  - doc/Edit_contacts_presenter.html
121
166
  - doc/Edit_git_presenter.html
122
167
  - doc/Edit_student_presenter.html
123
- - doc/Field_filter_decorator.html
124
- - doc/Filter.html
125
- - doc/Filter_decorator.html
126
- - doc/Full_name_filter_decorator.html
127
- - doc/Full_name_sort_decorator.html
128
- - doc/Gemfile.html
129
- - doc/Git_sort_decorator.html
130
- - doc/Has_not_field_filter_decorator.html
131
- - doc/JSON_storage_strategy.html
132
- - doc/Person.html
133
- - doc/README_md.html
134
- - doc/Rakefile.html
135
168
  - doc/Replace_student_presenter.html
136
- - doc/Sort_decorator.html
137
- - doc/Student.html
138
- - doc/StudentMvp.html
139
- - doc/StudentMvp/Error.html
140
169
  - doc/Student_list_presenter.html
141
- - doc/Student_short.html
142
- - doc/Students_list.html
143
- - doc/Students_list_DB.html
144
- - doc/Students_list_file.html
145
- - doc/Students_list_file_adapter.html
146
- - doc/Students_list_interface.html
147
- - doc/YAML_storage_strategy.html
148
- - doc/bin/setup.html
149
170
  - doc/created.rid
150
171
  - doc/css/fonts.css
151
172
  - doc/css/rdoc.css
data/doc/Binary_tree.html DELETED
@@ -1,300 +0,0 @@
1
- <!DOCTYPE html>
2
-
3
- <html>
4
- <head>
5
- <meta charset="UTF-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
-
8
- <title>class Binary_tree - RDoc Documentation</title>
9
-
10
- <meta name="keywords" content="ruby,class,Binary_tree">
11
-
12
- <meta name="description" content="Documentation for the Binary_tree class">
13
-
14
- <script type="text/javascript">
15
- var rdoc_rel_prefix = "./";
16
- var index_rel_prefix = "./";
17
- </script>
18
-
19
- <script src="./js/navigation.js" defer></script>
20
- <script src="./js/search.js" defer></script>
21
- <script src="./js/search_index.js" defer></script>
22
- <script src="./js/searcher.js" defer></script>
23
- <script src="./js/darkfish.js" defer></script>
24
-
25
- <link href="./css/fonts.css" rel="stylesheet">
26
- <link href="./css/rdoc.css" rel="stylesheet">
27
-
28
-
29
- <body id="top" role="document" class="class">
30
- <div id="navigation-toggle" role="button" tabindex="0" aria-label="Toggle sidebar" aria-expanded="true" aria-controls="navigation">
31
- <span aria-hidden="true">&#9776;</span>
32
- </div>
33
-
34
-
35
- <nav id="navigation" role="navigation">
36
- <div id="project-navigation">
37
- <div id="home-section" role="region" title="Quick navigation" class="nav-section">
38
- <h2>
39
- <a href="./index.html" rel="home">Home</a>
40
- </h2>
41
-
42
- <div id="table-of-contents-navigation">
43
- <a href="./table_of_contents.html#pages">Pages</a>
44
- <a href="./table_of_contents.html#classes">Classes</a>
45
- <a href="./table_of_contents.html#methods">Methods</a>
46
- </div>
47
- </div>
48
-
49
- <div id="search-section" role="search" class="project-section initially-hidden">
50
- <form action="#" method="get" accept-charset="utf-8">
51
- <div id="search-field-wrapper">
52
- <input id="search-field" role="combobox" aria-label="Search"
53
- aria-autocomplete="list" aria-controls="search-results"
54
- type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
55
- title="Type to search, Up and Down to navigate, Enter to load">
56
- </div>
57
-
58
- <ul id="search-results" aria-label="Search Results"
59
- aria-busy="false" aria-expanded="false"
60
- aria-atomic="false" class="initially-hidden"></ul>
61
- </form>
62
- </div>
63
-
64
- </div>
65
-
66
-
67
-
68
- <div id="parent-class-section" class="nav-section">
69
- <h3>Ancestors</h3>
70
- <ul><li>Object</li></ul>
71
- </div>
72
-
73
-
74
- <div id="includes-section" class="nav-section">
75
- <h3>Included Modules</h3>
76
-
77
- <ul class="link-list">
78
- <li><span class="include">Enumerable</span>
79
- </ul>
80
- </div>
81
-
82
-
83
-
84
- <div class="nav-section">
85
- <h3>Class Methods</h3>
86
- <ul class="link-list" role="directory">
87
- <li ><a href="#method-c-new">new</a></li>
88
- </ul>
89
- </div>
90
-
91
-
92
-
93
- <div class="nav-section">
94
- <h3>Instance Methods</h3>
95
- <ul class="link-list" role="directory">
96
- <li ><a href="#method-i-add">add</a></li>
97
- <li ><a href="#method-i-each">each</a></li>
98
- <li ><a href="#method-i-find">find</a></li>
99
- </ul>
100
- </div>
101
-
102
-
103
-
104
- <footer id="validator-badges" role="contentinfo">
105
- <p><a href="https://validator.w3.org/check/referer">Validate</a>
106
- <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.8.1.
107
- <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
108
- </footer>
109
-
110
- </nav>
111
-
112
- <main role="main" aria-labelledby="class-Binary_tree">
113
- <h1 id="class-Binary_tree" class="anchor-link class">
114
- class Binary_tree
115
- </h1>
116
-
117
- <section class="description">
118
-
119
- </section>
120
-
121
- <section id="5Buntitled-5D" class="documentation-section anchor-link">
122
-
123
-
124
- <section class="constants-list">
125
- <header>
126
- <h3>Constants</h3>
127
- </header>
128
- <dl>
129
- <dt id="BLACK">BLACK
130
- <dd>
131
-
132
- <dt id="RED">RED
133
- <dd>
134
-
135
- </dl>
136
- </section>
137
-
138
- <section class="attribute-method-details" class="method-section">
139
- <header>
140
- <h3>Attributes</h3>
141
- </header>
142
-
143
- <div id="attribute-i-root" class="method-detail anchor-link">
144
- <div class="method-heading attribute-method-heading">
145
- <a href="#attribute-i-root" title="Link to this attribute">
146
- <span class="method-name">root</span>
147
- <span class="attribute-access-type">[RW]</span>
148
- </a>
149
- </div>
150
-
151
- <div class="method-description">
152
-
153
- </div>
154
- </div>
155
- </section>
156
-
157
-
158
- <section id="public-class-5Buntitled-5D-method-details" class="method-section anchor-link">
159
- <header>
160
- <h3>Public Class Methods</h3>
161
- </header>
162
-
163
- <div id="method-c-new" class="method-detail anchor-link ">
164
- <div class="method-header">
165
- <div class="method-heading">
166
- <a href="#method-c-new" title="Link to this method">
167
- <span class="method-name">new</span>
168
- <span class="method-args">()</span>
169
- </a>
170
- </div>
171
- </div>
172
-
173
- <div class="method-controls">
174
- <details class="method-source-toggle">
175
- <summary>Source</summary>
176
- </details>
177
- </div>
178
-
179
- <div class="method-description">
180
- <div class="method-source-code" id="new-source">
181
- <pre><span class="ruby-comment"># File lib/models/binary_tree/binary_tree.rb, line 23</span>
182
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>
183
- <span class="ruby-keyword">self</span>.<span class="ruby-identifier">root</span> = <span class="ruby-keyword">nil</span>
184
- <span class="ruby-keyword">end</span></pre>
185
- </div>
186
-
187
- </div>
188
-
189
-
190
- </div>
191
-
192
- </section>
193
-
194
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
195
- <header>
196
- <h3>Public Instance Methods</h3>
197
- </header>
198
-
199
- <div id="method-i-add" class="method-detail anchor-link ">
200
- <div class="method-header">
201
- <div class="method-heading">
202
- <a href="#method-i-add" title="Link to this method">
203
- <span class="method-name">add</span>
204
- <span class="method-args">(value)</span>
205
- </a>
206
- </div>
207
- </div>
208
-
209
- <div class="method-controls">
210
- <details class="method-source-toggle">
211
- <summary>Source</summary>
212
- </details>
213
- </div>
214
-
215
- <div class="method-description">
216
- <div class="method-source-code" id="add-source">
217
- <pre><span class="ruby-comment"># File lib/models/binary_tree/binary_tree.rb, line 27</span>
218
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add</span>(<span class="ruby-identifier">value</span>)
219
- <span class="ruby-identifier">new_node</span> = <span class="ruby-constant">Node</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">value</span>)
220
- <span class="ruby-keyword">self</span>.<span class="ruby-identifier">root</span> = <span class="ruby-identifier">insert</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">root</span>, <span class="ruby-identifier">new_node</span>)
221
- <span class="ruby-keyword">self</span>.<span class="ruby-identifier">balance</span>(<span class="ruby-identifier">new_node</span>)
222
- <span class="ruby-keyword">end</span></pre>
223
- </div>
224
-
225
- </div>
226
-
227
-
228
- </div>
229
-
230
- <div id="method-i-each" class="method-detail anchor-link ">
231
- <div class="method-header">
232
- <div class="method-heading">
233
- <a href="#method-i-each" title="Link to this method">
234
- <span class="method-name">each</span>
235
- <span class="method-args">(&amp;block)</span>
236
- </a>
237
- </div>
238
- </div>
239
-
240
- <div class="method-controls">
241
- <details class="method-source-toggle">
242
- <summary>Source</summary>
243
- </details>
244
- </div>
245
-
246
- <div class="method-description">
247
- <div class="method-source-code" id="each-source">
248
- <pre><span class="ruby-comment"># File lib/models/binary_tree/binary_tree.rb, line 33</span>
249
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
250
- <span class="ruby-identifier">iterator</span> = <span class="ruby-constant">Binary_tree_iterator</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">root</span>)
251
- <span class="ruby-identifier">iterator</span>.<span class="ruby-identifier">each</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
252
- <span class="ruby-keyword">end</span></pre>
253
- </div>
254
-
255
- </div>
256
-
257
-
258
- </div>
259
-
260
- <div id="method-i-find" class="method-detail anchor-link ">
261
- <div class="method-header">
262
- <div class="method-heading">
263
- <a href="#method-i-find" title="Link to this method">
264
- <span class="method-name">find</span>
265
- <span class="method-args">(key)</span>
266
- </a>
267
- </div>
268
- </div>
269
-
270
- <div class="method-controls">
271
- <details class="method-source-toggle">
272
- <summary>Source</summary>
273
- </details>
274
- </div>
275
-
276
- <div class="method-description">
277
- <div class="method-source-code" id="find-source">
278
- <pre><span class="ruby-comment"># File lib/models/binary_tree/binary_tree.rb, line 38</span>
279
- <span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">find</span>(<span class="ruby-identifier">key</span>)
280
- <span class="ruby-identifier">result</span> = <span class="ruby-keyword">nil</span>
281
- <span class="ruby-keyword">self</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">value</span><span class="ruby-operator">|</span>
282
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">key</span>
283
- <span class="ruby-identifier">result</span> = <span class="ruby-identifier">value</span>
284
- <span class="ruby-keyword">break</span>
285
- <span class="ruby-keyword">end</span>
286
- <span class="ruby-keyword">end</span>
287
- <span class="ruby-identifier">result</span>
288
- <span class="ruby-keyword">end</span></pre>
289
- </div>
290
-
291
- </div>
292
-
293
-
294
- </div>
295
-
296
- </section>
297
-
298
- </section>
299
- </main>
300
-