was 0.3.0 → 0.5.0

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: 02d43144047e0f7e1da7df05778d6e1b075314ca447ce1f3440c65f38d65f121
4
- data.tar.gz: 3a858c1928e5408b9134ce98f9471677fe82ea89fa9d6df32ce5c541b172da6e
3
+ metadata.gz: 8022ee48dc263f90467dd4b9eb9fe4c2125d3a5f4ca14acca80abaa149f53e14
4
+ data.tar.gz: cda95f6711c8e87b234582a6a0969427824af9c4cbb6f74146b10185bdd4bfb6
5
5
  SHA512:
6
- metadata.gz: 5b18c6c1dd741eeb28df70a71a1a25f3c41cd4d7b01372115087c50c6b8f85fa748cced6d33b5792aabf960801b6fd86d145d89535b7b59d954a188125e608f6
7
- data.tar.gz: dff3ba39633f5baf30fd853da49fb09ed3ab56e586a6e3d528859c723e92ed1dabf197cb50c897499f4112141dbfd136bb584a276893f8cd283da0f68e22b4da
6
+ metadata.gz: 1693a283d769e0d4b2c96f42c154b39c5c9c8c3bf426befc73e81c938d163ae45ae74385719792966990dfe8f4a5f908915ec06876d003664feafd85e6c9bd89
7
+ data.tar.gz: 12cfc53b40541711c802191e428fabe75cb93b3f648255f181f6b378f05750441843829cab4264ad5dfae765d82f7a7f211b8c5b0189abc8fcce40978e2603d7
data/README.md CHANGED
@@ -25,8 +25,8 @@ require "was"
25
25
  class ReportScore < WAS::Score
26
26
  maximum_score 1000
27
27
 
28
- with "ExamScore", weight: 0.75
29
- with "PracticalScore", weight: 0.25
28
+ with :exam, "ExamScore", weight: 0.75
29
+ with :practical "PracticalScore", weight: 0.25
30
30
  end
31
31
 
32
32
  class ExamScore < WAS::Score
@@ -68,8 +68,8 @@ Omitting the `maximum_score` will return a composed percentage represented as a
68
68
  ```ruby
69
69
  # report_score.rb
70
70
  class ReportScore < WAS::Score
71
- with "ExamScore", weight: 0.75
72
- with "PracticalScore", weight: 0.25
71
+ with :exam, "ExamScore", weight: 0.75
72
+ with :practical "PracticalScore", weight: 0.25
73
73
  end
74
74
  ```
75
75
 
data/lib/was/score.rb CHANGED
@@ -10,21 +10,21 @@ module WAS
10
10
  @maximum_score || 1
11
11
  end
12
12
 
13
- def self.with(klass, weight: 0)
14
- klasses.merge!(klass => weight)
13
+ def self.with(name, class_name: klass, weight: 0)
14
+ scorers.merge!(name => { class_name: class_name, weight: weight })
15
15
  end
16
16
 
17
- def self.klasses
18
- @klasses ||= {}
17
+ def self.scorers
18
+ @scorers ||= {}
19
19
  end
20
20
 
21
21
  def self.weights
22
22
  {}.tap do |hash|
23
- klasses.each do |klass, weight|
24
- hash[klass_name_symbol(klass)] = { weight: weight }
25
- if Object.const_get(klass).klasses.length > 0
26
- hash[klass_name_symbol(klass)].merge!(
27
- with: Object.const_get(klass).weights
23
+ scorers.each do |name, scorer|
24
+ hash[name] = { weight: scorer[:weight] }
25
+ if Object.const_get(scorer[:class_name]).scorers.length > 0
26
+ hash[name].merge!(
27
+ with: Object.const_get(scorer[:class_name]).weights
28
28
  )
29
29
  end
30
30
  end
@@ -40,9 +40,9 @@ module WAS
40
40
  end
41
41
 
42
42
  def calculation
43
- self.class.klasses.sum do |klass, weight|
44
- score = Object.const_get(klass).new(input[self.class.klass_name_symbol(klass)]).calculate
45
- score * weight
43
+ self.class.scorers.sum do |name, scorer|
44
+ score = Object.const_get(scorer[:class_name]).new(input[name.to_sym]).calculate
45
+ score * scorer[:weight]
46
46
  end * self.class.max_score
47
47
  end
48
48
 
data/lib/was/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WAS
4
- VERSION = "0.3.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/was.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "WAS/version"
4
- require_relative "WAS/score"
3
+ require_relative "was/version"
4
+ require_relative "was/score"
5
5
 
6
6
  module WAS
7
7
  class Error < StandardError; end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: was
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Connell