grader-utils 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/grader-utils.rb +45 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b898a8c05ee927cb97c2ef0fbe5d093615363597
|
4
|
+
data.tar.gz: 3d74f813c453f8318bd5b5309de0064830db8df8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e34df510bcb7b7d726b1edc1e84f7378663ab97c336fa284e0235ddff10d7a85d2fcba191be179c42203e4efedae07eb15f90d5a6eeb632c0f52cc385514b6de
|
7
|
+
data.tar.gz: a90e5028c17a253c27403dd6239bf0057f69dc1c0d6c11975e53c6e840e4b6555dd4d082bb8d36911d5e0f20a9d3c606c6baee5e6a99417ced68e2f8c7de6800
|
data/lib/grader-utils.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module GraderUtils
|
4
|
+
def self.parse_number(input)
|
5
|
+
input = input.to_s.strip
|
6
|
+
|
7
|
+
return nil unless input =~ /\A\-?\d*(?:\.\d*)?\z/
|
8
|
+
|
9
|
+
input.to_f
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.parse_boolean(input)
|
13
|
+
input = parse_string(input).downcase
|
14
|
+
if input == "true"
|
15
|
+
true
|
16
|
+
elsif input == "false"
|
17
|
+
false
|
18
|
+
else
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.parse_string(input)
|
24
|
+
input = input.to_s.strip
|
25
|
+
|
26
|
+
if input[0] == "'" && input[-1] == "'"
|
27
|
+
input[0] = input[-1] = '"'
|
28
|
+
JSON.parse("[#{input}]")[0]
|
29
|
+
elsif input[0] == '"' && input[-1] == '"'
|
30
|
+
JSON.parse("[#{input}]")[0]
|
31
|
+
else
|
32
|
+
input
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.parse_array(input)
|
37
|
+
input = input.to_s.strip
|
38
|
+
|
39
|
+
if input[0] == "[" && input[-1] == "]"
|
40
|
+
input = input[1..-2]
|
41
|
+
end
|
42
|
+
|
43
|
+
input.split(',').map(&:strip)
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: grader-utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yihang Ho
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email: hoyihang5@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/grader-utils.rb
|
20
|
+
homepage:
|
21
|
+
licenses:
|
22
|
+
- MIT
|
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.2.2
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Collection of common utilities for SimpleCMS graders.
|
44
|
+
test_files: []
|
45
|
+
has_rdoc:
|