shnaider_code 1.1.5 → 1.1.6

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: b0f2d61075e4ea8ed4bd5251fdede22a0852304e235b35286e29162649ef9748
4
- data.tar.gz: ebc0f80b93bcb4c885da7370b2c42943c2b99bfe5f67237dc1eb3918a975b2ab
3
+ metadata.gz: 7e48a27d5a278939a30bee3a0ae4b09877d669eff51d5c1d3bd75fd449075261
4
+ data.tar.gz: f1a81eac5c6880152bde397e218d4d0ae19eb3b79667cd3cc18e76cab607b211
5
5
  SHA512:
6
- metadata.gz: bfaa925bb39c18ab6937f9d0d5686f58b04083bc00bc941bc0fae3de3aab27daf4367dcd989221147b4256ebd8c9b46258d5f07e602e92c44711cc963b98a797
7
- data.tar.gz: 300d64689ec07620cd2f11d802c221072546a66799739e4d1749914b176e50ece0fc898405257f63b95b06ffc6b32223420a271cdd6e645be48aac805e19ecca
6
+ metadata.gz: 4ea9dfc5ce7a15aecc3a7f97125e018a17a0d82ac9ebb5fb7371e8a40968790309a1ed3dc7b8803f3b6edb82c3c7eb6feb9979e49f92040486960d1e2b822436
7
+ data.tar.gz: 7cb5d288b765e6bf5fc39733251ade4704493b2da9281d2fc3fcf8c89971d1f029ff205c14b3070c2bc50c9e58f5db8884b2e1552198cbf27adf7b205e83a292
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gem "glimmer-dsl-libui",'~> 0.7.4'
7
7
  gem 'win32api'
8
8
  gem "minitest"
9
9
  gem 'rubocop', group: 'development'
10
- # gem 'shnaider_code', '~> 0.1.3'
11
10
  gem 'shnaider_code'
12
11
  gem 'sinatra', '~> 3.0', '>= 3.0.6'
13
12
  gem 'thin', '~> 1.8', '>= 1.8.2'
13
+
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ShnaiderCode
4
- VERSION = "1.1.5"
3
+ module Shnaider
4
+ VERSION = "1.1.6"
5
5
  end
data/lib/shnaider_code.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "shnaider_code/version"
4
4
 
