salesforce_certification_calculator 0.2.0 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ee895a9e21c058eefc6cb56279c7ec58f700b5dfec8a08d034482ba0d656a04f
4
- data.tar.gz: b988479222226cf9a93513e7eadd5aee75e8dad8db6d6ccdb1c82cd35b55c28a
3
+ metadata.gz: d3e2c79e3592dc37772b3e758787237aee2a59eb61fdf6bb79e69a2922fb409c
4
+ data.tar.gz: f71f648b7227e328e16e914d1285f53242c3b5d35456c1c59971924f6087cf52
5
5
  SHA512:
6
- metadata.gz: d1819b8eed67b8e1dd3b8e957a25155c4a117c009b6476c37723c8e1d97d6af71304b142d12dc847f614b1381859520e6d3f495ca662de1caf048aaf4a1eaa62
7
- data.tar.gz: 5d648caa5592a03f61f42ab341f434d8d69327158186333536780a835ba629d7ba4cb0ce81b903155e521b8324d81fe8d2e701d2de89298a41de264cacc76b39
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. Update your `.zshrc` config file:
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.0.gem`
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.0.gem` may need to become `-0.3.0.gem`).
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
- doc = File.open(exam.file) { |f| Nokogiri::XML(f) }
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
@@ -12,4 +12,4 @@ end
12
12
  desc "Run tests"
13
13
  task default: :test
14
14
 
15
- # --- Ran 103 tests in 0.013676s on 7/28/22 --- OK --- #
15
+ # --- Ran 103 tests in 0.013265s on 7/29/22 --- OK --- #
@@ -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
- # Gets list of all exams in the database, including their names and file paths
4
+ # Creates FileReader object by establishing a base path
5
5
  #
6
- # @example Retrieve Exams
7
- # >> reader = FileReader.new
8
- # >> exams = reader.generate_exams_list
9
- # => [<SalesforceCertificationCalculator::Exam 0x000987>, <SalesforceCertificationCalculator::Exam 0x000988>]
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
- base_path = gems_path + "/" + latest_sfc
27
- files = Dir.glob("data/*xml", base: base_path)
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
- doc = File.open(file) { |f| Nokogiri::XML(f) }
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
- doc = File.open(exam.file) { |f| Nokogiri::XML(f) }
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: salesforce_certification_calculator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jackson Reeves