salesforce_certification_calculator 0.2.4 → 0.2.5
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 +4 -4
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/lib/salesforce_certification_calculator/exam.rb +1 -0
- data/lib/salesforce_certification_calculator/file_reader.rb +6 -0
- data/lib/salesforce_certification_calculator/u_i.rb +14 -1
- data/lib/salesforce_certification_calculator.rb +2 -0
- data/test/test_u_i.rb +42 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a085ce0eb296c739f492519f11e1e11ed162423632aa115cb1e73aa66eb3c8e6
|
4
|
+
data.tar.gz: 76e04f4e08be8de4708986ec1609a0226d9c75a67cc01718d24d3dc55465c28f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c6b97f0d765f336d447914fc9e870a94646e4a80858e5fbc6442eca0e2210f7fc20aff23e375985fe07d12cd4ab042bc34e050b12a0668ba00df481ae032f1a
|
7
|
+
data.tar.gz: f31d416f959c4aeb42d3d29ebdf966d538aa7805965aecff6840b8a17ced8a9e13771c4ea03ba4bfbb705cb3984eb655f004663e9c41e1e5a2e13569490c5731
|
data/README.md
CHANGED
@@ -66,11 +66,11 @@ If you have trouble downloading the package or just want to play around with the
|
|
66
66
|
1. Fork this repository
|
67
67
|
2. Clone it to your local computer
|
68
68
|
3. From within your local version of the directory, build the module: `gem build salesforce_certification_calculator.gemspec`
|
69
|
-
4. Then install that built module: `gem install ./salesforce_certification_calculator-0.2.
|
69
|
+
4. Then install that built module: `gem install ./salesforce_certification_calculator-0.2.5.gem`
|
70
70
|
5. Open a Ruby environment to use the module: `irb`
|
71
71
|
6. Execute any of the recently installed methods
|
72
72
|
|
73
|
-
You may need to update the specific version of the build as later releases come out (e.g., `-0.2.
|
73
|
+
You may need to update the specific version of the build as later releases come out (e.g., `-0.2.5.gem` may need to become `-0.3.0.gem`).
|
74
74
|
|
75
75
|
## Usage
|
76
76
|
|
@@ -134,7 +134,7 @@ end
|
|
134
134
|
|
135
135
|
## Testing
|
136
136
|
|
137
|
-
This project has
|
137
|
+
This project has 106 automated tests, located in the `test` folder at the root. To run them, execute `rake test`. In order to successfully run these tests, you may need to also install `stringio` and `o_stream_catcher`.
|
138
138
|
|
139
139
|
## Future Goals
|
140
140
|
|
data/Rakefile
CHANGED
@@ -8,18 +8,22 @@ class SalesforceCertificationCalculator::FileReader
|
|
8
8
|
def initialize
|
9
9
|
sfc_gems = []
|
10
10
|
|
11
|
+
# Get full path to where Ruby gems are stored on user's computer, starting at the base
|
11
12
|
gems_path = ENV["HOME"] + "/gems/gems"
|
12
13
|
all_gems = Dir.children(gems_path)
|
13
14
|
|
15
|
+
# Create list of all versions of module installed on user's computer
|
14
16
|
all_gems.each do |gem|
|
15
17
|
if gem.include? "salesforce_certification_calculator"
|
16
18
|
sfc_gems.push(gem)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
22
|
+
# Determine most recent version of module available
|
20
23
|
sfc_gems.sort
|
21
24
|
latest_sfc = sfc_gems[sfc_gems.length - 1]
|
22
25
|
|
26
|
+
# Set path variable for use by the class's methods
|
23
27
|
@base_path = gems_path + "/" + latest_sfc
|
24
28
|
end
|
25
29
|
|
@@ -35,6 +39,7 @@ class SalesforceCertificationCalculator::FileReader
|
|
35
39
|
exams = []
|
36
40
|
files = Dir.glob("data/*xml", base: @base_path)
|
37
41
|
|
42
|
+
# Create list of all exams, including their titles and file paths
|
38
43
|
files.each do |file|
|
39
44
|
exam = SFC::Exam.new
|
40
45
|
file_path = @base_path + "/" + file
|
@@ -65,6 +70,7 @@ class SalesforceCertificationCalculator::FileReader
|
|
65
70
|
names = doc.xpath("//name")
|
66
71
|
weights = doc.xpath("//weight")
|
67
72
|
|
73
|
+
# Add all sections' names and weights to existing exam data
|
68
74
|
(0..names.length-1).each do |i|
|
69
75
|
exam.add_section(names[i].content, weights[i].content.to_i)
|
70
76
|
end
|
@@ -13,6 +13,7 @@ class SalesforceCertificationCalculator::UI
|
|
13
13
|
puts "Do you want to select an exam from a list (enter LIST), or do you want to type in your own details (enter NEW)?"
|
14
14
|
choice = gets.chomp
|
15
15
|
|
16
|
+
# Only return value if user selected one of the two provided options; otherwise, recursively recall function
|
16
17
|
if choice == "LIST" || choice == "NEW"
|
17
18
|
return choice
|
18
19
|
else
|
@@ -33,18 +34,28 @@ class SalesforceCertificationCalculator::UI
|
|
33
34
|
#
|
34
35
|
# @return [Exam] object with name, file, and section details for selected exam
|
35
36
|
def select_specific_exam(exams)
|
37
|
+
exams_length = exams.length
|
38
|
+
|
36
39
|
puts "Your choices are:"
|
37
40
|
|
41
|
+
# List exam options
|
38
42
|
exams.each do |exam|
|
39
43
|
puts "#{exams.find_index(exam) + 1} - #{exam.title}"
|
40
44
|
end
|
41
45
|
|
46
|
+
# Add option to take user back to the LIST or NEW prompt
|
47
|
+
puts "#{exams_length + 1} - NOT LISTED"
|
42
48
|
puts "Which one would you like to select? Enter the number before the exam name:"
|
43
49
|
choice = gets.chomp.to_i
|
44
50
|
|
45
|
-
if choice.between?(1,
|
51
|
+
if choice.between?(1, exams_length)
|
52
|
+
# Only return value if user inputted number within range
|
46
53
|
return exams[choice - 1]
|
54
|
+
elsif choice == exams_length + 1
|
55
|
+
# Allow user to opt out if last option entered
|
56
|
+
select_list_or_new()
|
47
57
|
else
|
58
|
+
# Recursively recall function if invalid input
|
48
59
|
select_specific_exam(exams)
|
49
60
|
end
|
50
61
|
end
|
@@ -65,6 +76,7 @@ class SalesforceCertificationCalculator::UI
|
|
65
76
|
def provide_scores(exam)
|
66
77
|
sections = exam.sections
|
67
78
|
|
79
|
+
# Get scores for each section from the user
|
68
80
|
sections.each do |section|
|
69
81
|
puts "#{section.name} is worth #{section.weight}%"
|
70
82
|
puts "What score did you get on that section? (enter an integer)"
|
@@ -90,6 +102,7 @@ class SalesforceCertificationCalculator::UI
|
|
90
102
|
puts "How many sections does it have?"
|
91
103
|
length = gets.chomp.to_i
|
92
104
|
|
105
|
+
# Get names, weights, and scores for each section of the exam from the user
|
93
106
|
(1..length).each do |i|
|
94
107
|
puts "What is the name of Section #{i}?"
|
95
108
|
name = gets.chomp
|
@@ -66,6 +66,7 @@ class SalesforceCertificationCalculator
|
|
66
66
|
choice = @ui.select_list_or_new
|
67
67
|
|
68
68
|
if choice == "LIST"
|
69
|
+
# Get list of exams, prompt user to select one, then require user to provide their scores for all the exam's sections
|
69
70
|
@exams = @reader.generate_exams_list
|
70
71
|
@exam = @ui.select_specific_exam(@exams)
|
71
72
|
@exam = @reader.extract_initial_exam_data(@exam)
|
@@ -75,6 +76,7 @@ class SalesforceCertificationCalculator
|
|
75
76
|
|
76
77
|
@exam = @ui.provide_scores(@exam)
|
77
78
|
else
|
79
|
+
# Allow user to manually enter all data themselves without the aid of the data already stored in the module's XML files
|
78
80
|
@exam = @ui.provide_all_details_manually
|
79
81
|
end
|
80
82
|
|
data/test/test_u_i.rb
CHANGED
@@ -184,6 +184,20 @@ class UITest < Minitest::Test
|
|
184
184
|
assert_equal 1, result[1].scan("Which one would you like to select").length, "should call select_specific_exam only once if user inputs 2"
|
185
185
|
end
|
186
186
|
|
187
|
+
def test_select_specific_exam_call_list_new
|
188
|
+
result = OStreamCatcher.catch do
|
189
|
+
string_io = StringIO.new
|
190
|
+
string_io.puts "#{@@exams.length + 1}"
|
191
|
+
string_io.puts "NEW"
|
192
|
+
string_io.rewind
|
193
|
+
$stdin = string_io
|
194
|
+
@@ui.select_specific_exam(@@exams)
|
195
|
+
$stdin = STDIN
|
196
|
+
end
|
197
|
+
|
198
|
+
assert_equal 1, result[1].scan("Do you want to select an exam from a list (enter LIST), or do you want to type in your own details (enter NEW)?").length, "should call select_list_or_new if user enters NOT LISTED option"
|
199
|
+
end
|
200
|
+
|
187
201
|
def test_select_specific_exam_recursion_greater
|
188
202
|
result = OStreamCatcher.catch do
|
189
203
|
string_io = StringIO.new
|
@@ -212,6 +226,34 @@ class UITest < Minitest::Test
|
|
212
226
|
assert_operator result[1].scan("Which one would you like to select").length, :>, 1, "should call select_specific_exam more than once if user inputs 0"
|
213
227
|
end
|
214
228
|
|
229
|
+
def test_select_specific_exam_recursion_letter
|
230
|
+
result = OStreamCatcher.catch do
|
231
|
+
string_io = StringIO.new
|
232
|
+
string_io.puts "a"
|
233
|
+
string_io.puts "1"
|
234
|
+
string_io.rewind
|
235
|
+
$stdin = string_io
|
236
|
+
@@ui.select_specific_exam(@@exams)
|
237
|
+
$stdin = STDIN
|
238
|
+
end
|
239
|
+
|
240
|
+
assert_operator result[1].scan("Which one would you like to select").length, :>, 1, "should call select_specific_exam more than once if user inputs letter"
|
241
|
+
end
|
242
|
+
|
243
|
+
def test_select_specific_exam_recursion_title
|
244
|
+
result = OStreamCatcher.catch do
|
245
|
+
string_io = StringIO.new
|
246
|
+
string_io.puts "Advanced Administrator"
|
247
|
+
string_io.puts "1"
|
248
|
+
string_io.rewind
|
249
|
+
$stdin = string_io
|
250
|
+
@@ui.select_specific_exam(@@exams)
|
251
|
+
$stdin = STDIN
|
252
|
+
end
|
253
|
+
|
254
|
+
assert_operator result[1].scan("Which one would you like to select").length, :>, 1, "should call select_specific_exam more than once if user inputs title of exam instead of number"
|
255
|
+
end
|
256
|
+
|
215
257
|
def test_provide_scores_returns_exam
|
216
258
|
result = {}
|
217
259
|
|