5
- module ShnaiderCode
5
+ module Shnaider
6
6
  Dir[File.dirname(__FILE__) + '/source/**/*.rb'].each { |file|
7
7
  puts file
8
8
  require file
@@ -1,11 +1,7 @@
1
1
  # frozen_string_literal: true
2
-
3
- require './LabStudents/util/logger_holder'
2
+ require 'source/util/logger_holder'
4
3
  require 'win32api'
5
4
 
6
- ##
7
- # Контроллер для модального окна создания студента
8
-
9
5
  class StudentInputFormControllerCreate
10
6
  def initialize(parent_controller)
11
7
  @parent_controller = parent_controller
@@ -17,8 +13,9 @@ class StudentInputFormControllerCreate
17
13
  LoggerHolder.instance.debug('StudentInputFormControllerCreate: view set')
18
14
  end
19
15
 
20
- ##
21
- # Вызывается из view после ее создания
16
+ def refresh
17
+ @parent_controller.refresh_data(1, 20)
18
+ end
22
19
 
23
20
  def on_view_created
24
21
  begin
@@ -28,9 +25,6 @@ class StudentInputFormControllerCreate
28
25
  end
29
26
  end
30
27
 
31
- ##
32
- # Обработать данные из полей и добавить студента
33
-
34
28
  def process_fields(fields)
35
29
  begin
36
30
  last_name = fields.delete(:last_name)
@@ -41,10 +35,10 @@ class StudentInputFormControllerCreate
41
35
 
42
36
  student = Student.new(last_name, first_name, father_name, **fields)
43
37
 
44
- LoggerHolder.instance.debug('StudentInputFormControllerCreate: adding student to DB')
45
-
46
38
  @student_rep.add_student(student)
47
39
 
40
+ LoggerHolder.instance.debug('StudentInputFormControllerCreate: adding student to DB')
41
+
48
42
  @view.close
49
43
  rescue ArgumentError => e
50
44
  LoggerHolder.instance.debug("StudentInputFormControllerCreate: wrong fields: #{e.message}")
@@ -55,9 +49,6 @@ class StudentInputFormControllerCreate
55
49
 
56
50
  private
57
51
 
58
- ##
59
- # Обработчик ошибки подключения к БД
60
-
61
52
  def on_db_conn_error(error)
62
53
  LoggerHolder.instance.debug('StudentInputFormControllerCreate: DB connection error:')
63
54
  LoggerHolder.instance.error(error.message)
@@ -1,11 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require './LabStudents/util/logger_holder'
3
+ require 'source/util/logger_holder'
4
4
  require 'win32api'
5
5
 
6
- ##
7
- # Контроллер для модального окна изменения студента
8
-
9
6
  class StudentInputFormControllerEdit
10
7
  def initialize(parent_controller, existing_student_id)
11
8
  @parent_controller = parent_controller
@@ -18,8 +15,9 @@ class StudentInputFormControllerEdit
18
15
  LoggerHolder.instance.debug('StudentInputFormControllerEdit: view set')
19
16
  end
20
17
 
21
- ##
22
- # Вызывается из view после ее создания
18
+ def refresh
19
+ @parent_controller.refresh_data(1, 20)
20
+ end
23
21
 
24
22
  def on_view_created
25
23
  begin
@@ -28,13 +26,10 @@ class StudentInputFormControllerEdit
28
26
  on_db_conn_error(e)
29
27
  end
30
28
  @existing_student = @student_rep.student_by_id(@existing_student_id)
31
- @view.make_readonly(:git, :telegram, :email, :phone)
29
+ #@view.make_readonly(:git, :telegram, :email, :phone)
32
30
  populate_fields(@existing_student)
33
31
  end
34
32
 
35
- ##
36
- # Заполнить имеющиеся данные о студенте
37
-
38
33
  def populate_fields(student)
39
34
  @view.set_value(:last_name, student.last_name)
40
35
  @view.set_value(:first_name, student.first_name)
@@ -45,9 +40,6 @@ class StudentInputFormControllerEdit
45
40
  @view.set_value(:phone, student.phone)
46
41
  end
47
42
 
48
- ##
49
- # Обработать данные из полей и добавить студента
50
-
51
43
  def process_fields(fields)
52
44
  begin
53
45
  new_student = Student.from_hash(fields)
@@ -66,8 +58,6 @@ class StudentInputFormControllerEdit
66
58
 
67
59
  private
68
60
 
69
- ##
70
- # Обработчик ошибки подключения к БД
71
61
  def on_db_conn_error(error)
72
62
  LoggerHolder.instance.debug('StudentInputFormControllerEdit: DB connection error:')
73
63
  LoggerHolder.instance.error(error.message)
@@ -1,18 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require './LabStudents/views/main_window'
4
- require './LabStudents/repositories/student_repository'
5
- require './LabStudents/repositories/adapters/db_source_adapter'
6
- require './LabStudents/repositories/containers/data_list_student_short'
4
+ require 'source/repositories/student_repository'
5
+ require 'source/repositories/adapters/db_source_adapter'
6
+ require 'source/repositories/containers/data_list_student_short'
7
7
  require './LabStudents/views/student_input_form'
8
- require './LabStudents/controllers/student_input_form/student_input_form_controller_create'
9
- require './LabStudents/controllers/student_input_form/student_input_form_controller_edit'
10
- require './LabStudents/util/logger_holder'
8
+ require 'source/controllers/student_input_form/student_input_form_controller_create'
9
+ require 'source/controllers/student_input_form/student_input_form_controller_edit'
10
+ require 'source/util/logger_holder'
11
11
  require 'win32api'
12
12
 
13
- ##
14
- # Контроллер для вкладки со списком студентов
15
-
16
13
  class TabStudentsController
17
14
  def initialize(view)
18
15
  LoggerHolder.instance.debug('TabStudentsController: init start')
@@ -22,22 +19,15 @@ class TabStudentsController
22
19
  LoggerHolder.instance.debug('TabStudentsController: init done')
23
20
  end
24
21
 
25
- ##
26
- # Вызывается из view после ее создания
27
-
28
22
  def on_view_created
29
23
  begin
30
24
  @student_rep = StudentRepository.new(DBSourceAdapter.new)
31
25
  LoggerHolder.instance.debug('TabStudentsController: created student repository')
32
26
  rescue Mysql2::Error::ConnectionError => e
33
- on_db_conn_error(e)
27
+ on_db_conn_error(e)
34
28
  end
35
29
  end
36
30
 
37
-
38
- ##
39
- # Показать модальное окно с добавлением студента
40
-
41
31
  def show_modal_add
42
32
  LoggerHolder.instance.debug('TabStudentsController: showing modal (add)')
43
33
  controller = StudentInputFormControllerCreate.new(self)
@@ -46,9 +36,6 @@ class TabStudentsController
46
36
  view.create.show
47
37
  end
48
38
 
49
- ##
50
- # Показать модальное окно с изменением выделенного студента
51
-
52
39
  def show_modal_edit(current_page, per_page, selected_row)
53
40
  LoggerHolder.instance.debug('TabStudentsController: showing modal (edit)')
54
41
  student_num = (current_page - 1) * per_page + selected_row
@@ -60,9 +47,6 @@ class TabStudentsController
60
47
  view.create.show
61
48
  end
62
49
 
63
- ##
64
- # Удалить выбранного студента
65
-
66
50
  def delete_selected(current_page, per_page, selected_row)
67
51
  begin
68
52
  LoggerHolder.instance.debug('TabStudentsController: deleting selected student')
@@ -75,9 +59,6 @@ class TabStudentsController
75
59
  end
76
60
  end
77
61
 
78
- ##
79
- # Обновить данные в таблице студентов
80
-
81
62
  def refresh_data(page, per_page)
82
63
  begin
83
64
  LoggerHolder.instance.debug('TabStudentsController: refreshing data...')
@@ -90,9 +71,6 @@ class TabStudentsController
90
71
 
91
72
  private
92
73
 
93
- ##
94
- # Обработчик ошибки подключения к БД
95
-
96
74
  def on_db_conn_error(error)
97
75
  LoggerHolder.instance.error('TabStudentsController: DB connection error:')
98
76
  LoggerHolder.instance.error(error.message)
@@ -1,6 +1,6 @@
1
1
  insert into student(last_name, first_name, father_name, phone, telegram, email, git) values
2
- ('Тимофеев', 'Иван', 'Георгиевич', '79517532585', NULL, 'timka@mail.ru', NULL),
3
- ('Кот', 'Александр', 'Дмитриевич', NULL, 'prettykitty', 'kot@bk.ru', 'kotkotkot'),
4
- ('Симонов', 'Аркадий', 'Олегович', '79998881487', 'simark', 'arksim@gmail.com', NULL),
5
- ('Балбесов', 'Никита', 'Никитович', '79180005577', 'balnik', NULL, 'nikitos_b'),
6
- ('Титов', 'Артур', 'Николаевич', '79990805051', 'narot', 'aptyp@narod.ru', 'bot_waasabi');
2
+ ("Шнайдер", "Ия", "Ниевна", NULL, NULL, NULL, "bushmrz"),
3
+ ("Худокмырлов", "Дмитрий", "Александрович", "78005553535", NULL, NULL, "kittenqz"),
4
+ ("Шнайдер", "Ий", " Ниевич", NULL, NULL, NULL, "invisible"),
5
+ ("Сайксова", "Риночка", "Рири", NULL, "slowrunner3000", NULL, NULL),
6
+ ("Кузнецов", "Максим", "Александрович", "+7-900-900-90-90", "maxonhol", "maximilian@ya.ru", "maxonspb");
@@ -3,14 +3,10 @@
3
3
  require 'json'
4
4
  require_relative 'student_base'
5
5
 
6
- ##
7
- # Модель студента
8
-
9
6
  class Student < StudentBase
7
+ # Делаем new предка публичным
10
8
  public_class_method :new
11
9
 
12
- ##
13
- # Конструктор из Hash. Ключи являются символами
14
10
  def self.from_hash(hash)
15
11
  hash = hash.dup
16
12
  raise ArgumentError, 'Fields required: fist_name, last_name, father_name' unless hash.key?(:first_name) && hash.key?(:last_name) && hash.key?(:father_name)
@@ -22,20 +18,19 @@ class Student < StudentBase
22
18
  Student.new(last_name, first_name, father_name, **hash)
23
19
  end
24
20
 
25
- ##
26
21
  # Конструктор из JSON строки
27
-
28
22
  def self.from_json_str(str)
29
23
  params = JSON.parse(str, { symbolize_names: true })
30
24
  from_hash(params)
31
25
  end
32
26
 
27
+ # Делаем публичными геттеры и сеттеры базового класса
33
28
  public :phone, :telegram, :email, 'id=', 'phone=', 'telegram=', 'email=', 'git='
34
29
 
30
+ # Стандартные геттеры для полей
35
31
  attr_reader :last_name, :first_name, :father_name
36
32
 
37
- ##
38
- # Стандартный конструктор. Принимает: Фамилия, Имя, Отчество, а также именованные параметры для предка
33
+ # Стандартный конструктор
39
34
  def initialize(last_name, first_name, father_name, **options)
40
35
  self.last_name = last_name
41
36
  self.first_name = first_name
@@ -43,6 +38,7 @@ class Student < StudentBase
43
38
  super(**options)
44
39
  end
45
40
 
41
+ # Сеттеры с валидацией перед присваиванием
46
42
  def last_name=(new_last_name)
47
43
  raise ArgumentError, "Invalid argument: last_name=#{new_last_name}" unless Student.valid_name?(new_last_name)
48
44
 
@@ -61,29 +57,19 @@ class Student < StudentBase
61
57
  @father_name = new_father_name
62
58
  end
63
59
 
64
- ##
65
- # Сеттер для массовой установки контактов
66
-
60
+ # Отдельный сеттер для массовой установки контактов
67
61
  def set_contacts(phone: nil, telegram: nil, email: nil)
68
62
  self.phone = phone if phone
69
63
  self.telegram = telegram if telegram
70
64
  self.email = email if email
71
65
  end
72
66
 
73
- ##
74
- # Вернуть фамилию и инициалы в виде строки "Фамилия И. О."
75
-
67
+ # Имя пользователя в формате Фамилия И. О.
76
68
  def last_name_and_initials
77
69
  "#{last_name} #{first_name[0]}. #{father_name[0]}."
78
70
  end
79
71
 
80
- ##
81
- # Краткая информация о пользователе в виде JSON строки.
82
- # Поля:
83
- # last_name_and_initials - Фамилия и инициалы в виде "Фамилия И. О."
84
- # contact - Приоритетный доступный контакт в виде хеша (StudentBase#short_contact)
85
- # git - Имя пользователя на гите
86
-
72
+ # Краткая информация о пользователе
87
73
  def short_info
88
74
  info = {}
89
75
  info[:last_name_and_initials] = last_name_and_initials
@@ -92,9 +78,7 @@ class Student < StudentBase
92
78
  JSON.generate(info)
93
79
  end
94
80
 
95
- ##
96
- # Преобразование студента в строку
97
-
81
+ # Методы приведения объекта к строке
98
82
  def to_s
99
83
  result = "#{last_name} #{first_name} #{father_name}"
100
84
  %i[id phone telegram email git].each do |attr|
@@ -104,9 +88,6 @@ class Student < StudentBase
104
88
  result
105
89
  end
106
90
 
107
- ##
108
- # Преобразование студента в хеш. Поля являются ключами
109
-
110
91
  def to_hash
111
92
  attrs = {}
112
93
  %i[last_name first_name father_name id phone telegram email git].each do |attr|
@@ -116,9 +97,6 @@ class Student < StudentBase
116
97
  attrs
117
98
  end
118
99
 
119
- ##
120
- # Преобразование студента в JSON строку.
121
-
122
100
  def to_json_str
123
101
  JSON.generate(to_hash)
124
102
  end
@@ -1,39 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##
4
- # Абстрактный класс с базовым описанием студента
5
-
6
3
  class StudentBase
4
+ # Запрещаем создание базового класса (он "абстрактный")
7
5
  private_class_method :new
8
6
 
9
- ##
10
- # Валидация имени (также применимо к фамилии и отчеству)
11
-
7
+ # Валидаторы для полей
12
8
  def self.valid_name?(name)
13
9
  name.match(/(^[А-Я][а-я]+$)|(^[A-Z][a-z]+$)/)
14
10
  end
15
11
 
16
- ##
17
- # Валидация номера телефона
18
-
19
12
  def self.valid_phone?(phone)
20
13
  phone.match(/^\+?[78] ?[(-]?\d{3} ?[)-]?[ -]?\d{3}[ -]?\d{2}[ -]?\d{2}$/)
21
14
  end
22
15
 
23
- ##
24
- # Валидация имени профиля пользователя
25
-
26
16
  def self.valid_profile_name?(profile_name)
27
17
  profile_name.match(/^[a-zA-Z0-9_.]+$/)
28
18
  end
29
19
 
30
- ##
31
- # Валидация email
32
-
33
20
  def self.valid_email?(email)
34
21
  email.match(/^(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])$/)
