• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Ruby GTK3移行後のメインリポジトリ


Commit MetaInfo

Revision2e0724aabae74c1570e6013373b2b99e8250060a (tree)
Time2016-12-11 14:43:42
AuthorShyouzou Sugitani <shy@user...>
CommiterShyouzou Sugitani

Log Message

coding style cleanup

Change Summary

Incremental Difference

--- a/lib/ninix/alias.rb
+++ b/lib/ninix/alias.rb
@@ -18,16 +18,18 @@ module Alias
1818
1919 def self.fatal(error)
2020 Logging::Logging.error('alias.rb: ' + error.to_s)
21- NConfig.null_config()
21+ NConfig.null_config
2222 end
2323
2424 def self.create_from_file(path)
25- f = File.open(path, 'rb')
2625 buf = []
27- while line = f.gets
28- buf << line.strip unless line.strip.empty?
29- end
30- return create_from_buffer(buf)
26+ File::open(path, 'rb') {|f|
27+ while line = f.gets
28+ line = line.strip
29+ buf << line unless line.empty?
30+ end
31+ }
32+ create_from_buffer(buf)
3133 end
3234
3335 def self.create_from_buffer(buf)
@@ -39,7 +41,7 @@ module Alias
3941 i += 1
4042 next if line.length.zero?
4143 match = re_alias.match(line)
42- if not match.nil?
44+ unless match.nil?
4345 name = line
4446 table = {}
4547 begin
@@ -110,6 +112,6 @@ module Alias
110112 dic[key] = value
111113 end
112114 end
113- return dic
115+ dic
114116 end
115117 end
--- a/lib/ninix/communicate.rb
+++ b/lib/ninix/communicate.rb
@@ -32,7 +32,7 @@ module Communicate
3232 end
3333
3434 def notify_all(event, references)
35- for sakura in @ghosts.keys()
35+ @ghosts.each_key do |sakura|
3636 sakura.enqueue_event(event, *references)
3737 end
3838 end
@@ -52,9 +52,7 @@ module Communicate
5252 event, name, selfname, shell_name,
5353 flag_break, communicate,
5454 sstp, notranslate, script, references)
55- if script.empty? and not ON_OTHER_EVENT.include?(event)
56- return
57- end
55+ return if script.empty? and not ON_OTHER_EVENT.include?(event)
5856 on_other_event = nil
5957 if ON_OTHER_EVENT.include?(event)
6058 if flag_break and ['OnClose', 'OnVanishSelected'].include?(event)
--- a/lib/ninix/config.rb
+++ b/lib/ninix/config.rb
@@ -25,26 +25,21 @@ module NConfig
2525 end
2626
2727 def self.create_from_file(path)
28- charset = 'CP932' # default
29- f = File.open(path, 'rb')
30- if f.read(3).bytes == [239, 187, 191] # "\xEF\xBB\xBF"
31- f.close
32- f = File.open(path, 'rb:BOM|UTF-8')
33- charset = 'UTF-8'
34- else
35- f.seek(0) # rewind
36- end
28+ has_bom = File.open(path) {|f| f.read(3) } == "\xEF\xBB\xBF"
29+ charset = has_bom ? 'UTF-8' : 'CP932'
3730 buf = []
38- while line = f.gets
39- buf << line.strip unless line.strip.empty?
40- end
41- f.close
31+ File.open(path, has_bom ? 'rb:BOM|UTF-8' : 'rb') {|f|
32+ while line = f.gets
33+ line = line.strip
34+ buf << line unless line.empty?
35+ end
36+ }
4237 return create_from_buffer(buf, :charset => charset)
4338 end
4439
4540 def self.create_from_buffer(buf, charset: 'CP932')
4641 dic = Config.new
47- for line in buf
42+ buf.each do |line|
4843 line = line.force_encoding(charset).encode(
4944 "UTF-8", :invalid => :replace, :undef => :replace)
5045 key, value = line.split(",", 2)
@@ -68,6 +63,6 @@ module NConfig
6863 end
6964
7065 def self.null_config()
71- NConfig::Config.new()
66+ NConfig::Config.new
7267 end
7368 end
--- a/lib/ninix/dll/textcopy.rb
+++ b/lib/ninix/dll/textcopy.rb
@@ -22,18 +22,18 @@ module Textcopy
2222 class Saori < DLL::SAORI
2323
2424 def initialize
25- super()
25+ super
2626 @clipboard = nil
2727 end
2828
2929 def setup
3030 @clipboard = Gtk::Clipboard.get('PRIMARY')
31- return 1
31+ 1
3232 end
3333
3434 def finalize
3535 @clipboard = nil
36- return 1
36+ 1
3737 end
3838
3939 def execute(argument)
--- a/lib/ninix/dll/yaya.rb
+++ b/lib/ninix/dll/yaya.rb
@@ -51,7 +51,7 @@ module Yaya
5151 result = 105
5252 end
5353 end
54- return result
54+ result
5555 end
5656
5757 def show_description
@@ -76,8 +76,7 @@ module Yaya
7676 )
7777 path[0, @dir.bytesize] = @dir
7878 @id = $_yaya.multi_load(path, @dir.bytesize)
79- ret = 1
80- return ret
79+ 1
8180 end
8281
8382 def unload
@@ -95,7 +94,7 @@ module Yaya
9594 rlen =[req_string.bytesize].pack("l!")
9695 ret = $_yaya.multi_request(@id, request, rlen)
9796 rlen, = rlen.unpack("l!")
98- return ret[0, rlen].to_s
97+ ret[0, rlen].to_s
9998 end
10099 end
101100 end