kanamei-keystone 0.0.22 → 0.0.23

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.
@@ -11,7 +11,7 @@ autoload :Moji , 'moji'
11
11
 
12
12
  module Keystone
13
13
 
14
- VERSION = '0.0.22'
14
+ VERSION = '0.0.23'
15
15
 
16
16
  autoload :StringUtil , 'keystone/string_util'
17
17
  autoload :Batch , 'keystone/batch'
@@ -4,6 +4,7 @@ module Keystone
4
4
  require 'keystone/core_ext/uri'
5
5
  require 'keystone/core_ext/tempfile'
6
6
  require 'keystone/core_ext/dir'
7
+ require 'keystone/core_ext/ipaddr'
7
8
  require 'keystone/core_ext/object'
8
9
  require 'keystone/core_ext/array'
9
10
  end
@@ -0,0 +1 @@
1
+ このフォルダ以下は実際は別プロジェクトにすべきなんでしょうが、、、、まぁめんどくさいのでまずはここにおいておきます
@@ -3,7 +3,6 @@
3
3
  require 'rubygems'
4
4
  require 'keystone'
5
5
  require 'pit'
6
- require 'pp'
7
6
 
8
7
  include Keystone::Batch::Base
9
8
 
@@ -40,7 +39,6 @@ BODY
40
39
  end
41
40
 
42
41
  execute() do
43
- info "start batch"
44
42
  limit = 80
45
43
  limit = Integer(ARGV[0]) if ARGV.size > 0
46
44
 
@@ -52,6 +50,5 @@ execute() do
52
50
  break
53
51
  end
54
52
  }
55
- info "finish batch"
56
53
  end
57
54
 
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'activesupport'
5
+ require 'meow'
6
+ require 'pit'
7
+ require 'keystone'
8
+
9
+ config = Pit.get("notice")
10
+ MAIL_TO = config["mailto"]
11
+ MAIL_FROM = config["mailfrom"]
12
+
13
+ def ppp(message)
14
+ print message
15
+ STDOUT.flush
16
+ end
17
+
18
+ class GrowlMessage
19
+ attr_accessor :execute_at,:message
20
+ def initialize
21
+ @message = ""
22
+ @execute_at = Time.now
23
+ end
24
+ end
25
+
26
+ if ARGV.size > 0 && ARGV[0] == "-f"
27
+ message = Marshal.load(File.open(ARGV[1]))
28
+ File.delete(ARGV[1])
29
+ loop do
30
+ break if message.execute_at < Time.now
31
+ sleep 30
32
+ end
33
+
34
+ begin
35
+ Keystone::Mail::Send.send(MAIL_FROM,MAIL_TO,message.message,message.message)
36
+ rescue
37
+ end
38
+
39
+ meep = Meow.new("growl_notify")
40
+ option = {:sticky=>true,:priority=>1}
41
+ message_text = "#{message.execute_at.strftime("%Y/%m/%d %H:%M:%S")}\n#{message.message}"
42
+ meep.notify("growl_notify",message_text,option)
43
+ exit
44
+ end
45
+
46
+ INPUT_TIME_MESSAGE = "when?(NN(minutes later) or NNh(hours later) or HH:MM(time format)):"
47
+ message = GrowlMessage.new
48
+
49
+ ppp "message:"
50
+ STDIN.each_line do |line|
51
+ line.chomp!
52
+ exit if line == ""
53
+ message.message = line
54
+ break
55
+ end
56
+
57
+ ppp INPUT_TIME_MESSAGE
58
+ STDIN.each_line do |line|
59
+ line.chomp!
60
+ minutes = 5
61
+ begin
62
+ minutes = Integer(line)
63
+ message.execute_at += minutes * 60
64
+ break
65
+ rescue
66
+ begin
67
+ if line =~ /(\d+):(\d+)/
68
+ hour,minute= Integer($1),Integer($2)
69
+ execute_at_candidate = message.execute_at.change(:hour => hour,:min => minute)
70
+ if execute_at_candidate < message.execute_at
71
+ execute_at_candidate += 60 * 60 * 24
72
+ end
73
+ message.execute_at = execute_at_candidate
74
+ break
75
+ elsif line =~ /(\d+)h/
76
+ hours = Integer($1)
77
+ message.execute_at += hours * 60 * 60
78
+ break
79
+ end
80
+ rescue => e
81
+ puts e
82
+ end
83
+ end
84
+ puts "invalid format"
85
+ ppp INPUT_TIME_MESSAGE
86
+ end
87
+
88
+ path = "/tmp/.gw_message.#{Time.now.tv_usec}"
89
+ Marshal.dump(message,File.new(path, 'w'))
90
+ cmd = "notice -f #{path} &"
91
+ #puts cmd
92
+ system cmd
93
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanamei-keystone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - kanamei
@@ -22,7 +22,10 @@ extensions: []
22
22
  extra_rdoc_files: []
23
23
 
24
24
  files:
25
- - bin/disk_size_check.rb
25
+ - util/bin
26
+ - util/bin/disk_size_check.rb
27
+ - util/bin/notice
28
+ - util/README
26
29
  - example/batch_sample.rb
27
30
  - example/os.rb
28
31
  - example/string_util.rb