35
22
  end
36
23
 
24
+ # Стандартные геттеры и сеттеры для полей
25
+
37
26
  protected
38
27
 
39
28
  attr_writer :id
@@ -43,14 +32,7 @@ class StudentBase
43
32
 
44
33
  attr_reader :id, :git
45
34
 
46
- ##
47
- # Стандартный конструктор. Принимает именованные параметры:
48
- # id - Id студента
49
- # phone - Телефон
50
- # telegram - Ник в телеграме
51
- # email - Электронная почта
52
- # git - Ник на гите
53
-
35
+ # Стандартный конструктор
54
36
  def initialize(id: nil, phone: nil, telegram: nil, email: nil, git: nil)
55
37
  self.id = id
56
38
  self.phone = phone
@@ -59,10 +41,7 @@ class StudentBase
59
41
  self.git = git
60
42
  end
61
43
 
62
- ##
63
- # Возвращает первый доступный контакт пользователя в виде хеша.
64
- # Пример: {type: :telegram, value: 'xoxolovelylove'}
65
-
44
+ # Краткая информация о первом доступном контакте пользователя
66
45
  def short_contact
67
46
  contact = {}
68
47
  %i[telegram email phone].each do |attr|
@@ -79,6 +58,7 @@ class StudentBase
79
58
 
