downtime 0.0.1 → 0.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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MGIzYzI1YWI5YjA4NjZlZDI1NWVkYTUxMWVjODU4ZTc1NTg1ODc0NA==
4
+ Y2IxMzQ3N2U2NThhOWFjZTNjYTcwYTY4YmNhNjNmNDc0MmIzYjg4Yg==
5
5
  data.tar.gz: !binary |-
6
- ZTcxZGZhODA0OTM5NWUxZmE3NWU2NDhlNDdhYTJiZmZmYjM2ZTc3NQ==
6
+ NWVjMDlmZTc3Y2U4NWM3M2MyOWQ5OGY3YmQ3ODBiODNiMDY2Yjc0ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODc2NjBlZDAwYzg4NTFjZTAzMzg2YzdmNDczYWEwZjMzNWZmNjZhNDRkMjY3
10
- M2Q0MmViOGM1Y2Y1NjY4N2NhYzA0M2ZlMmRhMWVjYjZhYzM3ZTQzZjNlYzkz
11
- ZTAwMTdjYTM3NTNhNDI5ZGQ3NGM1ZmYyODlmNmQ4ODFiN2M2MTA=
9
+ N2QxMWViYWI0YmU4NjA3OWJhMjQ0NmZjN2ZkY2MxNmIzOGYxNzk4ZTU2MWRh
10
+ ODdhNzNlNGI0NmQ1NDUyZjg2NzcwYWNjMWU4NTliNzY0ZTQ0MzkzMjMzZGM5
11
+ MzY0ZWVkYWYwZTMzZGJjYTA4ZjBmNjA3MTY5YzRkMDE5Y2IxMWU=
12
12
  data.tar.gz: !binary |-
13
- MGJkZTc3ZmQ5ZjBjODA5ZGUyYjc2MGVkNDJkMzk2ZTJjYTE1NjI5YjEzYTVk
14
- YzYyMGIwMDM3MzRmZmVlMjFhOGNmYmU2ZGRhYjBmNzI4M2Y1NDU2MWZiY2E3
15
- ZjllYjBkNzY5ZTFiMDY4NTVjOThiODQ5NDlhZmY3MzFhNDBhNjA=
13
+ N2ZmOGExNTY3NzkxYTE5YzBjMzJmNjczOTlhZjA4MjBjOTMzOGQxNmVkOTVj
14
+ NDhmYzYwMTI5YmY4Y2VhMjdlYjRiMDk3MDMwNWZmN2E0ZGQyZDJkODNjZTFm
15
+ OTA4OGFkNGY2NmI1MDVmMzZhZjAyZDM3NjE0ZGNkZjZkYjY3ZDA=
data/.gitignore CHANGED
@@ -12,3 +12,4 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ downtime.log
data/README.md CHANGED
@@ -31,12 +31,12 @@ It will create a `downtime.log` file in the current working directory.
31
31
 
32
32
  The file (`downtime.log`) will look like this:
33
33
 
34
- # This file was generated by the downtime ruby gem.
35
- 2015-01-01-10-22 up till 2015-01-02-08-10
36
- ! went down after 1000 minutes up
37
- 2015-01-02-08-10 down till 2015-01-03-08-40
38
- ! went up after 30 minutes down
39
- 2015-01-02-08-40 up till 2015-01-03-08-45
34
+ # This file was generated by the downtime ruby gem.
35
+ 2015-01-01-10-22 up till 2015-01-02-08-10
36
+ ! went down after 1000 minutes up
37
+ 2015-01-02-08-10 down till 2015-01-03-08-40
38
+ ! went up after 30 minutes down
39
+ 2015-01-02-08-40 up till 2015-01-03-08-45
40
40
 
41
41
  ## Caveats
42
42
 
data/bin/downtime CHANGED
@@ -2,19 +2,11 @@
2
2
 
3
3
  require 'downtime'
4
4
 
5
- # Check last state
6
- # check current state
7
- # if last = up
8
- # if current = up
9
- # if current = down
10
- # if last = down
11
- # if current = up
12
- # if current = down
13
- #
14
-
15
5
  check = Downtime::DowntimeCheck.new
16
6
  check.perform
17
7
 
8
+ # I'd like a friendly exit code
9
+
18
10
  #if Downtime.up?
19
11
  # Downtime.up_now!
20
12
  # exit 0
@@ -1,3 +1,3 @@
1
1
  module Downtime
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/downtime.rb CHANGED
@@ -37,14 +37,14 @@ module Downtime
37
37
  else
38
38
  # "stayed down"
39
39
  # Modify last line.
40
- lines[-1].gsub!(/till.*/, "till #{@timestamp}")
40
+ lines[-1].gsub!(/till.*/, "till #{@timestamp} (#{minutes} minutes)")
41
41
  end
42
42
  else
43
43
  # was up before
44
44
  if up
45
45
  # "stayed up."
46
46
  # Modify last line.
47
- lines[-1].gsub!(/till.*/, "till #{@timestamp}")
47
+ lines[-1].gsub!(/till.*/, "till #{@timestamp} (#{minutes} minutes)")
48
48
  else
49
49
  # "went down."
50
50
  lines << "! went down after #{minutes} minutes of uptime."
@@ -70,5 +70,11 @@ module Downtime
70
70
  def timestamp!
71
71
  @timestamp = Timestamp.new
72
72
  end
73
+
74
+ def append_to_logfile text
75
+ File.open(@log_file, 'a') do |f|
76
+ f.puts text
77
+ end
78
+ end
73
79
  end
74
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: downtime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Wolfsteller