gemwarrior 0.15.0 → 0.15.1

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: 42b11f28fb910a20ab8c22ad7c97f67403c0ea9b
4
- data.tar.gz: 884e88c0ee09cd7c34cd75b675c09d301750642a
3
+ metadata.gz: 2cf065fa4c0e9564a627c3ce4cf75b9ffff0f1b9
4
+ data.tar.gz: cdbe3d70715d1681f14578fa2ef9823a09f9dd6c
5
5
  SHA512:
6
- metadata.gz: 59cc678e76ce6dbd0d88fcef353eeef743185f4d78fa27dde69a84b7bc7779b1fc50d35c4ab1a2cb3d0a43588c0b866460838459b6499a7620074cb076922e88
7
- data.tar.gz: 94ef68e78d3e118385b91b26ee3ac71123546a6535b05fbe8baeb3a41b197e5977c10fd4a19c66aad557c2443d5a717fe2c4152343bc03c1618567ab9ea5905f
6
+ metadata.gz: 8e71c30f11de78dc95ce694381cce617f7ff4022a7ff172bc81663111cb3a6c656d50b03fd85ab51c8d56874a50b69454a12a8dc994d49ee6c6d8d5ed42f890f
7
+ data.tar.gz: a6fcb8ea07fa73b489e69f6fbba6d9027153f5e3fc344433bae76dd1a34aefc5277545128ecde7b10a2cb212aef50631367362ee170978e923cabfd4f40bc440
File without changes
@@ -1,19 +1,24 @@
1
1
  # lib/gemwarrior/misc/timer.rb
2
2
  # Timer
3
3
 
4
+ require 'observer'
5
+
4
6
  module Gemwarrior
5
7
  class Timer
6
- attr_accessor :duration_in_s, :timer_name, :background, :progress, :verbose
8
+ include Observable
9
+
10
+ attr_accessor :duration_in_s, :timer_name, :background, :progress, :verbose, :command
7
11
 
8
12
  DEFAULTS = {
9
- duration_in_s: 1,
10
- timer_name: 'Timer',
11
- background: false,
13
+ duration_in_s: 5,
14
+ timer_name: 'timer',
15
+ background: true,
12
16
  progress: false,
13
- verbose: true
17
+ verbose: false,
18
+ command: nil
14
19
  }
15
20
 
16
- def initialize(options = {})
21
+ def initialize(options = {}, repl)
17
22
  options = DEFAULTS.merge(options)
18
23
 
19
24
  self.duration_in_s = options[:duration_in_s]
@@ -21,6 +26,9 @@ module Gemwarrior
21
26
  self.background = options[:background]
22
27
  self.progress = options[:progress]
23
28
  self.verbose = options[:verbose]
29
+ self.command = options[:command]
30
+
31
+ add_observer(repl)
24
32
  end
25
33
 
26
34
  def start
@@ -40,11 +48,15 @@ module Gemwarrior
40
48
  sleep 1
41
49
  print '.' if progress
42
50
  if Time.now >= end_time
43
- print "\n"
44
- puts "#{timer_name} ended at #{Time.now}" if verbose
45
- return
51
+ return stop
46
52
  end
47
53
  end
48
54
  end
55
+
56
+ def stop
57
+ puts "\n#{timer_name} ended at #{Time.now}" if verbose
58
+ changed
59
+ notify_observers(self.command) unless self.command.nil?
60
+ end
49
61
  end
50
62
  end
@@ -76,15 +76,7 @@ module Gemwarrior
76
76
  loop do
77
77
  prompt
78
78
  begin
79
- input = read_line
80
- result = evaluator.parse(input)
81
- if result.eql?('exit')
82
- exit
83
- elsif result.eql?('checkupdate')
84
- check_for_new_release
85
- else
86
- puts result
87
- end
79
+ main_loop
88
80
  rescue Interrupt
89
81
  puts
90
82
  puts QUIT_MESSAGE
@@ -94,6 +86,23 @@ module Gemwarrior
94
86
  end
95
87
  end
96
88
 
89
+ def main_loop(ext_input = nil)
90
+ input = ext_input.nil? ? read_line : ext_input
91
+ result = evaluator.parse(input)
92
+ if result.eql?('exit')
93
+ exit
94
+ elsif result.eql?('checkupdate')
95
+ check_for_new_release
96
+ else
97
+ puts result
98
+ end
99
+ end
100
+
101
+ # timer observer
102
+ #def update(command)
103
+ # main_loop(command)
104
+ #end
105
+
97
106
  private
98
107
 
99
108
  def clear_screen
@@ -2,5 +2,5 @@
2
2
  # Version of Gem Warrior
3
3
 
4
4
  module Gemwarrior
5
- VERSION = '0.15.0'
5
+ VERSION = '0.15.1'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemwarrior
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Chadwick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-28 00:00:00.000000000 Z
11
+ date: 2015-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: os
@@ -367,4 +367,6 @@ rubygems_version: 2.4.8
367
367
  signing_key:
368
368
  specification_version: 4
369
369
  summary: RubyGem text adventure
370
- test_files: []
370
+ test_files:
371
+ - spec/gemwarrior_spec.rb
372
+ - spec/spec_helper.rb