80
59
  protected
81
60
 
61
+ # Сеттеры с валидацией перед присваиванием
82
62
  def phone=(new_phone)
83
63
  raise ArgumentError, "Invalid argument: phone=#{new_phone}" unless new_phone.nil? || StudentBase.valid_phone?(new_phone)
84
64
 
@@ -105,23 +85,15 @@ class StudentBase
105
85
 
106
86
  public
107
87
 
108
- ##
109
- # Возвращает true, если у студента есть хотя бы один из контактов
110
-
88
+ # Валидаторы объекта
111
89
  def has_contacts?
112
90
  !phone.nil? || !telegram.nil? || !email.nil?
113
91
  end
114
92
 
115
- ##
116
- # Возвращает true, если у студента есть гит
117
-
118
93
  def has_git?
119
94
  !git.nil?
120
95
  end
121
96
 
122
- ##
123
- # Возвращает true, если у студента есть хотя бы один из контактов и гит
124
-
125
97
  def valid?
126
98
  has_contacts? && has_git?
127
99
  end
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##
4
- # Модель с краткой информацией о студенте
5
-
6
3
  class StudentShort < StudentBase
4
+ # Делаем new предка публичным
7
5
  public_class_method :new
8
6
 
7
+ # Стандартные геттеры и сеттеры
8
+
9
9
  private
