sfc_ikiteru 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/History.txt ADDED
@@ -0,0 +1,3 @@
1
+ === 0.0.1 2011-03-24
2
+
3
+ * created
data/Manifest.txt ADDED
@@ -0,0 +1,14 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ lib/sfc_ikiteru.rb
6
+ script/console
7
+ script/destroy
8
+ script/generate
9
+ spec/sfc_ikiteru_spec.rb
10
+ spec/spec.opts
11
+ spec/spec_helper.rb
12
+ tasks/rspec.rake
13
+ samples/sample.rb
14
+ bin/sfc_ikiteru
data/README.rdoc ADDED
@@ -0,0 +1,49 @@
1
+ = sfc_ikiteru
2
+
3
+ * http://github.com/shokai/sfc_ikiteru
4
+
5
+ == DESCRIPTION:
6
+
7
+ check status of Keio Univ SFC.
8
+
9
+
10
+ == SYNOPSIS:
11
+
12
+ require 'sfc_ikiteru'
13
+ per, details = SfcIkiteru.ikiteru
14
+ p per
15
+ p details
16
+
17
+
18
+ == REQUIREMENTS:
19
+
20
+ * Ruby 1.8.7
21
+
22
+ == INSTALL:
23
+
24
+ * gem install sfc_ikiteru
25
+
26
+ == LICENSE:
27
+
28
+ (The MIT License)
29
+
30
+ Copyright (c) 2011 Sho Hashimoto
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining
33
+ a copy of this software and associated documentation files (the
34
+ 'Software'), to deal in the Software without restriction, including
35
+ without limitation the rights to use, copy, modify, merge, publish,
36
+ distribute, sublicense, and/or sell copies of the Software, and to
37
+ permit persons to whom the Software is furnished to do so, subject to
38
+ the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be
41
+ included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
44
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
46
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
47
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
48
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
49
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/sfc_ikiteru'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'sfc_ikiteru' do
14
+ self.developer 'Sho Hashimoto', 'hashimoto@shokai.org'
15
+ self.rubyforge_name = self.name # TODO this is default value
16
+ #self.extra_deps = [['activesupport','>= 2.0.2']]
17
+ self.extra_deps = [['rainbow']]
18
+
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
data/bin/sfc_ikiteru ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+ require 'rubygems'
4
+ #require File.dirname(__FILE__)+'/../lib/sfc_ikiteru'
5
+ require 'sfc_ikiteru'
6
+ require 'rainbow'
7
+
8
+ per, details = SfcIkiteru.ikiteru
9
+
10
+ print 'sfc_ikiteru => '
11
+ if per == 1
12
+ puts "生存率 #{(per*100).to_i}%".color(:green)
13
+ else
14
+ puts "生存率 #{(per*100).to_i}%".color(:magenta)
15
+ end
16
+ details.each{|i|
17
+ print "#{i[:host]} => "
18
+ if(i[:ping])
19
+ puts "正常です".color(:green)
20
+ else
21
+ puts "応答なし".color(:red)
22
+ end
23
+ }
@@ -0,0 +1,27 @@
1
+ require 'ping'
2
+
3
+ module SfcIkiteru
4
+ VERSION = '0.0.1'
5
+ def SfcIkiteru.servers
6
+ [
7
+ {:host => 'web.sfc.keio.ac.jp', :service => 'echo'},
8
+ {:host => 'ccz01.sfc.keio.ac.jp', :service => 'echo'},
9
+ {:host => 'ccz02.sfc.keio.ac.jp', :service => 'echo'},
10
+ {:host => 'mail.sfc.keio.ac.jp', :service => 'echo'},
11
+ {:host => 'masui.sfc.keio.ac.jp', :service => 'http'}
12
+ ]
13
+ end
14
+
15
+ def SfcIkiteru.ikiteru(timeout=3)
16
+ results = Array.new
17
+ servers.each{|s|
18
+ results << {:host => s[:host], :ping => Ping.pingecho(s[:host], timeout, s[:service])}
19
+ }
20
+ count = 0
21
+ results.each{|i|
22
+ count+=1 if i[:ping] == true
23
+ }
24
+ per = count.to_f / results.size
25
+ return per, results
26
+ end
27
+ end
data/samples/sample.rb ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ #require File.dirname(__FILE__)+'/../lib/sfc_ikiteru'
4
+ require 'sfc_ikiteru'
5
+
6
+ per, details = SfcIkiteru.ikiteru
7
+ p per
8
+ p details
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/sfc_ikiteru.rb'}"
9
+ puts "Loading sfc_ikiteru gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ # Time to add your specs!
4
+ # http://rspec.info/
5
+ describe "Place your specs here" do
6
+
7
+ it "find this spec in spec directory" do
8
+ # violated "Be sure to write your specs"
9
+ end
10
+
11
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,10 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ gem 'rspec'
6
+ require 'spec'
7
+ end
8
+
9
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
+ require 'sfc_ikiteru'
data/tasks/rspec.rake ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sfc_ikiteru
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Sho Hashimoto
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-24 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rainbow
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: hoe
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 41
44
+ segments:
45
+ - 2
46
+ - 9
47
+ - 1
48
+ version: 2.9.1
49
+ type: :development
50
+ version_requirements: *id002
51
+ description: check status of Keio Univ SFC.
52
+ email:
53
+ - hashimoto@shokai.org
54
+ executables:
55
+ - sfc_ikiteru
56
+ extensions: []
57
+
58
+ extra_rdoc_files:
59
+ - History.txt
60
+ - Manifest.txt
61
+ files:
62
+ - History.txt
63
+ - Manifest.txt
64
+ - README.rdoc
65
+ - Rakefile
66
+ - lib/sfc_ikiteru.rb
67
+ - script/console
68
+ - script/destroy
69
+ - script/generate
70
+ - spec/sfc_ikiteru_spec.rb
71
+ - spec/spec.opts
72
+ - spec/spec_helper.rb
73
+ - tasks/rspec.rake
74
+ - samples/sample.rb
75
+ - bin/sfc_ikiteru
76
+ - .gemtest
77
+ has_rdoc: true
78
+ homepage: http://github.com/shokai/sfc_ikiteru
79
+ licenses: []
80
+
81
+ post_install_message:
82
+ rdoc_options:
83
+ - --main
84
+ - README.rdoc
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ none: false
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ hash: 3
93
+ segments:
94
+ - 0
95
+ version: "0"
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ hash: 3
102
+ segments:
103
+ - 0
104
+ version: "0"
105
+ requirements: []
106
+
107
+ rubyforge_project: sfc_ikiteru
108
+ rubygems_version: 1.6.2
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: check status of Keio Univ SFC.
112
+ test_files: []
113
+