salesforce_certification_calculator 0.2.1 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -9
- data/Rakefile +1 -1
- data/lib/salesforce_certification_calculator/exam.rb +1 -1
- data/lib/salesforce_certification_calculator/file_reader.rb +24 -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: c6cd3c2dd6799ce7b8249d9651553b869544681b35622118147642aefe6eaa19
|
4
|
+
data.tar.gz: 98bddd3304510dcfd2b47b844d9a8f4385297a3c0c2fd214c826dbcdf632a251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 433f1b4df8363609831ce77597db9a052fea4c3303ab840bee07376e35334b384ab9cb142c745fd02057f1a30bf118402c4a4b28dc52a69341e40794f06c70d8
|
7
|
+
data.tar.gz: 3f588ef7f3f53d504f837a9539260e4f106554f00fcc01d9f75100010aa75cf7732e54eef5b80d19231274221380551baa0a9cee6c9357fac0d8dda70be1f5b6
|
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
|
|
@@ -39,16 +40,19 @@ I've taken a few Salesforce certification exams in my day, and I was always anno
|
|
39
40
|
### Set Up Environment
|
40
41
|
|
41
42
|
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`
|
43
|
+
2. Add the code block below these steps to your `.zshrc` config file
|
48
44
|
3. Install latest version of Ruby via the `rbenv` package: `rbenv install 3.1.2`
|
49
45
|
4. Set global version of Ruby via the `rbenv` package: `rbenv global 3.1.2`
|
50
46
|
5. Fix `racc` version: `gem pristine racc --version 1.6.0`
|
51
47
|
|
48
|
+
```bash
|
49
|
+
export PATH="/usr/local/opt/ruby/bin:/usr/local/lib/ruby/gems/3.1.0/bin:$PATH"
|
50
|
+
eval "$(rbenv init - zsh)"
|
51
|
+
export PATH=$HOME/.rbenv/shims:$PATH
|
52
|
+
export GEM_HOME=$HOME/gems
|
53
|
+
export PATH=$HOME/gems/bin:$PATH
|
54
|
+
```
|
55
|
+
|
52
56
|
### Download Package
|
53
57
|
|
54
58
|
```
|
@@ -62,14 +66,16 @@ If you have trouble downloading the package or just want to play around with the
|
|
62
66
|
1. Fork this repository
|
63
67
|
2. Clone it to your local computer
|
64
68
|
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.
|
69
|
+
4. Then install that built module: `gem install ./salesforce_certification_calculator-0.2.4.gem`
|
66
70
|
5. Open a Ruby environment to use the module: `irb`
|
67
71
|
6. Execute any of the recently installed methods
|
68
72
|
|
69
|
-
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.4.gem` may need to become `-0.3.0.gem`).
|
70
74
|
|
71
75
|
## Usage
|
72
76
|
|
77
|
+
### Module
|
78
|
+
|
73
79
|
1. Open a Ruby environment to use the module: `irb`
|
74
80
|
2. Require the package: `require 'salesforce_certification_calculator'`
|
75
81
|
3. Create a new calculator to use: `calculator = SalesforceCertificationCalculator.new`
|
@@ -78,6 +84,14 @@ You may need to update the specific version of the build as later releases come
|
|
78
84
|
|
79
85
|
Of course, you may use any of the other methods provided by the package, but `determine_percentage_manually` is the core method.
|
80
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
|
+
|
81
95
|
## Documentation
|
82
96
|
|
83
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.
|
@@ -96,6 +110,8 @@ def calculate_total
|
|
96
110
|
|
97
111
|
if summed_weights != 100
|
98
112
|
@total = "CANNOT CALCULATE"
|
113
|
+
else
|
114
|
+
@total = @total.round(2)
|
99
115
|
end
|
100
116
|
end
|
101
117
|
```
|
@@ -103,7 +119,8 @@ end
|
|
103
119
|
**Helper function to pull data stored in a reference XML file**
|
104
120
|
```ruby
|
105
121
|
def extract_initial_exam_data(exam)
|
106
|
-
|
122
|
+
file_path = @base_path + "/" + exam.file
|
123
|
+
doc = File.open(file_path) { |f| Nokogiri::XML(f) }
|
107
124
|
names = doc.xpath("//name")
|
108
125
|
weights = doc.xpath("//weight")
|
109
126
|
|
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,25 @@ 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
|
-
file_path = base_path + "/" + file
|
40
|
+
file_path = @base_path + "/" + file
|
32
41
|
doc = File.open(file_path) { |f| Nokogiri::XML(f) }
|
33
42
|
title = doc.at_xpath("//title")
|
34
43
|
exam.title = title.content
|
@@ -51,7 +60,8 @@ class SalesforceCertificationCalculator::FileReader
|
|
51
60
|
#
|
52
61
|
# @return [Exam] object with not only name and file, but also all sections, with their names and weights
|
53
62
|
def extract_initial_exam_data(exam)
|
54
|
-
|
63
|
+
file_path = @base_path + "/" + exam.file
|
64
|
+
doc = File.open(file_path) { |f| Nokogiri::XML(f) }
|
55
65
|
names = doc.xpath("//name")
|
56
66
|
weights = doc.xpath("//weight")
|
57
67
|
|