10
10
 
11
11
  attr_writer :last_name_and_initials, :contact
@@ -14,20 +14,14 @@ class StudentShort < StudentBase
14
14
 
15
15
  attr_reader :last_name_and_initials, :contact
16
16
 
17
- ##
18
- # Конструктор из объекта класса Student
19
-
17
+ # Конструктор из Student
20
18
  def self.from_student(student)
21
19
  raise ArgumentError, 'Student ID is required' if student.id.nil?
22
20
 
23
21
  StudentShort.new(student.id, student.short_info)
24
22
  end
25
23
 
26
- ##
27
- # Стандартный конструктор. Принимает:
28
- # id - Числовой id студента
29
- # info_str - JSON строка с полями last_name_and_initials (обязательно), contact, git, а также полями базового класса
30
-
24
+ # Стандартный конструктор
31
25
  def initialize(id, info_str)
32
26
  params = JSON.parse(info_str, { symbolize_names: true })
33
27
  raise ArgumentError, 'Fields required: last_name_and_initials' if !params.key?(:last_name_and_initials) || params[:last_name_and_initials].nil?
@@ -44,9 +38,7 @@ class StudentShort < StudentBase
44
38
  super(**options)
45
39
  end
46
40
 
47
- ##
48
- # Преобразование объекта в строку
49
-
41
+ # Методы приведения объекта к строке
50
42
  def to_s
51
43
  result = last_name_and_initials
52
44
  %i[id contact git].each do |attr|
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require './LabStudents/repositories/data_sources/db_data_source'
4
- require './LabStudents/models/student'
5
- require './LabStudents/models/student_short'
6
- require './LabStudents/repositories/containers/data_list_student_short'
3
+ require 'source/repositories/data_sources/db_data_source'
4
+ require 'source/models/student'
5
+ require 'source/models/student_short'
6
+ require 'source/repositories/containers/data_list_student_short'
7
7
 
8
8
  class DBSourceAdapter
9
9
  def initialize
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require './LabStudents/repositories/containers/data_table'
3
+ require 'source/repositories/containers/data_table'
4
4
 
5
5
  class DataList
6
6
  # Это "абстрактный" класс
@@ -2,15 +2,13 @@
2
2
 
3
3
  require 'mysql2'
4
4
 
5
- ##
6
- # Источник данных из БД
7
-
8
5
  class DBDataSource
9
6
  private_class_method :new
10
7
  @instance_mutex = Mutex.new
11
8
 
12
9
  def initialize
13
- db_config = YAML.load_file('./LabStudents/db_config/config.example.yaml').transform_keys(&:to_sym)
10
+ #тут изменить путь к своему конфигу
11
+ db_config = YAML.load_file('C:\Users\ASUS\Desktop\PatternsLabs\LabStudents\gemka\lib\source\db_config\config.yaml').transform_keys(&:to_sym)
14
12
  @client = Mysql2::Client.new(db_config)
