kxi 1.0.1 → 1.0.2
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 +4 -4
- data/lib/kxi.rb +44 -39
- data/lib/kxi/application/config.rb +177 -177
- data/lib/kxi/application/config_reader.rb +16 -16
- data/lib/kxi/application/event.rb +35 -35
- data/lib/kxi/application/logger.rb +155 -155
- data/lib/kxi/application/version.rb +106 -74
- data/lib/kxi/application/version_expression.rb +94 -69
- data/lib/kxi/application/workspace.rb +105 -0
- data/lib/kxi/cli/anonymous_argument.rb +50 -50
- data/lib/kxi/cli/argument.rb +56 -56
- data/lib/kxi/cli/argument_values.rb +83 -83
- data/lib/kxi/cli/explicit_argument.rb +38 -38
- data/lib/kxi/cli/flag_argument.rb +15 -15
- data/lib/kxi/cli/named_argument.rb +59 -59
- data/lib/kxi/cli/property_list.rb +57 -48
- data/lib/kxi/cli/table.rb +82 -62
- data/lib/kxi/cli/verb.rb +282 -280
- data/lib/kxi/collections/array_collection.rb +106 -106
- data/lib/kxi/collections/enumerable.rb +527 -527
- data/lib/kxi/collections/enumerator.rb +31 -31
- data/lib/kxi/collections/hash_collection.rb +100 -100
- data/lib/kxi/collections/protected_collection.rb +20 -19
- data/lib/kxi/exceptions/abstract_exception.rb +34 -34
- data/lib/kxi/exceptions/argument_exception.rb +21 -21
- data/lib/kxi/exceptions/collection_exception.rb +13 -13
- data/lib/kxi/exceptions/configuration_exception.rb +36 -25
- data/lib/kxi/exceptions/dimension_mismatch_exception.rb +29 -0
- data/lib/kxi/exceptions/invalid_type_exception.rb +32 -32
- data/lib/kxi/exceptions/no_argument_exception.rb +20 -20
- data/lib/kxi/exceptions/not_implemented_exception.rb +12 -12
- data/lib/kxi/exceptions/out_of_range_exception.rb +43 -43
- data/lib/kxi/exceptions/parse_exception.rb +28 -20
- data/lib/kxi/exceptions/verb_expected_exception.rb +20 -20
- data/lib/kxi/exceptions/workspace_collision_exception.rb +21 -0
- data/lib/kxi/math/math.rb +45 -0
- data/lib/kxi/math/matrix.rb +303 -0
- data/lib/kxi/math/polynomial.rb +141 -101
- data/lib/kxi/math/vector.rb +181 -0
- data/lib/kxi/platform.rb +103 -57
- data/lib/kxi/reflection/stack_frame.rb +80 -80
- data/lib/kxi/version.rb +4 -4
- metadata +8 -3
- data/lib/kxi/exceptions/invalid_operation_exception.rb +0 -11
@@ -1,32 +1,32 @@
|
|
1
|
-
# Created by Matyáš Pokorný on 2017-12-28.
|
2
|
-
|
3
|
-
module KXI
|
4
|
-
module Collections
|
5
|
-
# Allows iteration over a collection
|
6
|
-
# @abstract
|
7
|
-
class Enumerator
|
8
|
-
# Selects first item in collection
|
9
|
-
# @return [Bool] True if collection contains elements; otherwise false
|
10
|
-
# @abstract
|
11
|
-
def rewind
|
12
|
-
raise(KXI::Exceptions::AbstractException.new(Enumerator))
|
13
|
-
end
|
14
|
-
|
15
|
-
# Advances enumerator to next item
|
16
|
-
# @return [Bool] True if item is available; false otherwise
|
17
|
-
# @raise [KXI::Exceptions::AbstractException] When method is not implemented in superclass
|
18
|
-
# @abstract
|
19
|
-
def next
|
20
|
-
raise(KXI::Exceptions::AbstractException.new(Enumerator))
|
21
|
-
end
|
22
|
-
|
23
|
-
# Returns current item
|
24
|
-
# @return [Object] Current item
|
25
|
-
# @raise [KXI::Exceptions::AbstractException] When method is not implemented in superclass
|
26
|
-
# @abstract
|
27
|
-
def current
|
28
|
-
raise(KXI::Exceptions::AbstractException.new(Enumerator))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
1
|
+
# Created by Matyáš Pokorný on 2017-12-28.
|
2
|
+
|
3
|
+
module KXI
|
4
|
+
module Collections
|
5
|
+
# Allows iteration over a collection
|
6
|
+
# @abstract
|
7
|
+
class Enumerator
|
8
|
+
# Selects first item in collection
|
9
|
+
# @return [Bool] True if collection contains elements; otherwise false
|
10
|
+
# @abstract
|
11
|
+
def rewind
|
12
|
+
raise(KXI::Exceptions::AbstractException.new(Enumerator))
|
13
|
+
end
|
14
|
+
|
15
|
+
# Advances enumerator to next item
|
16
|
+
# @return [Bool] True if item is available; false otherwise
|
17
|
+
# @raise [KXI::Exceptions::AbstractException] When method is not implemented in superclass
|
18
|
+
# @abstract
|
19
|
+
def next
|
20
|
+
raise(KXI::Exceptions::AbstractException.new(Enumerator))
|
21
|
+
end
|
22
|
+
|
23
|
+
# Returns current item
|
24
|
+
# @return [Object] Current item
|
25
|
+
# @raise [KXI::Exceptions::AbstractException] When method is not implemented in superclass
|
26
|
+
# @abstract
|
27
|
+
def current
|
28
|
+
raise(KXI::Exceptions::AbstractException.new(Enumerator))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
32
|
end
|
@@ -1,101 +1,101 @@
|
|
1
|
-
# Created by Matyáš Pokorný on 2017-12-29.
|
2
|
-
|
3
|
-
module KXI
|
4
|
-
module Collections
|
5
|
-
# Makes hash enumerable.
|
6
|
-
# Every key-value pair of hash is represented by {KXI::Collections::HashCollection::HashEnumerator::KeyValuePair} class
|
7
|
-
class HashCollection < KXI::Collections::Enumerable
|
8
|
-
# Instantiates the {KXI::Collections::HashCollection} class
|
9
|
-
# @param hash [Hash] Hash for enumeration
|
10
|
-
def initialize(hash)
|
11
|
-
super()
|
12
|
-
@hash = hash
|
13
|
-
end
|
14
|
-
|
15
|
-
# Creates a new {KXI::Collections::Enumerator} bound to this instance
|
16
|
-
# @return [KXI::Collections::Enumerator] Enumerator bound to this instance
|
17
|
-
def create_enumerator
|
18
|
-
HashEnumerator.new(@hash)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Gets value from hash at given key
|
22
|
-
# @param key [Object] Key of value to obtain
|
23
|
-
# @return [Object] Obtained value
|
24
|
-
def [](key)
|
25
|
-
lock do
|
26
|
-
return @hash[key]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# Sets value to hash at given key
|
31
|
-
# @param key [Object] Key of pair to set
|
32
|
-
# @param value [Object] Value to set the pair to
|
33
|
-
# @return [Object] Given value
|
34
|
-
def []=(key, value)
|
35
|
-
lock(true) do
|
36
|
-
@hash[key] = value
|
37
|
-
end
|
38
|
-
return value
|
39
|
-
end
|
40
|
-
|
41
|
-
# Enumerates hash as key-value pairs represented by the {KXI::Collections::HashCollection::HashEnumerator::KeyValuePair} class
|
42
|
-
class HashEnumerator < KXI::Collections::Enumerator
|
43
|
-
# Instantiates the {KXI::Collections::HashCollection::HashEnumerator} class
|
44
|
-
# @param hash [Hash] Hash for enumeration
|
45
|
-
def initialize(hash)
|
46
|
-
@hash = hash
|
47
|
-
@keys = hash.keys
|
48
|
-
@current = 0
|
49
|
-
end
|
50
|
-
|
51
|
-
# Selects first item in collection
|
52
|
-
# @return [Bool] True if collection contains elements; otherwise false
|
53
|
-
def rewind
|
54
|
-
@current = 0
|
55
|
-
return @keys.length > 0
|
56
|
-
end
|
57
|
-
|
58
|
-
# Advances enumerator to next item
|
59
|
-
# @return [Bool] True if item is available; false otherwise
|
60
|
-
# @raise [KXI::Exceptions::AbstractException] When method is not implemented in superclass
|
61
|
-
def next
|
62
|
-
@current += 1
|
63
|
-
return @keys.length > @current
|
64
|
-
end
|
65
|
-
|
66
|
-
# Returns current item
|
67
|
-
# @return [Object] Current item
|
68
|
-
# @raise [KXI::Exceptions::AbstractException] When method is not implemented in superclass
|
69
|
-
def current
|
70
|
-
k = @keys[@current]
|
71
|
-
KeyValuePair.new(k, @hash[k])
|
72
|
-
end
|
73
|
-
|
74
|
-
# Represents a key-value pair
|
75
|
-
class KeyValuePair
|
76
|
-
# Returns the key of pair
|
77
|
-
# @return [Object] Key of pair
|
78
|
-
def key
|
79
|
-
@key
|
80
|
-
end
|
81
|
-
|
82
|
-
# Returns the value of pair
|
83
|
-
# @return [Object] Value of pair
|
84
|
-
def value
|
85
|
-
@val
|
86
|
-
end
|
87
|
-
|
88
|
-
# Instantiates the {KXI::Collections::HashCollection::HashEnumerator::KeyValuePair} class
|
89
|
-
# @param k [Object] Key of pair
|
90
|
-
# @param v [Object] Value of pair
|
91
|
-
def initialize(k, v)
|
92
|
-
@key = k
|
93
|
-
@val = v
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
protected :create_enumerator
|
99
|
-
end
|
100
|
-
end
|
1
|
+
# Created by Matyáš Pokorný on 2017-12-29.
|
2
|
+
|
3
|
+
module KXI
|
4
|
+
module Collections
|
5
|
+
# Makes hash enumerable.
|
6
|
+
# Every key-value pair of hash is represented by {KXI::Collections::HashCollection::HashEnumerator::KeyValuePair} class
|
7
|
+
class HashCollection < KXI::Collections::Enumerable
|
8
|
+
# Instantiates the {KXI::Collections::HashCollection} class
|
9
|
+
# @param hash [Hash] Hash for enumeration
|
10
|
+
def initialize(hash)
|
11
|
+
super()
|
12
|
+
@hash = hash
|
13
|
+
end
|
14
|
+
|
15
|
+
# Creates a new {KXI::Collections::Enumerator} bound to this instance
|
16
|
+
# @return [KXI::Collections::Enumerator] Enumerator bound to this instance
|
17
|
+
def create_enumerator
|
18
|
+
HashEnumerator.new(@hash)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Gets value from hash at given key
|
22
|
+
# @param key [Object] Key of value to obtain
|
23
|
+
# @return [Object] Obtained value
|
24
|
+
def [](key)
|
25
|
+
lock do
|
26
|
+
return @hash[key]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# Sets value to hash at given key
|
31
|
+
# @param key [Object] Key of pair to set
|
32
|
+
# @param value [Object] Value to set the pair to
|
33
|
+
# @return [Object] Given value
|
34
|
+
def []=(key, value)
|
35
|
+
lock(true) do
|
36
|
+
@hash[key] = value
|
37
|
+
end
|
38
|
+
return value
|
39
|
+
end
|
40
|
+
|
41
|
+
# Enumerates hash as key-value pairs represented by the {KXI::Collections::HashCollection::HashEnumerator::KeyValuePair} class
|
42
|
+
class HashEnumerator < KXI::Collections::Enumerator
|
43
|
+
# Instantiates the {KXI::Collections::HashCollection::HashEnumerator} class
|
44
|
+
# @param hash [Hash] Hash for enumeration
|
45
|
+
def initialize(hash)
|
46
|
+
@hash = hash
|
47
|
+
@keys = hash.keys
|
48
|
+
@current = 0
|
49
|
+
end
|
50
|
+
|
51
|
+
# Selects first item in collection
|
52
|
+
# @return [Bool] True if collection contains elements; otherwise false
|
53
|
+
def rewind
|
54
|
+
@current = 0
|
55
|
+
return @keys.length > 0
|
56
|
+
end
|
57
|
+
|
58
|
+
# Advances enumerator to next item
|
59
|
+
# @return [Bool] True if item is available; false otherwise
|
60
|
+
# @raise [KXI::Exceptions::AbstractException] When method is not implemented in superclass
|
61
|
+
def next
|
62
|
+
@current += 1
|
63
|
+
return @keys.length > @current
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns current item
|
67
|
+
# @return [Object] Current item
|
68
|
+
# @raise [KXI::Exceptions::AbstractException] When method is not implemented in superclass
|
69
|
+
def current
|
70
|
+
k = @keys[@current]
|
71
|
+
KeyValuePair.new(k, @hash[k])
|
72
|
+
end
|
73
|
+
|
74
|
+
# Represents a key-value pair
|
75
|
+
class KeyValuePair
|
76
|
+
# Returns the key of pair
|
77
|
+
# @return [Object] Key of pair
|
78
|
+
def key
|
79
|
+
@key
|
80
|
+
end
|
81
|
+
|
82
|
+
# Returns the value of pair
|
83
|
+
# @return [Object] Value of pair
|
84
|
+
def value
|
85
|
+
@val
|
86
|
+
end
|
87
|
+
|
88
|
+
# Instantiates the {KXI::Collections::HashCollection::HashEnumerator::KeyValuePair} class
|
89
|
+
# @param k [Object] Key of pair
|
90
|
+
# @param v [Object] Value of pair
|
91
|
+
def initialize(k, v)
|
92
|
+
@key = k
|
93
|
+
@val = v
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
protected :create_enumerator
|
99
|
+
end
|
100
|
+
end
|
101
101
|
end
|
@@ -1,20 +1,21 @@
|
|
1
|
-
# Created by Matyáš Pokorný on 2018-01-20.
|
2
|
-
|
3
|
-
module KXI
|
4
|
-
module Collections
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
#
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
# Created by Matyáš Pokorný on 2018-01-20.
|
2
|
+
|
3
|
+
module KXI
|
4
|
+
module Collections
|
5
|
+
# Represents a collection that can only be enumerated
|
6
|
+
class ProtectedCollection < KXI::Collections::Enumerable
|
7
|
+
# Instantiates the {KXI::Collections::ArrayCollection} class
|
8
|
+
# @param enum [KXI::Collections::Enumerable] Protected enumerable
|
9
|
+
def initialize(enum = [])
|
10
|
+
super()
|
11
|
+
@enum = enum
|
12
|
+
end
|
13
|
+
|
14
|
+
# Creates a new {KXI::Collections::Enumerator} bound to this instance
|
15
|
+
# @return [KXI::Collections::Enumerator] Enumerator bound to this instance
|
16
|
+
def create_enumerator
|
17
|
+
@enum.create_enumerator
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
20
21
|
end
|
@@ -1,35 +1,35 @@
|
|
1
|
-
# Created by Matyáš Pokorný on 2017-12-28.
|
2
|
-
module KXI
|
3
|
-
module Exceptions
|
4
|
-
# Raised when method that was supposed to be implemented by super class wasn't
|
5
|
-
class AbstractException < Exception
|
6
|
-
# Returns the abstract class
|
7
|
-
# @return [Class] Abstract class
|
8
|
-
def class
|
9
|
-
@class
|
10
|
-
end
|
11
|
-
|
12
|
-
# Returns the file that contains the abstract class
|
13
|
-
# @return [String] Path of file that contains the abstract class
|
14
|
-
def file
|
15
|
-
@file
|
16
|
-
end
|
17
|
-
|
18
|
-
# Returns name of the abstract method
|
19
|
-
# @return [String] Name of the abstract method
|
20
|
-
def method
|
21
|
-
@mtd
|
22
|
-
end
|
23
|
-
|
24
|
-
# Instantiates the {KXI::Exceptions::AbstractException} class
|
25
|
-
# @param cl [Class] Abstract class
|
26
|
-
def initialize(cl)
|
27
|
-
frame = Reflection::StackFrame.callstack(3).first
|
28
|
-
@file = frame.file
|
29
|
-
@mtd = frame.method
|
30
|
-
super("Abstract method #{cl.name}##{@mtd} wasn't implemented!")
|
31
|
-
@class = cl
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
# Created by Matyáš Pokorný on 2017-12-28.
|
2
|
+
module KXI
|
3
|
+
module Exceptions
|
4
|
+
# Raised when method that was supposed to be implemented by super class wasn't
|
5
|
+
class AbstractException < Exception
|
6
|
+
# Returns the abstract class
|
7
|
+
# @return [Class] Abstract class
|
8
|
+
def class
|
9
|
+
@class
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns the file that contains the abstract class
|
13
|
+
# @return [String] Path of file that contains the abstract class
|
14
|
+
def file
|
15
|
+
@file
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns name of the abstract method
|
19
|
+
# @return [String] Name of the abstract method
|
20
|
+
def method
|
21
|
+
@mtd
|
22
|
+
end
|
23
|
+
|
24
|
+
# Instantiates the {KXI::Exceptions::AbstractException} class
|
25
|
+
# @param cl [Class] Abstract class
|
26
|
+
def initialize(cl)
|
27
|
+
frame = Reflection::StackFrame.callstack(3).first
|
28
|
+
@file = frame.file
|
29
|
+
@mtd = frame.method
|
30
|
+
super("Abstract method #{cl.name}##{@mtd} wasn't implemented!")
|
31
|
+
@class = cl
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
35
|
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
# Created by Matyáš Pokorný on 2018-01-20.
|
2
|
-
|
3
|
-
module KXI
|
4
|
-
module Exceptions
|
5
|
-
# Raised when command-line parser encounters an error
|
6
|
-
class ArgumentException < Exception
|
7
|
-
# Get the name of argument
|
8
|
-
# @return [String] Name of argument
|
9
|
-
def argument
|
10
|
-
@arg
|
11
|
-
end
|
12
|
-
|
13
|
-
# Instantiates the {KXI::Exceptions::ArgumentException} class
|
14
|
-
# @param arg [String] Name of argument
|
15
|
-
# @param msg [String] Error message
|
16
|
-
def initialize(arg, msg)
|
17
|
-
super("<#{arg}> #{msg}")
|
18
|
-
@arg = arg
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
# Created by Matyáš Pokorný on 2018-01-20.
|
2
|
+
|
3
|
+
module KXI
|
4
|
+
module Exceptions
|
5
|
+
# Raised when command-line parser encounters an error
|
6
|
+
class ArgumentException < Exception
|
7
|
+
# Get the name of argument
|
8
|
+
# @return [String] Name of argument
|
9
|
+
def argument
|
10
|
+
@arg
|
11
|
+
end
|
12
|
+
|
13
|
+
# Instantiates the {KXI::Exceptions::ArgumentException} class
|
14
|
+
# @param arg [String] Name of argument
|
15
|
+
# @param msg [String] Error message
|
16
|
+
def initialize(arg, msg)
|
17
|
+
super("<#{arg}> #{msg}")
|
18
|
+
@arg = arg
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
22
|
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# Created by Matyáš Pokorný on 2017-12-28.
|
2
|
-
|
3
|
-
module KXI
|
4
|
-
module Exceptions
|
5
|
-
# Raised when collection encounters an error
|
6
|
-
class CollectionException < Exception
|
7
|
-
# Instantiates the {KXI::Exceptions::CollectionException} class
|
8
|
-
# @param msg [String] Exception message
|
9
|
-
def initialize(msg)
|
10
|
-
super(msg)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
1
|
+
# Created by Matyáš Pokorný on 2017-12-28.
|
2
|
+
|
3
|
+
module KXI
|
4
|
+
module Exceptions
|
5
|
+
# Raised when collection encounters an error
|
6
|
+
class CollectionException < Exception
|
7
|
+
# Instantiates the {KXI::Exceptions::CollectionException} class
|
8
|
+
# @param msg [String] Exception message
|
9
|
+
def initialize(msg)
|
10
|
+
super(msg)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
14
|
end
|