Module: Grouse
- Defined in:
- lib/grouse.rb
Overview
module grouse many functions.
Class Method Summary collapse
-
.core_version ⇒ Object
grouse version.
- .eq_socket ⇒ Object
-
.gem_version ⇒ Object
Using, rubygems version.
- .ipaddress_certification(gs_udp_socket, gs_list_socket) ⇒ Object
- .koyomi ⇒ Object
- .list_socket ⇒ Object
-
.pg_version ⇒ Object
libgroonga version in pgroonga.
-
.recommender_circuit(number_failures, within_times) ⇒ Object
BrokenCircuit.
- .udp_socket ⇒ Object
- .validation_check(card_naming, members_card, equal_password) ⇒ Object
-
.version ⇒ Object
version number x.x.
Class Method Details
.core_version ⇒ Object
grouse version
140 141 142 |
# File 'lib/grouse.rb', line 140 def core_version '1.1.7.1'.to_s end |
.eq_socket ⇒ Object
25 26 27 28 29 |
# File 'lib/grouse.rb', line 25 def eq_socket Socket.ip_address_list.find do |ai| ai.ipv4? && !ai.ipv4_loopback? end.ip_address end |
.gem_version ⇒ Object
Using, rubygems version
52 53 54 55 56 |
# File 'lib/grouse.rb', line 52 def gem_version gversion = 'gem -v' stdout_rb, stderr_rb, status_rb = Open3.capture3(gversion) version = stdout_rb.to_s end |
.ipaddress_certification(gs_udp_socket, gs_list_socket) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/grouse.rb', line 119 def ipaddress_certification(gs_udp_socket, gs_list_socket) begin gs_udp_socket = udp_socket gs_list_socket = list_socket unless "#{gs_udp_socket}" == "#{gs_list_socket}" puts "#{gs_udp_socket} == #{gs_list_socket}" puts 'Something other than an IP address was matched.' return else puts 'Passed, ip address specification.' end rescue StandardError => s puts s.backtrace tanraku_execute ensure GC.auto_compact end end |
.koyomi ⇒ Object
31 32 33 34 35 |
# File 'lib/grouse.rb', line 31 def koyomi dt = Time.new.getlocal('+09:00') week = %w(日 月 火 水 木 金 土)[dt.wday] @himekuri = "#{dt.year}年" + "#{dt.month}月" + "#{dt.day}日" + ' : '.to_s + "#{dt.hour}時"+"#{dt.min}分"+"#{dt.sec}秒" + ' : '.to_s + week + "曜日" end |
.list_socket ⇒ Object
19 20 21 22 23 |
# File 'lib/grouse.rb', line 19 def list_socket Socket.ip_address_list.find do |intf| intf.ipv4? && !intf.ipv4_loopback? && !intf.ipv4_multicast? end.ip_address end |
.pg_version ⇒ Object
libgroonga version in pgroonga
38 39 40 41 42 43 44 |
# File 'lib/grouse.rb', line 38 def pg_version sql = "SHOW pgroonga.libgroonga_version;" query = ActiveRecord::Base.connection.select_all(sql).to_a pg_string = (query).to_s.gsub(/[^A-Za-z]/, ' ').rstrip pg_number = (query).to_s.gsub(/[^.0-9A-Za-z]/, '').rstrip.delete("A-Za-z").delete_prefix(".").delete_suffix(".") @pg_version = pg_string + " " + pg_number end |
.recommender_circuit(number_failures, within_times) ⇒ Object
BrokenCircuit
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/grouse.rb', line 59 def recommender_circuit(number_failures, within_times) @num_failures = number_failures @within = within_times @failures = [].to_s if @failures >= @num_failures.to_s cutoff = Time.now - @within.to_i @failures.split.reject!{|t| t < cutoff.to_s} return if @failures.length >= @num_failures.to_i end begin yield rescue @failures.to_i << (Time.now).to_i @failures = nil end end |
.udp_socket ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/grouse.rb', line 11 def udp_socket udp = UDPSocket.new udp.connect("128.0.0.0", 7) adrs = Socket.unpack_sockaddr_in(udp.getsockname)[1] udp.close adrs end |
.validation_check(card_naming, members_card, equal_password) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/grouse.rb', line 78 def validation_check(card_naming, members_card, equal_password) begin card_name = card_naming memberscard = members_card member = File.(memberscard + card_name) eq_pass = equal_password unless File.exist?(member) puts 'Not found ' + card_name.to_s + ', Exec tanraku.' tanraku_execute else File.open(member) do |f| while (name = f.gets) name_c = name.chomp unless name_c =~ /#{eq_pass}/o puts 'No, Match Word in ' + card_name.to_s exit! else puts "Match word contain #{eq_pass} in #{card_name}" return end end if f.eof? f.close elsif !f.eof return end end end rescue Exception => cep puts cep.backtrace puts cep.backtrace_locations tanraku_execute rescue StandardError => a puts a.backtrace tanraku_execute ensure GC.auto_compact end end |
.version ⇒ Object
version number x.x
47 48 49 |
# File 'lib/grouse.rb', line 47 def version @version = ENV['NYASOCOMSUN_VERSION'] end |