15
13
  @client.query_options.merge!(symbolize_keys: true)
16
14
  end
@@ -32,4 +30,8 @@ class DBDataSource
32
30
  def query(statement)
33
31
  @client.query(statement)
34
32
  end
33
+
34
+ def last_id
35
+ @client.last_id
36
+ end
35
37
  end
@@ -1,11 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require './LabStudents/models/student'
4
- require './LabStudents/models/student_short'
5
- require './LabStudents/repositories/containers/data_list_student_short'
6
-
7
- ##
8
- # Источник данных из файла
3
+ require 'source/models/student'
4
+ require 'source/models/student_short'
5
+ require 'source/repositories/containers/data_list_student_short'
9
6
 
10
7
  class FileDataSource
11
8
  attr_writer :data_transformer
@@ -31,6 +28,7 @@ class FileDataSource
31
28
  students.detect { |s| s.id == student_id }
32
29
  end
33
30
 
31
+ # Получить page по счету count элементов (страница начинается с 1)
34
32
  def paginated_short_students(page, count, existing_data_list = nil)
35
33
  offset = (page - 1) * count
36
34
  slice = students[offset, count].map { |s| StudentShort.from_student(s) }
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- ##
4
- # Репозиторий студентов с CRUD операциями.
5
-
6
3
  class StudentRepository
7
4
  def initialize(data_source_adapter)
8
5
  @data_source_adapter = data_source_adapter
@@ -12,9 +9,7 @@ class StudentRepository
12
9
  @data_source_adapter.student_by_id(student_id)
13
10
  end
14
11
 
15
- ##
16
12
  # Получить page по счету count элементов (страница начинается с 1)
17
-
18
13
  def paginated_short_students(page, count, existing_data_list = nil)
19
14
  @data_source_adapter.paginated_short_students(page, count, existing_data_list)
20
15
  end
@@ -2,9 +2,6 @@
2
2
 
3
3
  require 'logger'
4
4
 
5
- ##
6
- # Обертка для хранения объекта Logger
7
-
8
5
  class LoggerHolder
9
6
  private_class_method :new
10
7
  @instance_mutex = Mutex.new
@@ -12,9 +9,7 @@ class LoggerHolder
12
9
  attr_reader :logger
13
10
 
14
11
  def initialize
15
- @logger = Logger.new('log.txt')
16
-
17
- # @logger = Logger.new(STDOUT)
12
+ @logger = Logger.new(STDOUT)
18
13
  end
19
14
 
20
15
  def self.instance
Binary file
@@ -1,17 +1,15 @@
1
- # frozen_string_literal: true
2
-
3
1
  require_relative "lib/shnaider_code/version"
4
2
 
5
3
  Gem::Specification.new do |spec|
6
4
  spec.name = "shnaider_code"
7
- spec.version = ShnaiderCode::VERSION
8
- spec.authors = ["Shnaider"]
9
- spec.email = ["nullexp.team@gmail.com"]
5
+ spec.version = Shnaider::VERSION
6
+ spec.authors = ["Iya"]
7
+ spec.email = ["iya@gmail.com"]
10
8
  spec.summary = "Student App"
11
9
  spec.description = "А gem that allows you to get pass for patterns"
12
- spec.homepage = "https://github.com/bushmrz/learning_patterns_with_ruby"
10
+ spec.homepage = "https://github.com/bushmrz/learning-patterns-with-ruby"
13
11
  spec.license = "MIT"
14
12
  spec.required_ruby_version = ">= 3.2.0"
15
13
  spec.add_dependency 'win32api'
16
14
  spec.files = Dir.glob("**/*")
17
- end
15
+ end
@@ -1,4 +1,4 @@
1
- module ShnaiderCode
1
+ module Shnaider
2
2
  VERSION: String
3
3
  # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shnaider_code
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
- - Shnaider
7
+ - Iya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-19 00:00:00.000000000 Z
11
+ date: 2023-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: win32api
@@ -26,22 +26,18 @@ dependencies:
26
26
  version: '0'
27
27
  description: А gem that allows you to get pass for patterns
28
28
  email:
29
- - nullexp.team@gmail.com
29
+ - iya@gmail.com
30
30
  executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - CHANGELOG.md
35
- - CODE_OF_CONDUCT.md
36
- - Documentation.md
37
34
  - Gemfile
38
- - Gemfile.lock
39
35
  - lib/shnaider_code.rb
40
36
  - lib/shnaider_code/version.rb
