nmg 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3146dd36c1eb1813e107e700e617a2edb526acb
4
- data.tar.gz: 7b84da0990de2fa9c4a9117e9ee7acc9b1957f91
3
+ metadata.gz: d1ae617c95c4a53e6e2af74e8a7c9fe446c53152
4
+ data.tar.gz: b42d1887068b227879fd5a9b5cb532aab878eefe
5
5
  SHA512:
6
- metadata.gz: d1b6f082b66a6d8737ba1ab655d677b9a5af38cfea17f45b13c8cc0aef87b41674cc38ae637140be089aabd962bc625cc9a32e78fc5bd70662f07ffb9d66eae7
7
- data.tar.gz: b373a23fc54c369dedd61867600412fa7a4e71a9de2fdd05ecda99c3d27ec0b8df045f12e87aa43d51605d62bb94ba61567d572f9f2931a44f473d9c0004ef17
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 (by default the same as machines count)'
29
+ desc: 'Count of operations per process',
30
+ default: 3
30
31
  option :'maintenance-duration-min',
31
32
  type: :numeric,
32
- default: 1,
33
+ default: 10,
33
34
  desc: 'Minimum maintenance duration'
34
35
  option :'maintenance-duration-max',
35
36
  type: :numeric,
36
- default: 20,
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: 1,
49
+ default: 10,
49
50
  desc: 'Minimum operation duration'
50
51
  option :'operation-duration-max',
51
52
  type: :numeric,
52
- default: 20,
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
- machines_count: options[:maintenances],
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),
@@ -4,8 +4,6 @@ module Nmg
4
4
  attribute :maintenances, Array[Maintenance]
5
5
 
6
6
  def self.generate(count, options = {}, gen = Random.new)
7
- options = {maintenances_count: 10}.merge(options)
8
-
9
7
  maintenances_count = options[:maintenances_count]
10
8
 
11
9
  count.times.map do
@@ -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
@@ -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[Integer]
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: operations.times.map { gen.rand(range) })
18
+ new(operations: Operation.generate(operations, options))
22
19
  end
23
20
  end
24
21
  end
data/lib/nmg/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nmg
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
data/lib/nmg.rb CHANGED
@@ -11,5 +11,6 @@ module Nmg
11
11
  autoload :Process, 'nmg/type/process'
12
12
  autoload :Machine, 'nmg/type/machine'
13
13
  autoload :Maintenance, 'nmg/type/maintenance'
14
+ autoload :Operation, 'nmg/type/operation'
14
15
  end
15
16
  end
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.1.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-03 00:00:00.000000000 Z
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