salesforce_certification_calculator 0.2.0 → 0.2.3
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 +15 -9
- data/Rakefile +1 -1
- data/lib/salesforce_certification_calculator/exam.rb +1 -1
- data/lib/salesforce_certification_calculator/file_reader.rb +25 -14
- 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: d3e2c79e3592dc37772b3e758787237aee2a59eb61fdf6bb79e69a2922fb409c
|
|
4
|
+
data.tar.gz: f71f648b7227e328e16e914d1285f53242c3b5d35456c1c59971924f6087cf52
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75e7530e1274da33a63de6705ae6d024cd8aa736266b74dcd4c01623303fbd4ce2bfdcab96f67423c3451265d84b6cfe03473d3ac867e29148631291b554eaa3
|
|
7
|
+
data.tar.gz: 200ce30ad30d7841a0fa37f03f86b2ca1d34b3391e6d75fed0604c38bcac88bd77c680ca1268dd567a275889753fad7e3f35b807d9f4b7b8b67f2fcf10eb9814
|
data/README.md
CHANGED
|
@@ -39,16 +39,19 @@ I've taken a few Salesforce certification exams in my day, and I was always anno
|
|
|
39
39
|
### Set Up Environment
|
|
40
40
|
|
|
41
41
|
1. Install `rbenv` via Homebrew: `brew install rbenv`
|
|
42
|
-
2.
|
|
43
|
-
> `export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.1.0/bin:$PATH"`
|
|
44
|
-
> `eval "$(rbenv init - zsh)"`
|
|
45
|
-
> `export PATH=$HOME/.rbenv/shims:$PATH`
|
|
46
|
-
> `export GEM_HOME=$HOME/gems`
|
|
47
|
-
> `export PATH=$HOME/gems/bin:$PATH`
|
|
42
|
+
2. Add the code block below these steps to your `.zshrc` config file
|
|
48
43
|
3. Install latest version of Ruby via the `rbenv` package: `rbenv install 3.1.2`
|
|
49
44
|
4. Set global version of Ruby via the `rbenv` package: `rbenv global 3.1.2`
|
|
50
45
|
5. Fix `racc` version: `gem pristine racc --version 1.6.0`
|
|
51
46
|
|
|
47
|
+
```bash
|
|
48
|
+
export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.1.0/bin:$PATH"
|
|
49
|
+
eval "$(rbenv init - zsh)"
|
|
50
|
+
export PATH=$HOME/.rbenv/shims:$PATH
|
|
51
|
+
export GEM_HOME=$HOME/gems
|
|
52
|
+
export PATH=$HOME/gems/bin:$PATH
|
|
53
|
+
```
|
|
54
|
+
|
|
52
55
|
### Download Package
|
|
53
56
|
|
|
54
57
|
```
|
|
@@ -62,11 +65,11 @@ If you have trouble downloading the package or just want to play around with the
|
|
|
62
65
|
1. Fork this repository
|
|
63
66
|
2. Clone it to your local computer
|
|
64
67
|
3. From within your local version of the directory, build the module: `gem build salesforce_certification_calculator.gemspec`
|
|
65
|
-
4. Then install that built module: `gem install ./salesforce_certification_calculator-0.2.
|
|
68
|
+
4. Then install that built module: `gem install ./salesforce_certification_calculator-0.2.3.gem`
|
|
66
69
|
5. Open a Ruby environment to use the module: `irb`
|
|
67
70
|
6. Execute any of the recently installed methods
|
|
68
71
|
|
|
69
|
-
You may need to update the specific version of the build as later releases come out (e.g., `-0.2.
|
|
72
|
+
You may need to update the specific version of the build as later releases come out (e.g., `-0.2.3.gem` may need to become `-0.3.0.gem`).
|
|
70
73
|
|
|
71
74
|
## Usage
|
|
72
75
|
|
|
@@ -96,6 +99,8 @@ def calculate_total
|
|
|
96
99
|
|
|
97
100
|
if summed_weights != 100
|
|
98
101
|
@total = "CANNOT CALCULATE"
|
|
102
|
+
else
|
|
103
|
+
@total = @total.round(2)
|
|
99
104
|
end
|
|
100
105
|
end
|
|
101
106
|
```
|
|
@@ -103,7 +108,8 @@ end
|
|
|
103
108
|
**Helper function to pull data stored in a reference XML file**
|
|
104
109
|
```ruby
|
|
105
110
|
def extract_initial_exam_data(exam)
|
|
106
|
-
|
|
111
|
+
file_path = @base_path + "/" + exam.file
|
|
112
|
+
doc = File.open(file_path) { |f| Nokogiri::XML(f) }
|
|
107
113
|
names = doc.xpath("//name")
|
|
108
114
|
weights = doc.xpath("//weight")
|
|
109
115
|
|
data/Rakefile
CHANGED
|
@@ -53,7 +53,7 @@ class SalesforceCertificationCalculator::Exam
|
|
|
53
53
|
@total += section.weight * section.score / 100.0
|
|
54
54
|
end
|
|
55
55
|
|
|
56
|
-
# Sets total to error message when sum of sections' weights is not 100
|
|
56
|
+
# Sets total to error message when sum of sections' weights is not 100; otherwise, rounds answer
|
|
57
57
|
if summed_weights != 100
|
|
58
58
|
@total = "CANNOT CALCULATE"
|
|
59
59
|
else
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
class SalesforceCertificationCalculator::FileReader
|
|
2
2
|
SFC = SalesforceCertificationCalculator
|
|
3
3
|
|
|
4
|
-
#
|
|
4
|
+
# Creates FileReader object by establishing a base path
|
|
5
5
|
#
|
|
6
|
-
# @example
|
|
7
|
-
# >>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# @return [Array] collection of Exam objects
|
|
12
|
-
def generate_exams_list
|
|
13
|
-
exams = []
|
|
6
|
+
# @example Create FileReader Object
|
|
7
|
+
# >> fr = FileReader.new
|
|
8
|
+
def initialize
|
|
9
|
+
sfc_gems = []
|
|
10
|
+
|
|
14
11
|
gems_path = ENV["HOME"] + "/gems/gems"
|
|
15
12
|
all_gems = Dir.children(gems_path)
|
|
16
|
-
sfc_gems = []
|
|
17
13
|
|
|
18
14
|
all_gems.each do |gem|
|
|
19
15
|
if gem.include? "salesforce_certification_calculator"
|
|
@@ -23,12 +19,26 @@ class SalesforceCertificationCalculator::FileReader
|
|
|
23
19
|
|
|
24
20
|
sfc_gems.sort
|
|
25
21
|
latest_sfc = sfc_gems[sfc_gems.length - 1]
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
|
|
23
|
+
@base_path = gems_path + "/" + latest_sfc
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Gets list of all exams in the database, including their names and file paths
|
|
27
|
+
#
|
|
28
|
+
# @example Retrieve Exams
|
|
29
|
+
# >> reader = FileReader.new
|
|
30
|
+
# >> exams = reader.generate_exams_list
|
|
31
|
+
# => [<SalesforceCertificationCalculator::Exam 0x000987>, <SalesforceCertificationCalculator::Exam 0x000988>]
|
|
32
|
+
#
|
|
33
|
+
# @return [Array] collection of Exam objects
|
|
34
|
+
def generate_exams_list
|
|
35
|
+
exams = []
|
|
36
|
+
files = Dir.glob("data/*xml", base: @base_path)
|
|
28
37
|
|
|
29
38
|
files.each do |file|
|
|
30
39
|
exam = SFC::Exam.new
|
|
31
|
-
|
|
40
|
+
file_path = @base_path + "/" + file
|
|
41
|
+
doc = File.open(file_path) { |f| Nokogiri::XML(f) }
|
|
32
42
|
title = doc.at_xpath("//title")
|
|
33
43
|
exam.title = title.content
|
|
34
44
|
exam.file = file
|
|
@@ -50,7 +60,8 @@ class SalesforceCertificationCalculator::FileReader
|
|
|
50
60
|
#
|
|
51
61
|
# @return [Exam] object with not only name and file, but also all sections, with their names and weights
|
|
52
62
|
def extract_initial_exam_data(exam)
|
|
53
|
-
|
|
63
|
+
file_path = @base_path + "/" + exam.file
|
|
64
|
+
doc = File.open(file_path) { |f| Nokogiri::XML(f) }
|
|
54
65
|
names = doc.xpath("//name")
|
|
55
66
|
weights = doc.xpath("//weight")
|
|
56
67
|
|