mc_gem 0.0.1
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 +7 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +91 -0
- data/Lab1/arr1_3.txt +1 -0
- data/Lab1/lb1_1.rb +19 -0
- data/Lab1/lb1_2.rb +28 -0
- data/Lab1/lb1_3.rb +46 -0
- data/Lab1/lb1_4.rb +82 -0
- data/Lab2/1Class.jpg +0 -0
- data/Lab2/Web/main.rb +89 -0
- data/Lab2/Web/views/add.html +168 -0
- data/Lab2/Web/views/main.html +233 -0
- data/Lab2/data_storage/students1.txt +1 -0
- data/Lab2/data_storage/studentsRead.json +36 -0
- data/Lab2/data_storage/studentsRead.txt +3 -0
- data/Lab2/data_storage/studentsRead.yaml +26 -0
- data/Lab2/data_storage/studentsWrite.json +42 -0
- data/Lab2/data_storage/studentsWrite.txt +4 -0
- data/Lab2/data_storage/studentsWrite.yaml +31 -0
- data/Lab2/examples/Strategy.rb +38 -0
- data/Lab2/examples/adapter.rb +30 -0
- data/Lab2/examples/database.rb +15 -0
- data/Lab2/examples/observer_example.rb +51 -0
- data/Lab2/examples/pattern_pattern.rb +44 -0
- data/Lab2/examples/site_example.rb +21 -0
- data/Lab2/examples/views/about.erb +11 -0
- data/Lab2/examples/views/contact.erb +15 -0
- data/Lab2/examples/views/index.erb +11 -0
- data/Lab2/main.rb +6 -0
- data/Lab2/main_window.rb +31 -0
- data/Lab2/student_input_form.rb +71 -0
- data/Lab2/tab_students.rb +157 -0
- data/Lab2/test/student_test.rb +91 -0
- data/README.md +3 -0
- data/mc_gem/CHANGELOG.md +5 -0
- data/mc_gem/CODE_OF_CONDUCT.md +84 -0
- data/mc_gem/Documentation.md +33 -0
- data/mc_gem/Gemfile +13 -0
- data/mc_gem/LICENSE.txt +21 -0
- data/mc_gem/README.md +1 -0
- data/mc_gem/lib/mc_gem/version.rb +5 -0
- data/mc_gem/lib/mc_gem.rb +10 -0
- data/mc_gem/lib/source/adapters/student_list_adapter.rb +95 -0
- data/mc_gem/lib/source/containers/Data_list.rb +66 -0
- data/mc_gem/lib/source/containers/Data_list_student_short.rb +17 -0
- data/mc_gem/lib/source/containers/Data_table.rb +25 -0
- data/mc_gem/lib/source/controllers/student_edit_form_controller.rb +63 -0
- data/mc_gem/lib/source/controllers/student_input_form_controller.rb +56 -0
- data/mc_gem/lib/source/controllers/student_list_controller.rb +83 -0
- data/mc_gem/lib/source/converters/Converter.rb +11 -0
- data/mc_gem/lib/source/converters/Converter_json.rb +14 -0
- data/mc_gem/lib/source/converters/Converter_txt.rb +26 -0
- data/mc_gem/lib/source/converters/Converter_yaml.rb +14 -0
- data/mc_gem/lib/source/database/scripts/create_table.sql +10 -0
- data/mc_gem/lib/source/database/scripts/insert_data.sql +4 -0
- data/mc_gem/lib/source/database/student_list_db.rb +41 -0
- data/mc_gem/lib/source/database/students_db.rb +79 -0
- data/mc_gem/lib/source/model/Student.rb +106 -0
- data/mc_gem/lib/source/model/StudentBase.rb +50 -0
- data/mc_gem/lib/source/model/Student_short.rb +39 -0
- data/mc_gem/lib/source/repositories/Student_list.rb +65 -0
- data/mc_gem/lib/source/repositories/student_list_adv.rb +35 -0
- data/mc_gem/lib/source/util/LoggerHolder.rb +22 -0
- data/mc_gem/mc_gem.gemspec +17 -0
- data/mc_gem/sig/mvcStudentXD.rbs +4 -0
- metadata +121 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
class StudentList
|
2
|
+
private
|
3
|
+
attr_accessor :students, :gen_id, :typer
|
4
|
+
|
5
|
+
public
|
6
|
+
def initialize(typer)
|
7
|
+
self.students = []
|
8
|
+
self.gen_id = students.count + 1
|
9
|
+
self.typer = typer
|
10
|
+
end
|
11
|
+
|
12
|
+
def read_file(file_path)
|
13
|
+
raise ArgumentError.new("File not found #{file_path}") unless File.file?(file_path)
|
14
|
+
hash_students = typer.read_file(File.read(file_path))
|
15
|
+
self.students = hash_students.map{|h| Student.from_hash(h)}
|
16
|
+
nextId
|
17
|
+
end
|
18
|
+
|
19
|
+
def write_file(file_path)
|
20
|
+
hash_students = students.map(&:to_hash)
|
21
|
+
File.write(file_path, typer.write_file(hash_students))
|
22
|
+
end
|
23
|
+
|
24
|
+
def get_student(stud_id)
|
25
|
+
students.find{|s| s.id == stud_id}
|
26
|
+
end
|
27
|
+
|
28
|
+
def sorted
|
29
|
+
students.sort_by(&:fio)
|
30
|
+
end
|
31
|
+
|
32
|
+
def add_student(student)
|
33
|
+
students << student
|
34
|
+
student.id = gen_id
|
35
|
+
nextId
|
36
|
+
end
|
37
|
+
|
38
|
+
def get_students_pag(k,n,existing_data = nil)
|
39
|
+
skip = (k-1) * n
|
40
|
+
new_data = students[skip, n].map{|s| StudentShort.from_student_class(s)}
|
41
|
+
|
42
|
+
return DataListStudentShort.new(new_data) if existing_data.nil?
|
43
|
+
|
44
|
+
existing_data.replace_objects(new_data)
|
45
|
+
existing_data
|
46
|
+
end
|
47
|
+
|
48
|
+
def replace_student(student_id, student)
|
49
|
+
idx = student.find{|s| s.id==student.id}
|
50
|
+
self.students[idx]=student
|
51
|
+
end
|
52
|
+
|
53
|
+
def remove_student(student_id)
|
54
|
+
self.students.reject! {|s| s.id==student_id}
|
55
|
+
end
|
56
|
+
|
57
|
+
def count
|
58
|
+
self.students.count
|
59
|
+
end
|
60
|
+
|
61
|
+
def nextId
|
62
|
+
self.gen_id=students.max_by(&:id).id + 1
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class StudentListAdv
|
4
|
+
private
|
5
|
+
attr_accessor :students_list_adapter
|
6
|
+
public
|
7
|
+
def initialize(students_list_adapter)
|
8
|
+
self.students_list_adapter = students_list_adapter
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_student(id)
|
12
|
+
students_list_adapter.get_student(id)
|
13
|
+
end
|
14
|
+
|
15
|
+
def remove_student(id)
|
16
|
+
students_list_adapter.remove_student(id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def replace_student(id, student)
|
20
|
+
students_list_adapter.replace_student(id, student)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_students_pag(k, n, data)
|
24
|
+
students_list_adapter.get_students_pag(k, n, data)
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_student(student)
|
28
|
+
students_list_adapter.add_student(student)
|
29
|
+
end
|
30
|
+
|
31
|
+
def count
|
32
|
+
students_list_adapter.count
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'logger'
|
2
|
+
|
3
|
+
class LoggerHolder
|
4
|
+
private_class_method :new
|
5
|
+
@instance_mutex = Mutex.new
|
6
|
+
|
7
|
+
attr_reader :logger
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@logger = Logger.new(STDOUT)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.instance
|
14
|
+
return @instance.logger if @instance
|
15
|
+
|
16
|
+
@instance_mutex.synchronize do
|
17
|
+
@instance ||= new
|
18
|
+
end
|
19
|
+
|
20
|
+
@instance.logger
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/mc_gem/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "mc_gem"
|
7
|
+
spec.version = Mc_Gem::VERSION
|
8
|
+
spec.authors = ["papaSquid"]
|
9
|
+
spec.email = ["bakladjant@mail.ru"]
|
10
|
+
spec.summary = "models and controllers"
|
11
|
+
spec.description = "This game will make sure you'll never touch Ruby ever again"
|
12
|
+
spec.homepage = "https://github.com/KiTTeNqz/RubyLabs"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
spec.add_dependency 'win32api'
|
16
|
+
spec.files = Dir.glob("**/*")
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mc_gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- papaSquid
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: win32api
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: This game will make sure you'll never touch Ruby ever again
|
28
|
+
email:
|
29
|
+
- bakladjant@mail.ru
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- Gemfile.lock
|
36
|
+
- Lab1/arr1_3.txt
|
37
|
+
- Lab1/lb1_1.rb
|
38
|
+
- Lab1/lb1_2.rb
|
39
|
+
- Lab1/lb1_3.rb
|
40
|
+
- Lab1/lb1_4.rb
|
41
|
+
- Lab2/1Class.jpg
|
42
|
+
- Lab2/Web/main.rb
|
43
|
+
- Lab2/Web/views/add.html
|
44
|
+
- Lab2/Web/views/main.html
|
45
|
+
- Lab2/data_storage/students1.txt
|
46
|
+
- Lab2/data_storage/studentsRead.json
|
47
|
+
- Lab2/data_storage/studentsRead.txt
|
48
|
+
- Lab2/data_storage/studentsRead.yaml
|
49
|
+
- Lab2/data_storage/studentsWrite.json
|
50
|
+
- Lab2/data_storage/studentsWrite.txt
|
51
|
+
- Lab2/data_storage/studentsWrite.yaml
|
52
|
+
- Lab2/examples/Strategy.rb
|
53
|
+
- Lab2/examples/adapter.rb
|
54
|
+
- Lab2/examples/database.rb
|
55
|
+
- Lab2/examples/observer_example.rb
|
56
|
+
- Lab2/examples/pattern_pattern.rb
|
57
|
+
- Lab2/examples/site_example.rb
|
58
|
+
- Lab2/examples/views/about.erb
|
59
|
+
- Lab2/examples/views/contact.erb
|
60
|
+
- Lab2/examples/views/index.erb
|
61
|
+
- Lab2/main.rb
|
62
|
+
- Lab2/main_window.rb
|
63
|
+
- Lab2/student_input_form.rb
|
64
|
+
- Lab2/tab_students.rb
|
65
|
+
- Lab2/test/student_test.rb
|
66
|
+
- README.md
|
67
|
+
- mc_gem/CHANGELOG.md
|
68
|
+
- mc_gem/CODE_OF_CONDUCT.md
|
69
|
+
- mc_gem/Documentation.md
|
70
|
+
- mc_gem/Gemfile
|
71
|
+
- mc_gem/LICENSE.txt
|
72
|
+
- mc_gem/README.md
|
73
|
+
- mc_gem/lib/mc_gem.rb
|
74
|
+
- mc_gem/lib/mc_gem/version.rb
|
75
|
+
- mc_gem/lib/source/adapters/student_list_adapter.rb
|
76
|
+
- mc_gem/lib/source/containers/Data_list.rb
|
77
|
+
- mc_gem/lib/source/containers/Data_list_student_short.rb
|
78
|
+
- mc_gem/lib/source/containers/Data_table.rb
|
79
|
+
- mc_gem/lib/source/controllers/student_edit_form_controller.rb
|
80
|
+
- mc_gem/lib/source/controllers/student_input_form_controller.rb
|
81
|
+
- mc_gem/lib/source/controllers/student_list_controller.rb
|
82
|
+
- mc_gem/lib/source/converters/Converter.rb
|
83
|
+
- mc_gem/lib/source/converters/Converter_json.rb
|
84
|
+
- mc_gem/lib/source/converters/Converter_txt.rb
|
85
|
+
- mc_gem/lib/source/converters/Converter_yaml.rb
|
86
|
+
- mc_gem/lib/source/database/scripts/create_table.sql
|
87
|
+
- mc_gem/lib/source/database/scripts/insert_data.sql
|
88
|
+
- mc_gem/lib/source/database/student_list_db.rb
|
89
|
+
- mc_gem/lib/source/database/students_db.rb
|
90
|
+
- mc_gem/lib/source/model/Student.rb
|
91
|
+
- mc_gem/lib/source/model/StudentBase.rb
|
92
|
+
- mc_gem/lib/source/model/Student_short.rb
|
93
|
+
- mc_gem/lib/source/repositories/Student_list.rb
|
94
|
+
- mc_gem/lib/source/repositories/student_list_adv.rb
|
95
|
+
- mc_gem/lib/source/util/LoggerHolder.rb
|
96
|
+
- mc_gem/mc_gem.gemspec
|
97
|
+
- mc_gem/sig/mvcStudentXD.rbs
|
98
|
+
homepage: https://github.com/KiTTeNqz/RubyLabs
|
99
|
+
licenses:
|
100
|
+
- MIT
|
101
|
+
metadata: {}
|
102
|
+
post_install_message:
|
103
|
+
rdoc_options: []
|
104
|
+
require_paths:
|
105
|
+
- lib
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.6.0
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
requirements: []
|
117
|
+
rubygems_version: 3.4.10
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: models and controllers
|
121
|
+
test_files: []
|