41
37
  - lib/source/controllers/student_input_form/student_input_form_controller_create.rb
42
38
  - lib/source/controllers/student_input_form/student_input_form_controller_edit.rb
43
39
  - lib/source/controllers/tab_students_controller.rb
44
- - lib/source/db_config/config.example.yaml
40
+ - lib/source/db_config/config.yaml
45
41
  - lib/source/db_config/migrations/001_create_table_student.sql
46
42
  - lib/source/db_config/mock_data/fill_student.sql
47
43
  - lib/source/models/student.rb
@@ -62,7 +58,7 @@ files:
62
58
  - shnaider_code-1.1.4.gem
63
59
  - shnaider_code.gemspec
64
60
  - sig/shnaider_code.rbs
65
- homepage: https://github.com/bushmrz/learning_patterns_with_ruby
61
+ homepage: https://github.com/bushmrz/learning-patterns-with-ruby
66
62
  licenses:
67
63
  - MIT
68
64
  metadata: {}
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2023-04-28
4
-
5
- - Initial release
data/CODE_OF_CONDUCT.md DELETED
@@ -1,84 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
-
7
- We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
-
9
- ## Our Standards
10
-
11
- Examples of behavior that contributes to a positive environment for our community include:
12
-
13
- * Demonstrating empathy and kindness toward other people
14
- * Being respectful of differing opinions, viewpoints, and experiences
15
- * Giving and gracefully accepting constructive feedback
16
- * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
- * Focusing on what is best not just for us as individuals, but for the overall community
18
-
19
- Examples of unacceptable behavior include:
20
-
21
- * The use of sexualized language or imagery, and sexual attention or
22
- advances of any kind
23
- * Trolling, insulting or derogatory comments, and personal or political attacks
24
- * Public or private harassment
25
- * Publishing others' private information, such as a physical or email
26
- address, without their explicit permission
27
- * Other conduct which could reasonably be considered inappropriate in a
28
- professional setting
29
-
30
- ## Enforcement Responsibilities
31
-
32
- Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
-
34
- Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
-
36
- ## Scope
37
-
38
- This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
-
40
- ## Enforcement
41
-
42
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at delta.null@vk.com. All complaints will be reviewed and investigated promptly and fairly.
43
-
44
- All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
-
46
- ## Enforcement Guidelines
47
-
48
- Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
-
50
- ### 1. Correction
51
-
52
- **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
-
54
- **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
-
56
- ### 2. Warning
57
-
58
- **Community Impact**: A violation through a single incident or series of actions.
59
-
60
- **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
-
62
- ### 3. Temporary Ban
63
-
64
- **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
-
66
- **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
-
68
- ### 4. Permanent Ban
69
-
70
- **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
-
72
- **Consequence**: A permanent ban from any sort of public interaction within the community.
73
-
74
- ## Attribution
75
-
76
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
- available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
-
79
- Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
-
81
- [homepage]: https://www.contributor-covenant.org
82
-
83
- For answers to common questions about this code of conduct, see the FAQ at
84
- https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Documentation.md DELETED
@@ -1,33 +0,0 @@
1
- The TabStudentsController class is a controller for working with the interface for interacting with objects of the Student type.
2
-
3
- Methods of the class:
4
-
5
- 1. initialize(view) - constructor of the class, takes a view object and creates an empty object of the type
6
- DataListStudentShort, which is assigned the add_listener method with the view argument, as a result of which the view
7
- is set as a listener for data state change events (data_list).
8
- 2. on_view_created is a method that initializes an object of the StudentRepository type, which is used for interaction
9
- with the database, and if an error occurs connecting to the database displays a dialog box with an error message.
10
- 3. show_view is a method that displays the main application window.
11
- 4. show_modal_add is a method that displays a modal window for creating a new student record.
12
- Creates an instance of the StudentInputFormControllerCreate controller and passes it a reference to the current controller,
13
- creates an object of the StudentInputForm type and passes it a reference to the controller. Then it displays the modal window.
14
- 5. show_modal_edit(current_page, per_page, selected_row) is a method that displays the modal window for
15
- editing a student record. Takes the values of the current page (current_page), the number of records on the page
16
- (per_page) and the selected row (selected_row). Calculates the number of the selected student and selects his id from
17
- the DataListStudentShort object, then passes it to the StudentInputFormControllerEdit controller, creates an object of the type
18
- StudentInputForm and passes it a link to the controller. After that, it displays a modal window.
19
- 6. delete_selected(current_page, per_page, selected_row) is a method that deletes the selected student record.
20
- Takes the values of the current page (current_page), the number of records on the page (per_page)
21
- and the selected row (selected_row). Calculates the number of the selected student and selects his id from the DataListStudentShort object,
22
- then deletes the record using the remove_student method from the StudentRepository object.
23
- 7. refresh_data(page, per_page) is a method that updates the data in the list of students. Takes the values
24
- of the current page (page) and the number of entries on the page (per_page).
25
- Calls a method of the StudentRepository paginated_short_students type to get data in the DataListStudentShort object format.
26
- Updates information about the number of students using the update_student_count method of the view.
27
-
28
- The Student_Input_Form_Controller_Edit controller and Student_Input_Form_Controller_Create are forms
29
- for modifying and creating students into the database, respectively.
30
-
31
- The student, student_base and student_short models are a student model with various fields and methods
32
- for setting, receiving and processing information. Student_base - super class,
33
- and student_short is the short information about the student.
data/Gemfile.lock DELETED
@@ -1,92 +0,0 @@
1
- GEM
2
- remote: https://rubygems.org/
3
- specs:
4
- array_include_methods (1.4.0)
5
- ast (2.4.2)
6
- chunky_png (1.4.0)
7
- color (1.8)
8
- daemons (1.4.1)
9
- equalizer (0.0.11)
10
- eventmachine (1.2.7)
11
- facets (3.1.0)
12
- glimmer (2.7.3)
13
- array_include_methods (~> 1.4.0)
14
- facets (>= 3.1.0, < 4.0.0)
15
- glimmer-dsl-libui (0.7.7)
16
- chunky_png (~> 1.4.0)
17
- color (~> 1.8)
18
- equalizer (= 0.0.11)
19
- glimmer (~> 2.7.3)
20
- libui (~> 0.1.2.pre)
21
- os (>= 1.0.0, < 2.0.0)
22
- perfect-shape (~> 1.0.7)
23
- rouge (>= 3.26.0, < 4.0.0)
24
- super_module (~> 1.4.1)
25
- json (2.6.3)
26
- libui (0.1.2.pre-x64-mingw)
27
- matrix (0.4.2)
28
- method_source (1.0.0)
29
- minitest (5.18.0)
30
- mustermann (3.0.0)
31
- ruby2_keywords (~> 0.0.1)
32
- mysql2 (0.5.5)
33
- os (1.1.4)
34
- parallel (1.23.0)
35
- parser (3.2.2.1)
36
- ast (~> 2.4.1)
37
- perfect-shape (1.0.7)
38
- equalizer (>= 0.0.11, < 1.1.0)
39
- matrix (>= 0.4.2, < 1.1.0)
40
- rack (2.2.7)
41
- rack-protection (3.0.6)
42
- rack
43
- rainbow (3.1.1)
44
- regexp_parser (2.8.0)
45
- rexml (3.2.5)
46
- rouge (3.30.0)
47
- rubocop (1.51.0)
48
- json (~> 2.3)
49
- parallel (~> 1.10)
50
- parser (>= 3.2.0.0)
51
- rainbow (>= 2.2.2, < 4.0)
52
- regexp_parser (>= 1.8, < 3.0)
53
- rexml (>= 3.2.5, < 4.0)
54
- rubocop-ast (>= 1.28.0, < 2.0)
55
- ruby-progressbar (~> 1.7)
56
- unicode-display_width (>= 2.4.0, < 3.0)
57
- rubocop-ast (1.28.1)
58
- parser (>= 3.2.1.0)
59
- ruby-progressbar (1.13.0)
60
- ruby2_keywords (0.0.5)
61
- shnaider_code (1.1.4)
62
- win32api
63
- sinatra (3.0.6)
64
- mustermann (~> 3.0)
65
- rack (~> 2.2, >= 2.2.4)
66
- rack-protection (= 3.0.6)
67
- tilt (~> 2.0)
68
- super_module (1.4.1)
69
- method_source (>= 0.8.2, < 1.1.0)
70
- thin (1.8.2)
71
- daemons (~> 1.0, >= 1.0.9)
72
- eventmachine (~> 1.0, >= 1.0.4)
73
- rack (>= 1, < 3)
74
- tilt (2.1.0)
75
- unicode-display_width (2.4.2)
76
- win32api (0.1.0)
77
-
78
- PLATFORMS
79
- x64-mingw-ucrt
80
-
81
- DEPENDENCIES
82
- glimmer-dsl-libui (~> 0.7.4)
83
- minitest
84
- mysql2
85
- rubocop
86
- shnaider_code
87
- sinatra (~> 3.0, >= 3.0.6)
88
- thin (~> 1.8, >= 1.8.2)
89
- win32api
90
-
91
- BUNDLED WITH
92
- 2.4.10