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.
- .koyomi ⇒ Object
- .list_socket ⇒ Object
-
.pg_version ⇒ Object
libgroonga version in pgroonga.
-
.recommender_circuit(number_failure, 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
115 116 117 |
# File 'lib/grouse.rb', line 115 def core_version '1.1.4'.to_s end |
.eq_socket ⇒ Object
24 25 26 27 28 |
# File 'lib/grouse.rb', line 24 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
51 52 53 54 55 |
# File 'lib/grouse.rb', line 51 def gem_version gversion = 'gem -v' stdout_rb, stderr_rb, status_rb = Open3.capture3(gversion) version = stdout_rb.to_s end |
.koyomi ⇒ Object
30 31 32 33 34 |
# File 'lib/grouse.rb', line 30 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
18 19 20 21 22 |
# File 'lib/grouse.rb', line 18 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
37 38 39 40 41 42 43 |
# File 'lib/grouse.rb', line 37 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_failure, within_times) ⇒ Object
BrokenCircuit
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/grouse.rb', line 58 def recommender_circuit(number_failure, within_times) @num_failure = number_failure @within = within_times @failure = [].to_s if @failure >= @num_failure.to_s cutoff = Time.now - @within.to_i @failure.split.reject!{|t| t < cutoff.to_s} return if @failure.length >= @num_failure.to_i end begin yield rescue @failure.to_i << (Time.now).to_i nil end end |
.udp_socket ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/grouse.rb', line 10 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
77 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 |
# File 'lib/grouse.rb', line 77 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 tanraku_execute end end end rescue StandardError => a puts a.backtrace tanraku_execute ensure GC.auto_compact end end |
.version ⇒ Object
version number x.x
46 47 48 |
# File 'lib/grouse.rb', line 46 def version @version = ENV['NYASOCOMSUN_VERSION'] end |