ast-tdl 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/README.md +33 -0
- data/lib/ast-tdl.rb +1 -0
- data/lib/ast.rb +53 -0
- data/lib/classes.rb +86 -0
- data/lib/interval.rb +51 -0
- data/lib/session.rb +42 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2f857804cef121dd1c5f2a8e41ab0d27098517e03ee15c8316bc0e62d7707093
|
4
|
+
data.tar.gz: 2235c16bf905edf99c00693477e5b9c0f037b084c39ca541bec49f00031f9cdb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62436ef8167db994e207f1309c7a41a9b022ceae7ca85f82f57b9f630134965859ceb845953b99c5858a3a16613961ba04507451252a27597da9702e86458655
|
7
|
+
data.tar.gz: 10e94fd67a4301721b0b600b4786fe73d5527493a3c192d85e1f7d8c290fe376a79f4e3ebab62f63eba8748b7af025fbf59cd1d4203b608634e5f0ae31f644b5
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Training Description Language (TDL) for Artificial Sport Trainer (AST)
|
2
|
+
|
3
|
+
AST-DSL is a very small domain-specific language
|
4
|
+
|
5
|
+
## Objective
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install ast-tdl
|
10
|
+
|
11
|
+
## Language description
|
12
|
+
|
13
|
+
## Examples
|
14
|
+
|
15
|
+
### Session
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
session("Short swimming session today") {
|
19
|
+
sport :"swim"
|
20
|
+
info :"Very easy training"
|
21
|
+
avhr :"130"
|
22
|
+
td :"30"
|
23
|
+
}
|
24
|
+
```
|
25
|
+
## License
|
26
|
+
|
27
|
+
This package is distributed under the MIT License. This license can be found online at <http://www.opensource.org/licenses/MIT>.
|
28
|
+
|
29
|
+
## Disclaimer
|
30
|
+
|
31
|
+
This framework is provided as-is, and there are no guarantees that it fits your purposes or that it is bug-free. Use it at your own risk!
|
32
|
+
|
33
|
+
|
data/lib/ast-tdl.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'ast'
|
data/lib/ast.rb
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
require_relative 'classes'
|
4
|
+
require_relative 'interval'
|
5
|
+
require_relative 'session'
|
6
|
+
|
7
|
+
|
8
|
+
module Ast
|
9
|
+
def self.build(name, &block)
|
10
|
+
training = Training.new(name)
|
11
|
+
training.instance_eval(&block)
|
12
|
+
return training
|
13
|
+
end
|
14
|
+
|
15
|
+
class Training
|
16
|
+
def initialize(name)
|
17
|
+
@name = name
|
18
|
+
@session = []
|
19
|
+
@interval = []
|
20
|
+
end
|
21
|
+
|
22
|
+
def session(name, &block)
|
23
|
+
training_type = Session.new(name)
|
24
|
+
training_type.instance_eval(&block)
|
25
|
+
@session << training_type
|
26
|
+
end
|
27
|
+
|
28
|
+
def interval(name, &block)
|
29
|
+
interval_data = Interval.new(name)
|
30
|
+
interval_data.instance_eval(&block)
|
31
|
+
@interval << interval_data
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_s
|
35
|
+
str = "#{@name} #{@session[0]}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def json
|
39
|
+
training_json = {
|
40
|
+
name: @name,
|
41
|
+
session: @session.collect { |x| x.to_hash },
|
42
|
+
interval: @interval.collect { |x| x.to_hash },
|
43
|
+
}
|
44
|
+
training_json.to_json
|
45
|
+
end
|
46
|
+
|
47
|
+
def save_to_file(filename)
|
48
|
+
f = File.open(filename, "w")
|
49
|
+
f.puts(json)
|
50
|
+
f.close
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/classes.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
|
4
|
+
class Sport
|
5
|
+
attr_reader :type
|
6
|
+
|
7
|
+
def initialize(type)
|
8
|
+
@type = type
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_hash
|
12
|
+
sport_json = {
|
13
|
+
type: @type
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Info
|
19
|
+
attr_reader :message
|
20
|
+
|
21
|
+
def initialize(message)
|
22
|
+
@message = message
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_hash
|
26
|
+
info_json = {
|
27
|
+
message: @message
|
28
|
+
}
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Avhr
|
33
|
+
attr_reader :heart_rate
|
34
|
+
|
35
|
+
def initialize(heart_rate)
|
36
|
+
@heart_rate = heart_rate
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_hash
|
40
|
+
info_json = {
|
41
|
+
average_hr: @heart_rate
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Td
|
47
|
+
attr_reader :duration
|
48
|
+
|
49
|
+
def initialize(duration)
|
50
|
+
@duration = duration
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_hash
|
54
|
+
td_json = {
|
55
|
+
duration: @duration
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class AvhrRest
|
61
|
+
attr_reader :avhr_rest
|
62
|
+
|
63
|
+
def initialize(avhr_rest)
|
64
|
+
@avhr_rest = avhr_rest
|
65
|
+
end
|
66
|
+
|
67
|
+
def to_hash
|
68
|
+
avhr_json = {
|
69
|
+
average_hr_rest: @avhr_rest
|
70
|
+
}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class TdRest
|
75
|
+
attr_reader :td_rest
|
76
|
+
|
77
|
+
def initialize(td_rest)
|
78
|
+
@td_rest = td_rest
|
79
|
+
end
|
80
|
+
|
81
|
+
def to_hash
|
82
|
+
td_json = {
|
83
|
+
duration_rest: @td_rest
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
data/lib/interval.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
class Interval
|
2
|
+
def initialize(name)
|
3
|
+
@name = []
|
4
|
+
@sport = []
|
5
|
+
@info = []
|
6
|
+
@avhr = []
|
7
|
+
@td = []
|
8
|
+
@avhr_rest = []
|
9
|
+
@td_rest = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def sport(type)
|
13
|
+
@sport << Sport.new(type)
|
14
|
+
end
|
15
|
+
|
16
|
+
def info(message)
|
17
|
+
@info << Info.new(message)
|
18
|
+
end
|
19
|
+
|
20
|
+
def avhr(heart_rate)
|
21
|
+
@avhr << Avhr.new(heart_rate)
|
22
|
+
end
|
23
|
+
|
24
|
+
def td(duration)
|
25
|
+
@td << Td.new(duration)
|
26
|
+
end
|
27
|
+
|
28
|
+
def avhr_rest(heart_rate_rest)
|
29
|
+
@avhr_rest << AvhrRest.new(heart_rate_rest)
|
30
|
+
end
|
31
|
+
|
32
|
+
def td_rest(duration_rest)
|
33
|
+
@td_rest << TdRest.new(duration_rest)
|
34
|
+
end
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
str = "#{@sport[0].type} #{@info[0].message}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def to_hash
|
41
|
+
interval_json = {
|
42
|
+
name: @name.collect { |x| x.to_hash },
|
43
|
+
sport: @sport.collect { |x| x.to_hash },
|
44
|
+
info: @info.collect { |x| x.to_hash },
|
45
|
+
average_hr: @avhr.collect { |x| x.to_hash },
|
46
|
+
duration: @td.collect { |x| x.to_hash },
|
47
|
+
average_hr_rest: @avhr_rest.collect { |x| x.to_hash },
|
48
|
+
duration_rest: @td_rest.collect { |x| x.to_hash },
|
49
|
+
}
|
50
|
+
end
|
51
|
+
end
|
data/lib/session.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
|
4
|
+
class Session
|
5
|
+
def initialize(name)
|
6
|
+
@name = []
|
7
|
+
@sport = []
|
8
|
+
@info = []
|
9
|
+
@avhr = []
|
10
|
+
@td = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def sport(type)
|
14
|
+
@sport << Sport.new(type)
|
15
|
+
end
|
16
|
+
|
17
|
+
def info(message)
|
18
|
+
@info << Info.new(message)
|
19
|
+
end
|
20
|
+
|
21
|
+
def avhr(heart_rate)
|
22
|
+
@avhr << Avhr.new(heart_rate)
|
23
|
+
end
|
24
|
+
|
25
|
+
def td(duration)
|
26
|
+
@td << Td.new(duration)
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_s
|
30
|
+
str = "#{@sport[0].type} #{@info[0].message}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_hash
|
34
|
+
session_json = {
|
35
|
+
name: @name.collect { |x| x.to_hash },
|
36
|
+
sport: @sport.collect { |x| x.to_hash },
|
37
|
+
info: @info.collect { |x| x.to_hash },
|
38
|
+
average_hr: @avhr.collect { |x| x.to_hash },
|
39
|
+
duration: @td.collect { |x| x.to_hash },
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ast-tdl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- firefly-cpp
|
8
|
+
- luckyLukac
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2022-06-14 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- iztok@iztok-jr-fister.eu
|
17
|
+
- luka.lukac@student.um.si
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- README.md
|
23
|
+
- lib/ast-tdl.rb
|
24
|
+
- lib/ast.rb
|
25
|
+
- lib/classes.rb
|
26
|
+
- lib/interval.rb
|
27
|
+
- lib/session.rb
|
28
|
+
homepage: https://github.com/firefly-cpp/AST-DSL
|
29
|
+
licenses: []
|
30
|
+
metadata:
|
31
|
+
homepage_uri: https://github.com/firefly-cpp/AST-DSL
|
32
|
+
source_code_uri: https://github.com/firefly-cpp/AST-DSL
|
33
|
+
changelog_uri: https://github.com/firefly-cpp/AST-DSL
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 2.4.0
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubygems_version: 3.3.7
|
50
|
+
signing_key:
|
51
|
+
specification_version: 4
|
52
|
+
summary: An experimental and minimalistic Training Description Language for Artificial
|
53
|
+
Sport Trainer
|
54
|
+
test_files: []
|