gaku_sample 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1794cb88a013519c12d7678daf65b24bd04a518
4
+ data.tar.gz: 4a7db83bb0521993d66ab4a4b480a8c78ef27d14
5
+ SHA512:
6
+ metadata.gz: 033adb52b869b58bfeea404bf7401a8d542e36ec37f0c58984b17180c908ce0a7a6a909555724f85ac966dff2592e0fa3e51b1ce18da6ccb0b024bbfa5a6a5c4
7
+ data.tar.gz: c214499d62dd813cbbe8e43b67c40ff85d379494e7001ad6748cfc8a5e431b2c8378f92aec03911553382a16ac2182e49da709f82e8434134735e428afc7279e
@@ -0,0 +1,12 @@
1
+ els = %w(
2
+ JuniorRuby SeniorRuby RubyGuru
3
+ JuniorJavascript SeniorJavascript JavascriptGuru
4
+ JuniorClojure SeniorClojure ClojureGuru
5
+ JuniorScala SeniorScala ScalaGuru
6
+ )
7
+
8
+ say "Creating #{els.size} achievements ...".yellow
9
+
10
+ els.each do |el|
11
+ Gaku::Achievement.where(name: el).first_or_create!
12
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ require 'shared_sample_data'
3
+
4
+ say "Creating #{@count[:changes]} student changes ...".yellow
5
+
6
+ commute_method_type = Gaku::CommuteMethodType.where(name: 'Changed CommuteMethodType').first_or_create!
7
+ scholarship_status = Gaku::ScholarshipStatus.where(name: 'Changed Scholarship Status').first_or_create!
8
+ enrollment_status = Gaku::EnrollmentStatus.where(code: 'changed_enrollment_status').first_or_create!
9
+
10
+ counter = 0
11
+
12
+ batch_create(@count[:changes]) do
13
+ counter += 1
14
+ random_student = random_person.merge(
15
+ commute_method_type: @commute_method_type,
16
+ enrollment_status_code: @enrollment_status,
17
+ scholarship_status: @scholarship_status,
18
+ student_id_number: "number_#{counter}",
19
+ student_foreign_id_number: "foreign_number_#{counter}",
20
+ )
21
+
22
+ student = Gaku::Student.where(random_student).first_or_create!
23
+ student.name = Faker::Name.first_name
24
+ student.middle_name = Faker::Name.first_name
25
+ student.surname = Faker::Name.last_name
26
+ student.enrollment_status_code = enrollment_status.code
27
+ student.commute_method_type = commute_method_type
28
+ student.scholarship_status = scholarship_status
29
+ student.student_id_number = "number_#{counter+100}"
30
+ student.student_foreign_id_number = "foreign_number_#{counter+100}"
31
+ student.save!
32
+
33
+ student.soft_delete
34
+ student.destroy
35
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ class_groups = [
4
+ { name: 'Ms. Moore 3rd Grade', grade: 3 },
5
+ { name: 'Advanced', grade: 5 },
6
+ { name: 'Mr. Nagae', grade: 7 },
7
+ { name: 'A組', grade: 1 },
8
+ { name: 'A組', grade: 2 },
9
+ { name: 'さくら組', grade: 0 },
10
+ { name: 'マルチメディア専攻', grade: 1 },
11
+ { name: 'Mr.Kalkov', grade: 7 },
12
+ { name: 'Mr.Kagetsuki', grade: 7 },
13
+ { name: 'Mr.Tapalilov', grade: 7 },
14
+ { name: 'Mr.Georgiev', grade: 7 },
15
+ { name: 'Mrs.Kostova', grade: 7 }
16
+ ]
17
+
18
+ say "Creating #{class_groups.size} class groups ...".yellow
19
+
20
+ class_groups.each do |class_group|
21
+ Gaku::ClassGroup.where(class_group).first_or_create!
22
+ end
@@ -0,0 +1,7 @@
1
+ els = %w( Ruby Node.js Clojure )
2
+
3
+ say "Creating #{els.size} course groups ...".yellow
4
+
5
+ els.each do |el|
6
+ Gaku::CourseGroup.where(name: el).first_or_create!
7
+ end
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ codes = ['Spring2012', 'Fall2012', 'Spring2013', 'Fall2013']
4
+
5
+ say "Creating #{codes.size} courses ...".yellow
6
+
7
+ codes.each do |code|
8
+ Gaku::Course.where(code: code).first_or_create!
9
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ require 'shared_sample_data'
3
+
4
+ say "Creating #{@count[:disposals]} teachers with addresses and contacts ...".yellow
5
+
6
+ batch_create(@count[:disposals]) do
7
+ teacher = Gaku::Teacher.where(random_person).first_or_create!
8
+ teacher.addresses.where(random_address.merge(deleted: true)).first_or_create!
9
+ teacher.contacts.where(random_home_phone.merge(deleted: true)).first_or_create!
10
+ end
11
+
12
+ say "Creating #{@count[:disposals]} students with addresses and contacts ...".yellow
13
+
14
+ batch_create(@count[:disposals]) do
15
+ student = Gaku::Student.where(random_person).first_or_create!
16
+ student.addresses.where(random_address.merge(deleted: true)).first_or_create!
17
+ student.contacts.where(random_home_phone.merge(deleted: true)).first_or_create!
18
+ end
19
+
20
+ say "Creating #{@count[:disposals]} guardians with addresses and contacts ...".yellow
21
+
22
+ batch_create(@count[:disposals]) do
23
+ guardian = Gaku::Guardian.where(random_person).first_or_create!
24
+ guardian.addresses.where(random_address.merge(deleted: true)).first_or_create!
25
+ guardian.contacts.where(random_home_phone.merge(deleted: true)).first_or_create!
26
+ end
@@ -0,0 +1,9 @@
1
+ require 'shared_sample_data'
2
+
3
+ say "Creating #{@count[:disposals]} exam attachment disposals ...".yellow
4
+
5
+ batch_create(@count[:disposals]) do
6
+ exam = Gaku::Exam.where(name: "#{Faker::Education.major} Exam").first_or_create!
7
+ exam_portion = exam.exam_portions.where(name: "#{Faker::Education.major} ExamPortion", max_score: 100).first_or_create!
8
+ Gaku::Attachment.create!(name: 'Attachment Name', attachable: exam_portion, asset: File.open(File.join(File.dirname(__FILE__), '..', 'images', '120x120.jpg')), deleted: true)
9
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ require 'shared_sample_data'
3
+
4
+ say "Creating #{@count[:disposals]} course groups ...".yellow
5
+
6
+ batch_create(@count[:disposals]) do
7
+ Gaku::CourseGroup.where(name: "#{Faker::Education.major} CourseGroup", deleted: true).first_or_create!
8
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ require 'shared_sample_data'
3
+
4
+ say "Creating #{@count[:disposals]} exams ...".yellow
5
+
6
+ batch_create(@count[:disposals]) do
7
+ Gaku::Exam.where(name: Faker::Education.major, deleted: true).first_or_create!
8
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ require 'shared_sample_data'
3
+
4
+ say "Creating #{@count[:disposals]} students and guardians ...".yellow
5
+
6
+ batch_create(@count[:disposals]) do
7
+ student = Gaku::Student.where(random_person.merge(deleted: true)).first_or_create!
8
+ guardian = Gaku::Guardian.where(random_person.merge(deleted: true)).first_or_create!
9
+ student.guardians << guardian
10
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+ require 'shared_sample_data'
3
+
4
+ say "Creating #{@count[:disposals]} teachers ...".yellow
5
+
6
+ batch_create(@count[:disposals]) do
7
+ student = Gaku::Teacher.where(random_person.merge(deleted: true)).first_or_create!
8
+ end
@@ -0,0 +1,14 @@
1
+ # encoding: utf-8
2
+
3
+ names = [
4
+ 'Summer Program Entry',
5
+ 'Regular Program Entry',
6
+ 'International Program Exams',
7
+ 'National Information Engineer Certification'
8
+ ]
9
+
10
+ say "Creating #{names.size} exams ...".yellow
11
+
12
+ names.each do |name|
13
+ Gaku::Exam.where(name: name).first_or_create!
14
+ end
@@ -0,0 +1,7 @@
1
+ els = %w( Tennis Football Basketball Handball Climbing Running Swimming Rugby PingPong Chess Fitness )
2
+
3
+ say "Creating #{els.size} extracurricular activities ...".yellow
4
+
5
+ els.each do |el|
6
+ Gaku::ExtracurricularActivity.where(name: el).first_or_create!
7
+ end
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ require 'shared_sample_data'
3
+
4
+ say 'Creating grading widget data ...'.yellow
5
+
6
+ syllabus = Gaku::Syllabus.where(name: 'Ruby', code: 'rb').first_or_create!
7
+ course = Gaku::Course.where(code: 'Fall 2011').first_or_create!
8
+ enrollment_status_code = Gaku::EnrollmentStatus.where(code: 'admitted').first.try(:code)
9
+
10
+ student = Gaku::Student.where(@john_doe).first_or_create!
11
+
12
+ exam1 = Gaku::Exam.where(name: 'Midterm', use_weighting: true, weight: 4).first_or_create!
13
+ exam1_portion1 = exam1.exam_portions.create(name: 'Multiple Choice', max_score: 100)
14
+ exam1_portion2 = exam1.exam_portions.create(name: 'Practical', max_score: 200)
15
+
16
+ exam2 = Gaku::Exam.where(name: 'Final', use_weighting: true, weight: 6).first_or_create!
17
+ exam2_portion1 = exam2.exam_portions.where(name: 'Question and Answer', max_score: 200).first_or_create!
18
+ exam2_portion2 = exam2.exam_portions.where(name: 'Practical', max_score: 300).first_or_create!
19
+
20
+ exams = [exam1, exam2]
21
+
22
+ unless syllabus.exams.count > 0
23
+ syllabus.exams << exams
24
+ end
25
+
26
+ unless course.students.count > 0
27
+ course.students << student
28
+ end
29
+
30
+ syllabus.courses << course
31
+
Binary file
@@ -0,0 +1,9 @@
1
+ # encoding: utf-8
2
+
3
+ roles = %w(Admin ProgramManager Instructor Counselor Staff Principal VicePrincipal Student Guardian)
4
+
5
+ say "Creating #{roles.size} roles ...".yellow
6
+
7
+ roles.each do |role|
8
+ Gaku::Role.where(name: role).first_or_create!
9
+ end
@@ -0,0 +1,10 @@
1
+ els = %w(
2
+ RubyDeveloper JavascriptDeveloper ClojureDeveloper
3
+ ScalaDeveloper PythonDeveloper GoDeveloper
4
+ )
5
+
6
+ say "Creating #{els.size} specialties ...".yellow
7
+
8
+ els.each do |el|
9
+ Gaku::Specialty.where(name: el).first_or_create!
10
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ require 'shared_sample_data'
3
+
4
+ say 'Creating predefined students ...'.yellow
5
+ students = [
6
+ { name: 'Anonime', surname: 'Anonimized', birth_date: Date.new(1982,1,1), enrollment_status_code: @enrollment_status },
7
+ { name: 'Amon', surname: 'Tobin', birth_date: Date.new(1983,1,1), enrollment_status_code: @enrollment_status },
8
+ { name: '零', surname: '影月', enrollment_status_code: @enrollment_status },
9
+ { name: 'サニー', surname: 'スノー', enrollment_status_code: @enrollment_status }
10
+ ]
11
+
12
+ create_student_with_full_info(@john_doe)
13
+ students.each do |student|
14
+ create_student_with_full_info(student)
15
+ end
16
+
17
+
18
+ say "Creating #{@count[:students]} students ...".yellow
19
+
20
+ batch_create(@count[:students]) do
21
+ create_student_with_full_info
22
+ end
@@ -0,0 +1,130 @@
1
+ # encoding: utf-8
2
+
3
+ syllabuses = [
4
+
5
+ {
6
+ name: 'Introduction to Biology',
7
+ code: 'B01',
8
+ description: 'A general introduction to the world of organisms and how they function',
9
+ credits: 5
10
+ },
11
+
12
+ {
13
+ name: 'Trigonometry',
14
+ code: 'M401',
15
+ description: 'TRIANGLES!',
16
+ credits: 3
17
+ },
18
+
19
+ {
20
+ name: 'Literature',
21
+ code: 'LIT',
22
+ description: 'In this course you will read a series of short stories and essays by stuck up self-proclaimed writers.',
23
+ credits: 1
24
+ },
25
+
26
+ {
27
+ name: 'Introductory Japanese[日本語入門]',
28
+ code: 'NH1',
29
+ description: 'Learn basic moonspeak. This course covers introductions, greetings and basic questions and answers for every day life. This course also covers both sets of kana and some basic kanji.',
30
+ credits: 2
31
+ },
32
+
33
+ {
34
+ name: 'ブルガリア語入門',
35
+ code: 'BG1',
36
+ description: 'ブルガリアで日常生活が出来る様、挨拶や日常に使う質問と答えの仕方が学べます。ブルガリア語に使われるキリル文字の読み書きも出来る様になります。',
37
+ credits: 2
38
+ },
39
+
40
+ {
41
+ name: 'メカトロニクス',
42
+ code: 'MT',
43
+ description: '電子回路と電気機器とメカニカル機械を効率良く合わせてロボットの基礎や様々のデバイスや機械が作れる様になります。',
44
+ credits: 8
45
+ },
46
+
47
+ {
48
+ name: 'Атомна физика',
49
+ code: 'AF1',
50
+ description: 'Сътворете атомна бомба с лекота',
51
+ credits: 8
52
+ },
53
+
54
+ {
55
+ name: 'Нинджи наука',
56
+ code: 'NJ1',
57
+ description: 'Научете разнообразие от нинджа техники.',
58
+ credits: 3
59
+ },
60
+
61
+ {
62
+ name: 'Introduction to Ruby',
63
+ code: 'RB1',
64
+ description: 'Learn the basics of Ruby programming.',
65
+ credits: 3
66
+ },
67
+
68
+ {
69
+ name: 'Ruby Programming',
70
+ code: 'RB2',
71
+ description: 'Leverage your Ruby skills.',
72
+ credits: 3
73
+ },
74
+
75
+ {
76
+ name: 'Ruby Guru',
77
+ code: 'RB3',
78
+ description: 'Became a ruby guru.',
79
+ credits: 3
80
+ },
81
+
82
+ {
83
+ name: 'Introduction to node.js',
84
+ code: 'NJS1',
85
+ description: 'Learn the basics of node.js programming.',
86
+ credits: 3
87
+ },
88
+
89
+ {
90
+ name: 'Node.js Programming',
91
+ code: 'NJS2',
92
+ description: 'Leverage your node.js skills.',
93
+ credits: 3
94
+ },
95
+
96
+ {
97
+ name: 'Node.js Guru',
98
+ code: 'NJS3',
99
+ description: 'Became a node.js guru.',
100
+ credits: 3
101
+ },
102
+
103
+ {
104
+ name: 'Introduction to clojure',
105
+ code: 'CL1',
106
+ description: 'Learn the basics of clojure programming.',
107
+ credits: 3
108
+ },
109
+
110
+ {
111
+ name: 'Clojure Programming',
112
+ code: 'CL2',
113
+ description: 'Leverage your clojure skills.',
114
+ credits: 3
115
+ },
116
+
117
+ {
118
+ name: 'Clojure Guru',
119
+ code: 'CL3',
120
+ description: 'Became a clojure guru.',
121
+ credits: 3
122
+ }
123
+
124
+ ]
125
+
126
+ say "Creating #{syllabuses.size} syllabuses ...".yellow
127
+
128
+ syllabuses.each do |syllabus|
129
+ Gaku::Syllabus.where(syllabus).first_or_create!
130
+ end
@@ -0,0 +1,31 @@
1
+ require 'rake-progressbar'
2
+
3
+ teachers = [
4
+ { name: 'Vassil', surname: 'Kalkov' },
5
+ { name: 'Marta', surname: 'Kostova' },
6
+ { name: 'Georgi', surname: 'Tapalilov'},
7
+ { name: 'Radoslav', surname: 'Georgiev'},
8
+ { name: 'Rei', surname: 'Kagetsuki'}
9
+ ]
10
+
11
+ say 'Creating predefined teachers...'.yellow
12
+
13
+ teachers.each do |teacher|
14
+ Gaku::Teacher.where(teacher).first_or_create!
15
+ end
16
+
17
+
18
+ say "Creating #{@count[:teachers]} teachers...".yellow
19
+
20
+ batch_create(@count[:teachers]) do
21
+ teacher = Gaku::Teacher.where(random_person).first_or_create!
22
+
23
+ teacher.addresses.where(random_address).first_or_create!
24
+ teacher.addresses.where(random_address).first_or_create!
25
+
26
+ teacher.contacts.where(random_mobile_phone).first_or_create!
27
+ teacher.contacts.where(random_home_phone).first_or_create!
28
+ teacher.contacts.where(random_email).first_or_create!
29
+
30
+ teacher.notes.where(random_note).first_or_create!
31
+ end
@@ -0,0 +1,59 @@
1
+ # encoding: utf-8
2
+
3
+ users = [
4
+
5
+ {
6
+ email: 'example@example.com',
7
+ username: 'example',
8
+ password: '123456',
9
+ password_confirmation: '123456'
10
+ },
11
+
12
+ {
13
+ email: 'admin@example.com',
14
+ username: 'admin',
15
+ password: '123456',
16
+ password_confirmation: '123456'
17
+ },
18
+
19
+ {
20
+ email: 'student@example.com',
21
+ username: 'student',
22
+ password: '123456',
23
+ password_confirmation: '123456'
24
+ },
25
+
26
+ {
27
+ email: 'guardian@example.com',
28
+ username: 'guardian',
29
+ password: '123456',
30
+ password_confirmation: '123456'
31
+ }
32
+
33
+ ]
34
+
35
+ users.each do |user|
36
+ Gaku::User.where(username: user[:username]).first_or_create!(email: user[:email],
37
+ password: user[:password],
38
+ password_confirmation: user[:password_confirmation]
39
+ )
40
+ end
41
+
42
+ admin_user = Gaku::User.find_by_username('admin')
43
+ admin_role = Gaku::Role.find_by_name('Admin')
44
+ admin_user.roles << admin_role
45
+
46
+ student_user = Gaku::User.find_by_username('student')
47
+ student_role = Gaku::Role.find_by_name('Student')
48
+ student_user.roles << student_role
49
+
50
+ guardian_user = Gaku::User.find_by_username('guardian')
51
+ guardian_role = Gaku::Role.find_by_name('Guardian')
52
+ guardian_user.roles << guardian_role
53
+
54
+ say "Creating #{@count[:users]} users...".yellow
55
+
56
+ batch_create(@count[:teachers]) do
57
+ Gaku::User.where(username: Faker::Name.first_name, email: Faker::Internet.email).first_or_create( password: '123456', password_confirmation: '123456')
58
+ end
59
+
@@ -0,0 +1,10 @@
1
+ require 'gaku_core'
2
+ require 'ffaker'
3
+ require 'rake-progressbar'
4
+ require 'highline'
5
+
6
+ module GakuSample
7
+ class Engine < Rails::Engine
8
+ engine_name 'gaku_sample'
9
+ end
10
+ end
@@ -0,0 +1,23 @@
1
+ @full_sample_counts = {
2
+ disposals: 100,
3
+ changes: 100,
4
+ students: 500,
5
+ teachers: 80,
6
+ users: 100
7
+ }
8
+
9
+ @normal_sample_counts = {
10
+ disposals: 30,
11
+ changes: 30,
12
+ students: 50,
13
+ teachers: 50,
14
+ users: 50
15
+ }
16
+
17
+ @simple_sample_counts = {
18
+ disposals: 10,
19
+ changes: 10,
20
+ students: 10,
21
+ teachers: 10,
22
+ users: 10
23
+ }
@@ -0,0 +1,108 @@
1
+ @country = Gaku::Country.where( name: '日本',
2
+ iso3: 'JPN',
3
+ iso: 'JP',
4
+ iso_name: 'JAPAN',
5
+ numcode: '392'
6
+ ).first_or_create!
7
+
8
+ @mobile_phone = Gaku::ContactType.where(name: 'Mobile Phone').first_or_create!
9
+ @home_phone = Gaku::ContactType.where(name: 'Home Phone').first_or_create!
10
+ @email = Gaku::ContactType.where(name: 'Email').first_or_create!
11
+ @enrollment_status = Gaku::EnrollmentStatus.where(code: 'admitted').first.try(:code)
12
+ @commute_method_type = Gaku::CommuteMethodType.where(name: 'Superbike').first_or_create!
13
+ @scholarship_status = Gaku::ScholarshipStatus.where(name: 'Charity').first_or_create!
14
+
15
+ @john_doe = {
16
+ name: 'John',
17
+ surname: 'Doe',
18
+ birth_date: Date.new(1983,10,5),
19
+ enrollment_status_code: @enrollment_status
20
+ }
21
+
22
+ def batch_create(count)
23
+ ActiveRecord::Base.transaction do
24
+ bar = RakeProgressbar.new(count)
25
+ count.times do
26
+ bar.inc
27
+ yield
28
+ end
29
+ bar.finished
30
+ end
31
+ end
32
+
33
+ def random_person
34
+ {
35
+ name: Faker::Name.first_name,
36
+ middle_name: Faker::Name.first_name,
37
+ surname: Faker::Name.last_name,
38
+ birth_date: Date.today-rand(1000)
39
+ }
40
+ end
41
+
42
+
43
+ def random_home_phone
44
+ {
45
+ data: Faker::PhoneNumber.phone_number,
46
+ contact_type_id: @home_phone.id
47
+ }
48
+ end
49
+
50
+ def random_mobile_phone
51
+ {
52
+ data: Faker::PhoneNumber.phone_number,
53
+ contact_type_id: @mobile_phone.id
54
+ }
55
+ end
56
+
57
+ def random_email
58
+ {
59
+ data: Faker::Internet.email,
60
+ contact_type_id: @email.id
61
+ }
62
+ end
63
+
64
+ def random_note
65
+ {
66
+ title: Faker::Lorem.word,
67
+ content: Faker::Lorem.sentence
68
+ }
69
+ end
70
+
71
+
72
+ def random_address
73
+ {
74
+ address1: Faker::Address.street_address,
75
+ address2: Faker::Address.street_address,
76
+ title: 'Home address',
77
+ zipcode: '452-0813',
78
+ city: 'Nagoya',
79
+ country: @country
80
+ }
81
+ end
82
+
83
+ def create_student_with_full_info(predefined_student=nil)
84
+ if predefined_student
85
+ student = Gaku::Student.where(predefined_student).first_or_create!
86
+ else
87
+ random_student = random_person.merge(enrollment_status_code: @enrollment_status)
88
+ student = Gaku::Student.where(random_student).first_or_create!
89
+ end
90
+
91
+ student.addresses.where(random_address).first_or_create!
92
+ student.contacts.where(random_email).first_or_create!
93
+ student.contacts.where(random_home_phone).first_or_create!
94
+ student.contacts.where(random_mobile_phone).first_or_create!
95
+ student.notes.where(random_note).first_or_create!
96
+ student.notes.where(random_note).first_or_create!
97
+
98
+ #guardian
99
+ guardian = Gaku::Guardian.where(random_person).first_or_create!
100
+ guardian.addresses.where(random_address).first_or_create!
101
+ guardian.contacts.where(random_email).first_or_create!
102
+ guardian.contacts.where(random_home_phone).first_or_create!
103
+ guardian.contacts.where(random_mobile_phone).first_or_create!
104
+ #guardian.notes.where(random_note).first_or_create!
105
+ #guardian.notes.where(random_note).first_or_create!
106
+
107
+ student.guardians << guardian
108
+ end
@@ -0,0 +1,73 @@
1
+ #require 'ffaker'
2
+ require 'sample_counters'
3
+ require 'benchmark'
4
+
5
+ namespace :db do
6
+ desc 'Loads sample data'
7
+ task :sample do
8
+
9
+ say "Simple mode: #{@simple_sample_counts.to_json}".yellow
10
+ say "Normal mode: #{@normal_sample_counts.to_json}".yellow
11
+ say "Full mode: #{@full_sample_counts.to_json}".yellow
12
+ say "------------------------------------------------------------------------------------------------".green
13
+
14
+ mode = ENV['mode']
15
+ if mode.nil?
16
+ choose do |menu|
17
+ menu.prompt = "Please choose a mode ".yellow
18
+
19
+ menu.choice(:simple) { simple_mode }
20
+ menu.choice(:normal) { normal_mode }
21
+ menu.choice(:full) { full_mode }
22
+ end
23
+ else
24
+ resolve_mode(mode)
25
+ end
26
+
27
+ time = Benchmark.realtime do
28
+ say "Resetting database ..."
29
+ Rake::Task["db:reset"].invoke
30
+
31
+ sample_path = File.join(File.dirname(__FILE__), '..', '..', 'db', 'sample')
32
+ Rake::Task['db:load_dir'].reenable
33
+ Rake::Task['db:load_dir'].invoke(sample_path)
34
+ end
35
+
36
+ say "Time elapsed #{human_time(time)}"
37
+ end
38
+ end
39
+
40
+
41
+ private
42
+
43
+ def human_time(time)
44
+ mm, ss = time.divmod(60)
45
+ say("%d minutes and %d seconds".green % [mm, ss])
46
+ end
47
+
48
+ def simple_mode
49
+ say "Running in simple mode ...".yellow
50
+ @count = @simple_sample_counts
51
+ end
52
+
53
+ def normal_mode
54
+ say "Running in normal mode ...".yellow
55
+ @count = @normal_sample_counts
56
+ end
57
+
58
+ def full_mode
59
+ say "Running in full mode ...".yellow
60
+ @count = @full_sample_counts
61
+ end
62
+
63
+ def resolve_mode(mode)
64
+ if mode == 'full'
65
+ full_mode
66
+ elsif mode == 'normal'
67
+ normal_mode
68
+ elsif mode == 'simple'
69
+ simple_mode
70
+ else
71
+ normal_mode
72
+ end
73
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gaku_sample
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Rei Kagetsuki
8
+ - Vassil Kalkov
9
+ - Georgi Tapalilov
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-10-08 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: gaku_core
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.0.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - '='
27
+ - !ruby/object:Gem::Version
28
+ version: 0.0.1
29
+ - !ruby/object:Gem::Dependency
30
+ name: ffaker
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ description: Just some sample data
44
+ email: info@genshin.org
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - lib/shared_sample_data.rb
50
+ - lib/gaku_sample.rb
51
+ - lib/sample_counters.rb
52
+ - lib/tasks/sample.rake
53
+ - db/sample/gaku/users.rb
54
+ - db/sample/gaku/students.rb
55
+ - db/sample/gaku/grading_widget.rb
56
+ - db/sample/gaku/roles.rb
57
+ - db/sample/gaku/course_groups.rb
58
+ - db/sample/gaku/teachers.rb
59
+ - db/sample/gaku/changes/student_changes.rb
60
+ - db/sample/gaku/disposals/exam_disposals.rb
61
+ - db/sample/gaku/disposals/student_disposals.rb
62
+ - db/sample/gaku/disposals/course_group_disposals.rb
63
+ - db/sample/gaku/disposals/teacher_disposals.rb
64
+ - db/sample/gaku/disposals/attachment_disposals.rb
65
+ - db/sample/gaku/disposals/address_and_contact_disposals.rb
66
+ - db/sample/gaku/images/120x120.jpg
67
+ - db/sample/gaku/class_groups.rb
68
+ - db/sample/gaku/exams.rb
69
+ - db/sample/gaku/courses.rb
70
+ - db/sample/gaku/achievements.rb
71
+ - db/sample/gaku/specialties.rb
72
+ - db/sample/gaku/extracurricular_activities.rb
73
+ - db/sample/gaku/syllabuses.rb
74
+ homepage: http://github.com/Genshin/gaku
75
+ licenses: []
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 2.0.0
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements:
92
+ - postgres
93
+ - redis
94
+ rubyforge_project:
95
+ rubygems_version: 2.0.3
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Sample data for use with GAKU Engine
99
+ test_files: []