nmg 0.1.0 → 0.2.0
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/bin/nmg +18 -7
- data/lib/nmg/type/machine.rb +0 -2
- data/lib/nmg/type/operation.rb +23 -0
- data/lib/nmg/type/process.rb +2 -5
- data/lib/nmg/version.rb +1 -1
- data/lib/nmg.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1ae617c95c4a53e6e2af74e8a7c9fe446c53152
|
|
4
|
+
data.tar.gz: b42d1887068b227879fd5a9b5cb532aab878eefe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1884a297580c731fe8147391dd801aac368b84a3a34e0093a6191ae419d03dca97c8d473bb22bef5dd67678d117ffdf363d8e57d310f833bbe815d5c52f2d766
|
|
7
|
+
data.tar.gz: ea40907d9689e9d5e03f3a9acec4195ef07c06b64996d3f9ad3bfd7ce78036ae7a597fea99087b53425e16af95b508f4d6d2546176d2bec09b4599ce86ec57a8
|
data/bin/nmg
CHANGED
|
@@ -26,14 +26,15 @@ class Nmg::CLI < Thor
|
|
|
26
26
|
option :operations,
|
|
27
27
|
type: :numeric,
|
|
28
28
|
aliases: %w(-o --opts),
|
|
29
|
-
desc: 'Count of operations per process
|
|
29
|
+
desc: 'Count of operations per process',
|
|
30
|
+
default: 3
|
|
30
31
|
option :'maintenance-duration-min',
|
|
31
32
|
type: :numeric,
|
|
32
|
-
default:
|
|
33
|
+
default: 10,
|
|
33
34
|
desc: 'Minimum maintenance duration'
|
|
34
35
|
option :'maintenance-duration-max',
|
|
35
36
|
type: :numeric,
|
|
36
|
-
default:
|
|
37
|
+
default: 50,
|
|
37
38
|
desc: 'Maximum maintenance duration'
|
|
38
39
|
option :'maintenance-step-min',
|
|
39
40
|
type: :numeric,
|
|
@@ -45,15 +46,23 @@ class Nmg::CLI < Thor
|
|
|
45
46
|
desc: 'Maximum time between two maintenances'
|
|
46
47
|
option :'operation-duration-min',
|
|
47
48
|
type: :numeric,
|
|
48
|
-
default:
|
|
49
|
+
default: 10,
|
|
49
50
|
desc: 'Minimum operation duration'
|
|
50
51
|
option :'operation-duration-max',
|
|
51
52
|
type: :numeric,
|
|
52
|
-
default:
|
|
53
|
+
default: 50,
|
|
53
54
|
desc: 'Maximum operation duration'
|
|
55
|
+
option :'preparation-min',
|
|
56
|
+
type: :numeric,
|
|
57
|
+
default: 5,
|
|
58
|
+
desc: 'Minimum preparation time'
|
|
59
|
+
option :'preparation-max',
|
|
60
|
+
type: :numeric,
|
|
61
|
+
default: 25,
|
|
62
|
+
desc: 'Maximum preparation time'
|
|
54
63
|
def generate(file)
|
|
55
64
|
machine_opts = {
|
|
56
|
-
|
|
65
|
+
maintenences_count: options[:maintenances],
|
|
57
66
|
maintenances: {
|
|
58
67
|
from: options[:'maintenance-duration-min'],
|
|
59
68
|
to: options[:'maintenance-duration-max'],
|
|
@@ -66,7 +75,9 @@ class Nmg::CLI < Thor
|
|
|
66
75
|
task_opts = {
|
|
67
76
|
operations: options[:operations] || options[:machines],
|
|
68
77
|
min: options[:'operation-duration-min'],
|
|
69
|
-
max: options[:'operation-duration-max']
|
|
78
|
+
max: options[:'operation-duration-max'],
|
|
79
|
+
prep_min: options[:'preparation-min'],
|
|
80
|
+
prep_max: options[:'preparation-max']
|
|
70
81
|
}
|
|
71
82
|
hash = {
|
|
72
83
|
machines: Nmg::Type::Machine.generate(options[:machines], machine_opts),
|
data/lib/nmg/type/machine.rb
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module Nmg
|
|
2
|
+
module Type
|
|
3
|
+
class Operation < Base
|
|
4
|
+
attribute :preparation, Integer
|
|
5
|
+
attribute :duration, Integer
|
|
6
|
+
|
|
7
|
+
def to_json(options = {})
|
|
8
|
+
{
|
|
9
|
+
preparation: preparation,
|
|
10
|
+
duration: duration
|
|
11
|
+
}.to_json(options)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.generate(count, options = {}, gen = Random.new)
|
|
15
|
+
prep = (options[:prep_min]..options[:prep_max])
|
|
16
|
+
count.times.map do
|
|
17
|
+
new(preparation: gen.rand(prep),
|
|
18
|
+
duration: gen.rand(options[:min]..options[:max]))
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/nmg/type/process.rb
CHANGED
|
@@ -5,20 +5,17 @@ module Nmg
|
|
|
5
5
|
# @!macro [attach] virtus.attribute
|
|
6
6
|
# @!attribute $1
|
|
7
7
|
# @return [$2] the $1 $0
|
|
8
|
-
attribute :operations, Array[
|
|
8
|
+
attribute :operations, Array[Operation]
|
|
9
9
|
|
|
10
10
|
def to_json(options = {})
|
|
11
11
|
operations.to_json(options)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def self.generate(count, options = {}, gen = Random.new)
|
|
15
|
-
options = {operations: 3, min: 1, max: 20}.merge(options)
|
|
16
|
-
|
|
17
15
|
operations = options[:operations]
|
|
18
|
-
range = (options[:min]..options[:max])
|
|
19
16
|
|
|
20
17
|
count.times.map do
|
|
21
|
-
new(operations:
|
|
18
|
+
new(operations: Operation.generate(operations, options))
|
|
22
19
|
end
|
|
23
20
|
end
|
|
24
21
|
end
|
data/lib/nmg/version.rb
CHANGED
data/lib/nmg.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nmg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Łukasz Niemier
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-12-
|
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|
|
@@ -99,6 +99,7 @@ files:
|
|
|
99
99
|
- lib/nmg/type/base.rb
|
|
100
100
|
- lib/nmg/type/machine.rb
|
|
101
101
|
- lib/nmg/type/maintenance.rb
|
|
102
|
+
- lib/nmg/type/operation.rb
|
|
102
103
|
- lib/nmg/type/process.rb
|
|
103
104
|
- lib/nmg/version.rb
|
|
104
105
|
- nmg.gemspec
|