ttcalc 0.0.1
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 +7 -0
- data/lib/ttcalc.rb +32 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eb041fa9a422faeb8e31a52483cca0aa03d31a46
|
4
|
+
data.tar.gz: 0eac55a4a96a1c7f6a1fc7a3dc71221c27844fa4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de15a9d5ae4b3e17dc36d3ff3f5f508768094364b6053f0d9694c599840b282f36c0c4a2ec6e6b5e2459003ddc9e3c4bd1dfe8f2899537cefd4a67a7e590242a
|
7
|
+
data.tar.gz: 9e458d0095fd52d4df052db04fb71fd89aab8e669358859751c4ff233300e9c15a9053fc322871bf458395a07957defdde1e44f12a34cc5df41907366a9e768b
|
data/lib/ttcalc.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class TTCalc
|
4
|
+
def initialize(input)
|
5
|
+
@input = JSON.parse(input)
|
6
|
+
end
|
7
|
+
|
8
|
+
def summatching(attsum, attmatch)
|
9
|
+
@attsum = attsum
|
10
|
+
@attmatch = attmatch
|
11
|
+
|
12
|
+
attvals = Hash.new
|
13
|
+
@input.each do |i|
|
14
|
+
if attvals[i[@attmatch]]
|
15
|
+
attvals[i[@attmatch]] = attvals[i[@attmatch]]+i[@attsum]
|
16
|
+
else
|
17
|
+
attvals[i[@attmatch]] = i[@attsum]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
outarray = Array.new
|
22
|
+
attvals.each do |k,v|
|
23
|
+
temphash = Hash.new
|
24
|
+
temphash[@attmatch] = k
|
25
|
+
temphash[@attsum] = v
|
26
|
+
outarray.push(temphash)
|
27
|
+
end
|
28
|
+
|
29
|
+
return JSON.pretty_generate(outarray)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ttcalc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- M. C. McGrath
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Calculation functions for Transparency Toolkit.
|
14
|
+
email: shidash@shidash.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/ttcalc.rb
|
20
|
+
homepage: https://github.com/TransparencyToolkit/ttcalc
|
21
|
+
licenses:
|
22
|
+
- GPL
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.0.14
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Calculation functions for Transparency Toolkit
|
44
|
+
test_files: []
|
45
|
+
has_rdoc:
|