salesforce_certification_calculator 0.2.3 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -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 +11 -5
- data/test/test_salesforce_certification_calculator.rb +22 -0
- data/test/test_u_i.rb +50 -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: 2b029eea93b1b6f56977e85781962c822e0bee773d870460bf1c836a7dca92ec
|
4
|
+
data.tar.gz: fb84076ace1358dfc93df233953938db8f9b86d42c8ac4fec6ef3c287a89251c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 427d35fadd423b18a3a3037cd6d10c9ea6ff6a869aec934b1767c6a2d256ea5a3226d9831b97538e2582db4a0ad65d26fba46d7e73a12b7aba80394edcd98689
|
7
|
+
data.tar.gz: 5aadbee6d26c7600831e6d81781d1ec764610708b251b7451a584d73116d82bd382b87ca9cde8be554c4ea60a8a52714d5c90e6156aa092132ed2a0aadd813a9
|
data/README.md
CHANGED
@@ -28,6 +28,7 @@ I've taken a few Salesforce certification exams in my day, and I was always anno
|
|
28
28
|
- File reading functionality
|
29
29
|
- User interface for the CLI to provide prompts to walk user through the input process
|
30
30
|
- Methods for calculating the cumulative total and for walking the user through all stages of data collection
|
31
|
+
- Executable to allow user to run the module's core functionality with a simple command in the CLI instead of needing to go into a Ruby shell
|
31
32
|
|
32
33
|
## Requirements
|
33
34
|
|
@@ -65,14 +66,16 @@ If you have trouble downloading the package or just want to play around with the
|
|
65
66
|
1. Fork this repository
|
66
67
|
2. Clone it to your local computer
|
67
68
|
3. From within your local version of the directory, build the module: `gem build salesforce_certification_calculator.gemspec`
|
68
|
-
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.6.gem`
|
69
70
|
5. Open a Ruby environment to use the module: `irb`
|
70
71
|
6. Execute any of the recently installed methods
|
71
72
|
|
72
|
-
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.6.gem` may need to become `-0.3.0.gem`).
|
73
74
|
|
74
75
|
## Usage
|
75
76
|
|
77
|
+
### Module
|
78
|
+
|
76
79
|
1. Open a Ruby environment to use the module: `irb`
|
77
80
|
2. Require the package: `require 'salesforce_certification_calculator'`
|
78
81
|
3. Create a new calculator to use: `calculator = SalesforceCertificationCalculator.new`
|
@@ -81,6 +84,14 @@ You may need to update the specific version of the build as later releases come
|
|
81
84
|
|
82
85
|
Of course, you may use any of the other methods provided by the package, but `determine_percentage_manually` is the core method.
|
83
86
|
|
87
|
+
### Executable
|
88
|
+
|
89
|
+
This package also contains an executable, so you can run its core functionality (the above `determine_percentage_manually` method) directly from the CLI without needing to enter a Ruby shell:
|
90
|
+
|
91
|
+
```
|
92
|
+
salesforce_certification_calculator
|
93
|
+
```
|
94
|
+
|
84
95
|
## Documentation
|
85
96
|
|
86
97
|
This project uses **YARD** for documentation generation. To view the published form, see the [documentation on the RubyDoc site](https://www.rubydoc.info/gems/salesforce_certification_calculator/). To view the docs locally, go to the `doc` folder. To generate the docs yourself, execute `rake yard` in the CLI from the root of your local copy of the project.
|
@@ -123,7 +134,7 @@ end
|
|
123
134
|
|
124
135
|
## Testing
|
125
136
|
|
126
|
-
This project has
|
137
|
+
This project has 107 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`.
|
127
138
|
|
128
139
|
## Future Goals
|
129
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 let user enter details manually if exam not listed
|
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
|
+
# Enter details manually if exam not included in list
|
56
|
+
provide_all_details_manually()
|
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,15 +66,21 @@ 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
|
-
@exam = @reader.extract_initial_exam_data(@exam)
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
# Only proceed if user did not end up entering data manually after not finding their exam listed
|
74
|
+
if @exam.sections.length == 0
|
75
|
+
@exam = @reader.extract_initial_exam_data(@exam)
|
76
|
+
|
77
|
+
puts "You selected: #{@exam.title}"
|
78
|
+
puts "Enter your scores for each of the exam's #{@exam.sections.length} sections in the order you are prompted"
|
79
|
+
|
80
|
+
@exam = @ui.provide_scores(@exam)
|
81
|
+
end
|
77
82
|
else
|
83
|
+
# Allow user to manually enter all data themselves without the aid of the data already stored in the module's XML files
|
78
84
|
@exam = @ui.provide_all_details_manually
|
79
85
|
end
|
80
86
|
|
@@ -186,4 +186,26 @@ class SalesforceTest < Minitest::Test
|
|
186
186
|
|
187
187
|
assert_equal prompts, result[1].scan("?").length, "should prompt user for input 3 more than 3 times the number of sections in exam when call determine_percentage_manually and NEW selected"
|
188
188
|
end
|
189
|
+
|
190
|
+
def test_determine_percentage_manually_handles_not_listed_option
|
191
|
+
calculator = SFC.new
|
192
|
+
calculator.generate_exams_list
|
193
|
+
|
194
|
+
result = OStreamCatcher.catch do
|
195
|
+
string_io = StringIO.new
|
196
|
+
string_io.puts "LIST"
|
197
|
+
string_io.puts "#{calculator.exams.length + 1}"
|
198
|
+
string_io.puts "My Test"
|
199
|
+
string_io.puts "1"
|
200
|
+
string_io.puts "Section 1"
|
201
|
+
string_io.puts "100"
|
202
|
+
string_io.puts "70"
|
203
|
+
string_io.rewind
|
204
|
+
$stdin = string_io
|
205
|
+
result = calculator.determine_percentage_manually
|
206
|
+
$stdin = STDIN
|
207
|
+
end
|
208
|
+
|
209
|
+
assert_equal 1, result[1].scan("What is the title of this exam?").length, "should prompt user for title of new test if user selects NOT LISTED after initially selecting LIST"
|
210
|
+
end
|
189
211
|
end
|
data/test/test_u_i.rb
CHANGED
@@ -184,6 +184,28 @@ 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_provide_manually
|
188
|
+
result = OStreamCatcher.catch do
|
189
|
+
string_io = StringIO.new
|
190
|
+
string_io.puts "#{@@exams.length + 1}"
|
191
|
+
string_io.puts "My Test"
|
192
|
+
string_io.puts "4"
|
193
|
+
|
194
|
+
(1..4).each do |i|
|
195
|
+
string_io.puts "Section #{i}"
|
196
|
+
string_io.puts "25"
|
197
|
+
string_io.puts "80"
|
198
|
+
end
|
199
|
+
|
200
|
+
string_io.rewind
|
201
|
+
$stdin = string_io
|
202
|
+
@@ui.select_specific_exam(@@exams)
|
203
|
+
$stdin = STDIN
|
204
|
+
end
|
205
|
+
|
206
|
+
assert_equal 1, result[1].scan("What is the title of this exam?").length, "should call provide_all_details_manually if user enters NOT LISTED option"
|
207
|
+
end
|
208
|
+
|
187
209
|
def test_select_specific_exam_recursion_greater
|
188
210
|
result = OStreamCatcher.catch do
|
189
211
|
string_io = StringIO.new
|
@@ -212,6 +234,34 @@ class UITest < Minitest::Test
|
|
212
234
|
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
235
|
end
|
214
236
|
|
237
|
+
def test_select_specific_exam_recursion_letter
|
238
|
+
result = OStreamCatcher.catch do
|
239
|
+
string_io = StringIO.new
|
240
|
+
string_io.puts "a"
|
241
|
+
string_io.puts "1"
|
242
|
+
string_io.rewind
|
243
|
+
$stdin = string_io
|
244
|
+
@@ui.select_specific_exam(@@exams)
|
245
|
+
$stdin = STDIN
|
246
|
+
end
|
247
|
+
|
248
|
+
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"
|
249
|
+
end
|
250
|
+
|
251
|
+
def test_select_specific_exam_recursion_title
|
252
|
+
result = OStreamCatcher.catch do
|
253
|
+
string_io = StringIO.new
|
254
|
+
string_io.puts "Advanced Administrator"
|
255
|
+
string_io.puts "1"
|
256
|
+
string_io.rewind
|
257
|
+
$stdin = string_io
|
258
|
+
@@ui.select_specific_exam(@@exams)
|
259
|
+
$stdin = STDIN
|
260
|
+
end
|
261
|
+
|
262
|
+
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"
|
263
|
+
end
|
264
|
+
|
215
265
|
def test_provide_scores_returns_exam
|
216
266
|
result = {}
|
217
267
|
|