gibil 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/gibil +15 -15
  3. data/lib/gibil.rb +65 -68
  4. metadata +20 -28
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 180ca57f10c00d2e3c0d46188275d85d4114708c
4
+ data.tar.gz: 0cded32a63035c49281d6108436c531c16ac9470
5
+ SHA512:
6
+ metadata.gz: 9063a76ff2643414ca0579c78f716df1f74feba60a4daaa78d711ea653fda38b5a387b326b01927037f21f72d87464b237b98b1ebef11044f6f9ef0eaf930896
7
+ data.tar.gz: 9471f65d95718e44f96c3128e8f5c358a1d805e28016a64f3cd64533cc88a63b6c5063ba3edb8cc822a1423562c2d043ce25c91ec78d0b8d1e9164e7b92344d6
data/bin/gibil CHANGED
@@ -1,15 +1,15 @@
1
- #!/usr/bin/env ruby
2
- # -*- coding: utf-8 -*-
3
-
4
- require 'gibil'
5
-
6
- args = ARGV.dup
7
-
8
- case args[0]
9
- when 'schedule'
10
- Gibil::Cronify.schedule
11
- when 'job'
12
- Gibil::Notification.notify if Gibil::Sensor.temperature > 60
13
- else
14
- Gibil::Notification.notify
15
- end
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ require 'gibil'
5
+
6
+ args = ARGV.dup
7
+
8
+ case args[0]
9
+ when 'schedule'
10
+ Gibil::Cronify.schedule
11
+ when 'job'
12
+ Gibil::Notification.notify if Gibil::Sensor.temperature > 60
13
+ else
14
+ Gibil::Notification.notify
15
+ end
@@ -1,68 +1,65 @@
1
- # -*- coding: utf-8 -*-
2
- require 'libnotify'
3
-
4
- module Gibil
5
- # Temperature Sensor interface.
6
- # Currently works/tested only on Linux
7
- module Sensor
8
- # == Returns:
9
- # A float value of the system's temperature
10
- def self.temperature
11
- File.read('/sys/class/hwmon/hwmon0/temp1_input').to_f / 1000
12
- end
13
- end
14
-
15
- # Uses system notification to notify of current temperature.
16
- # Currently works/tested only on Linux
17
- module Notification
18
- def self.notify
19
- temp = Sensor.temperature
20
-
21
- n = Libnotify.new(
22
- summary: 'Temperature',
23
- body: "Your computer's temperature is now #{temp} °C",
24
- timeout: 1.5,
25
- append: true
26
- )
27
-
28
- n.urgency = (temp > 80) ? :critical : :normal
29
-
30
- n.show!
31
- end
32
- end
33
-
34
- # Module to write the cronjob
35
- module Cronify
36
- # Tries to write the crontab and exits with the appropiate code
37
- def self.schedule
38
- cron = <<-END.gsub(/^ {8}/, '')
39
- # Gibil temperature notification
40
- 0,10,20,30,40,50 * * * * /bin/bash -l -c 'gibil job'
41
- # End Gibil temperature notification
42
- END
43
-
44
- require 'tempfile'
45
- file = Tempfile.new('temp_cronfile')
46
- file.write(cron)
47
- file.close
48
-
49
- run(file)
50
- end
51
-
52
- def self.run(file)
53
- if system("crontab #{file.path}")
54
- puts 'INFO: Wrote crontab file'
55
- file.unlink
56
- exit(0)
57
- else
58
- warn 'ERROR: Failed to write crontab'
59
- file.unlink
60
- exit(1)
61
- end
62
- end
63
-
64
- def self.temp_path(cron)
65
- file.path
66
- end
67
- end
68
- end
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'libnotify'
4
+
5
+ module Gibil
6
+ # Temperature Sensor interface.
7
+ # Currently works/tested only on Linux
8
+ module Sensor
9
+ # == Returns:
10
+ # A float value of the system's temperature
11
+ def self.temperature
12
+ File.read('/sys/class/hwmon/hwmon0/temp1_input').to_f / 1000
13
+ end
14
+ end
15
+
16
+ # Uses system notification to notify of current temperature.
17
+ # Currently works/tested only on Linux
18
+ module Notification
19
+ def self.notify
20
+ temp = Sensor.temperature
21
+
22
+ n = Libnotify.new(
23
+ summary: 'Temperature',
24
+ body: "Your computer's temperature is now #{temp} °C",
25
+ timeout: 1.5,
26
+ append: true
27
+ )
28
+
29
+ n.urgency = temp > 80 ? :critical : :normal
30
+
31
+ n.show!
32
+ end
33
+ end
34
+
35
+ # Module to write the cronjob
36
+ module Cronify
37
+ # Tries to write the crontab and exits with the appropiate code
38
+ def self.schedule
39
+ cron = <<-END.gsub(/^ {8}/, '')
40
+ # Gibil temperature notification
41
+ 0,10,20,30,40,50 * * * * /bin/bash -l -c 'gibil job'
42
+ # End Gibil temperature notification
43
+ END
44
+
45
+ require 'tempfile'
46
+ file = Tempfile.new('temp_cronfile')
47
+ file.write(cron)
48
+ file.close
49
+
50
+ run(file)
51
+ end
52
+
53
+ def self.run(file)
54
+ if system("crontab #{file.path}")
55
+ puts 'INFO: Wrote crontab file'
56
+ file.unlink
57
+ exit(0)
58
+ else
59
+ warn 'ERROR: Failed to write crontab'
60
+ file.unlink
61
+ exit(1)
62
+ end
63
+ end
64
+ end
65
+ end
metadata CHANGED
@@ -1,64 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gibil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
5
- prerelease:
4
+ version: 0.1.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Fernando Briano
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-17 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: libnotify
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0.8'
19
+ version: 0.9.3
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0.8'
26
+ version: 0.9.3
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: minitest
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '5.3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: '5.3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rubocop
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0.19'
47
+ version: 0.47.1
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '0.19'
54
+ version: 0.47.1
62
55
  description: Show a notification of your computer's temperature. It can be programmed
63
56
  as a cronjob, so you can be notified when the temperature is high.
64
57
  email: fernando@picandocodigo.net
@@ -67,32 +60,31 @@ executables:
67
60
  extensions: []
68
61
  extra_rdoc_files: []
69
62
  files:
70
- - lib/gibil.rb
71
63
  - bin/gibil
64
+ - lib/gibil.rb
72
65
  homepage: https://github.com/picandocodigo/gibil
73
66
  licenses:
74
- - GPL-3
67
+ - GPL-3.0
68
+ metadata: {}
75
69
  post_install_message:
76
70
  rdoc_options: []
77
71
  require_paths:
78
72
  - lib
79
73
  required_ruby_version: !ruby/object:Gem::Requirement
80
- none: false
81
74
  requirements:
82
- - - ! '>='
75
+ - - ">="
83
76
  - !ruby/object:Gem::Version
84
77
  version: '0'
85
78
  required_rubygems_version: !ruby/object:Gem::Requirement
86
- none: false
87
79
  requirements:
88
- - - ! '>='
80
+ - - ">="
89
81
  - !ruby/object:Gem::Version
90
82
  version: '0'
91
83
  requirements: []
92
84
  rubyforge_project:
93
- rubygems_version: 1.8.23
85
+ rubygems_version: 2.6.10
94
86
  signing_key:
95
- specification_version: 3
96
- summary: A gem to notify you of system temperature
87
+ specification_version: 4
88
+ summary: A gem to notify you of system temperature for Linux
97
89
  test_files: []
98
90
  has_rdoc: