SHIBATA Hiroshi
null****@okkez*****
2014年 2月 28日 (金) 19:10:55 JST
SHIBATA Hiroshi 2014-02-28 19:10:55 +0900 (Fri, 28 Feb 2014) New Revision: 96f7014dcd8ba6540befc999828c728e508430e5 https://github.com/hiki/hiki/commit/96f7014dcd8ba6540befc999828c728e508430e5 Message: convert Ruby 1.9 style syntax Modified files: hiki.rb hiki/db/flatfile.rb hiki/db/rdb.rb hiki/db/tmarshal.rb hiki/farm/wiki.rb hiki/image_size.rb hiki/interwiki.rb hiki/plugin.rb hiki/repos/plain.rb hiki/util.rb misc/plugin/its.rb misc/plugin/todo.rb misc/webrick/hikilet.rb spec/spec_50bayes_filter.rb spec/spec_bayes_filter.rb spec/spec_filter.rb style/default/parser.rb test/acceptance/basic_scenario_test.rb test/ptstore_test.rb tool/convert.rb Modified: hiki.rb (+4 -4) =================================================================== --- hiki.rb 2014-02-28 19:00:09 +0900 (8730a3c) +++ hiki.rb 2014-02-28 19:10:55 +0900 (56ea73c) @@ -11,12 +11,12 @@ app = Rack::Builder.new{ use Rack::ShowExceptions #use Rack::ShowStatus use Rack::CommonLogger - use Rack::Static, :urls => ['/theme'], :root => '.' + use Rack::Static, urls: ['/theme'], root: '.' run Hiki::App.new }.to_app options = { - :Port => 9292, - :Host => '0.0.0.0', - :AccessLog => [] + Port: 9292, + Host: '0.0.0.0', + AccessLog: [] } Rack::Handler.default.run(app, options) Modified: hiki/db/flatfile.rb (+8 -8) =================================================================== --- hiki/db/flatfile.rb 2014-02-28 19:00:09 +0900 (59898ee) +++ hiki/db/flatfile.rb 2014-02-28 19:10:55 +0900 (6f5a3b6) @@ -32,7 +32,7 @@ module Hiki if exist?(page) return nil if md5 != md5hex(page) if update_timestamp - FileUtils.copy(filename, backupdir(page), { :preserve => true }) + FileUtils.copy(filename, backupdir(page), { preserve: true }) end end create_info_default(page) unless info_exist?(page) @@ -49,7 +49,7 @@ module Hiki def unlink(page) if exist?(page) begin - FileUtils.copy(textdir(page), backupdir(page), { :preserve => true }) + FileUtils.copy(textdir(page), backupdir(page), { preserve: true }) delete_info(page) File.unlink(textdir(page)) rescue @@ -228,12 +228,12 @@ module Hiki end def default - { :count => 0, - :last_modified => Time.now, - :freeze => false, - :references => [], - :keyword => [], - :title => '', + { count: 0, + last_modified: Time.now, + freeze: false, + references: [], + keyword: [], + title: '', } end Modified: hiki/db/rdb.rb (+13 -13) =================================================================== --- hiki/db/rdb.rb 2014-02-28 19:00:09 +0900 (327cdb4) +++ hiki/db/rdb.rb 2014-02-28 19:10:55 +0900 (93b36a3) @@ -189,24 +189,24 @@ module Hiki end def default - { :count => 0, - :last_modified => Time::now, - :freeze => false, - :references => [], - :keyword => [], - :title => "", + { count: 0, + last_modified: Time::now, + freeze: false, + references: [], + keyword: [], + title: "", } end def make_info_hash(hash) { - :title => hash[:title] || "", - :last_modified => make_time(hash[:last_modified]), - :keyword => (hash[:keyword] || "").split(/\n/), - :references => (hash[:references] || "").split(/\n/), - :editor => hash[:editor], - :freeze => (hash[:freeze] == 1), - :count => hash[:count], + title: hash[:title] || "", + last_modified: make_time(hash[:last_modified]), + keyword: (hash[:keyword] || "").split(/\n/), + references: (hash[:references] || "").split(/\n/), + editor: hash[:editor], + freeze: (hash[:freeze] == 1), + count: hash[:count], } end Modified: hiki/db/tmarshal.rb (+1 -1) =================================================================== --- hiki/db/tmarshal.rb 2014-02-28 19:00:09 +0900 (0279b26) +++ hiki/db/tmarshal.rb 2014-02-28 19:10:55 +0900 (cc4b325) @@ -47,5 +47,5 @@ module TMarshal end if __FILE__ == $0 - puts TMarshal.dump({:age => 22, :lang => 'Ruby', :man => true, :day => Time.now}) + puts TMarshal.dump({age: 22, lang: 'Ruby', man: true, day: Time.now}) end Modified: hiki/farm/wiki.rb (+2 -2) =================================================================== --- hiki/farm/wiki.rb 2014-02-28 19:00:09 +0900 (b861be8) +++ hiki/farm/wiki.rb 2014-02-28 19:10:55 +0900 (f821310) @@ -36,8 +36,8 @@ module Hiki @pages_num = pages.size @pages = pages.reverse[0..9].collect do |page| { - :name => File.basename(page), - :mtime => File.mtime(page), + name: File.basename(page), + mtime: File.mtime(page), } end end Modified: hiki/image_size.rb (+1 -1) =================================================================== --- hiki/image_size.rb 2014-02-28 19:00:09 +0900 (4398e85) +++ hiki/image_size.rb 2014-02-28 19:10:55 +0900 (3a85a98) @@ -92,7 +92,7 @@ class ImageSize def get_size if get_height && get_width - {:width => get_width, :height => get_height} + {width: get_width, height: get_height} else nil end Modified: hiki/interwiki.rb (+1 -1) =================================================================== --- hiki/interwiki.rb 2014-02-28 19:00:09 +0900 (790798d) +++ hiki/interwiki.rb 2014-02-28 19:10:55 +0900 (9f93d8a) @@ -16,7 +16,7 @@ module Hiki @interwiki_names = {} (str || '').scan( INTERWIKI_NAME_RE ) do |i| e = i.size > 2 ? i[2] : 'none' - @interwiki_names[i[0]] = {:url => i[1], :encoding => e} + @interwiki_names[i[0]] = {url: i[1], encoding: e} end end Modified: hiki/plugin.rb (+4 -4) =================================================================== --- hiki/plugin.rb 2014-02-28 19:00:09 +0900 (bbab14b) +++ hiki/plugin.rb 2014-02-28 19:10:55 +0900 (dbe6065) @@ -289,7 +289,7 @@ module Hiki src.sub!(/\n*\z/, "\n") result =****@db*****(page, src, md5, update_timestamp) if result - @db.set_attribute( page, :editor => @user ) + @db.set_attribute( page, editor: @user ) @db.delete_cache( page ) begin update_proc @@ -379,9 +379,9 @@ module Hiki def add_plugin_command(command, display_text, option = {}) @plugin_command << command - @plugin_menu << {:command => command, - :display_text => display_text, - :option => option} if display_text + @plugin_menu << {command: command, + display_text: display_text, + option: option} if display_text nil end Modified: hiki/repos/plain.rb (+1 -1) =================================================================== --- hiki/repos/plain.rb 2014-02-28 19:00:09 +0900 (82ca243) +++ hiki/repos/plain.rb 2014-02-28 19:10:55 +0900 (51d0acb) @@ -38,7 +38,7 @@ module Hiki dir = "#{@root}/#{wiki.untaint}/#{escape(page).untaint}" Dir.mkdir(dir) if not File.exists?(dir) - FileUtils.rm("#{dir}/.removed", {:force => true}) + FileUtils.rm("#{dir}/.removed", {force: true}) rev = last_revision(page) + 1 Modified: hiki/util.rb (+10 -10) =================================================================== --- hiki/util.rb 2014-02-28 19:00:09 +0900 (d8fea2e) +++ hiki/util.rb 2014-02-28 19:10:55 +0900 (64ad0ef) @@ -161,16 +161,16 @@ module Hiki dst_doc = Document.new( dst, @charset, CharString.guess_eol($/) ) diff = compare_by_line_word( src_doc, dst_doc ) overriding_tags = { - :start_common => '', - :end_common => '', - :start_del => '<del class="deleted">', - :end_del => '</del>', - :start_add => '<ins class="added">', - :end_add => '</ins>', - :start_before_change => '<del class="deleted">', - :end_before_change => '</del>', - :start_after_change => '<ins class="added">', - :end_after_change => '</ins>', + start_common: '', + end_common: '', + start_del: '<del class="deleted">', + end_del: '</del>', + start_add: '<ins class="added">', + end_add: '</ins>', + start_before_change: '<del class="deleted">', + end_before_change: '</del>', + start_after_change: '<ins class="added">', + end_after_change: '</ins>', } if digest return View.new( diff, src.encoding, src.eol ).to_html_digest(overriding_tags, false).join.gsub( %r|<br />|, '' ).gsub( %r|\n</ins>|, "</ins>\n" ) #" Modified: misc/plugin/its.rb (+9 -9) =================================================================== --- misc/plugin/its.rb 2014-02-28 19:00:09 +0900 (3e1fba9) +++ misc/plugin/its.rb 2014-02-28 19:10:55 +0900 (131e533) @@ -131,15 +131,15 @@ def its_parse_ticket( page ) version = /:Version:(.*)/ =~ text ? $1.strip : '' milestone = /:Milestone:(.*)/ =~ text ? $1.strip : '' - { :num => num, - :summary => summary, - :priority => priority, - :reporter => reporter, - :status => status, - :assigned => assigned, - :created => created, - :version => version, - :milestone => milestone, } + { num: num, + summary: summary, + priority: priority, + reporter: reporter, + status: status, + assigned: assigned, + created: created, + version: version, + milestone: milestone, } rescue nil end Modified: misc/plugin/todo.rb (+1 -1) =================================================================== --- misc/plugin/todo.rb 2014-02-28 19:00:09 +0900 (375ab39) +++ misc/plugin/todo.rb 2014-02-28 19:10:55 +0900 (db2307d) @@ -8,7 +8,7 @@ def todo(p, num = 8) n =****@db*****(unescape_html(p)) || '' n.scan(todo_re) do |i| - todo_list << {:priority => $1.to_i, :todo => $2} + todo_list << {priority: $1.to_i, todo: $2} end todo_list.sort! {|a, b| b[:priority] <=> a[:priority]} Modified: misc/webrick/hikilet.rb (+2 -2) =================================================================== --- misc/webrick/hikilet.rb 2014-02-28 19:00:09 +0900 (55af1bb) +++ misc/webrick/hikilet.rb 2014-02-28 19:10:55 +0900 (0b6a96f) @@ -139,8 +139,8 @@ if __FILE__ == $0 ENV['SERVER_PORT'] ||= base_url.port.to_s logger = WEBrick::Log::new(STDERR, WEBrick::Log::INFO) server = WEBrick::HTTPServer.new({ - :Port => base_url.port, - :Logger => logger, + Port: base_url.port, + Logger: logger, }) # prepare $LOAD_PATH Modified: spec/spec_50bayes_filter.rb (+12 -12) =================================================================== --- spec/spec_50bayes_filter.rb 2014-02-28 19:00:09 +0900 (7e58ba4) +++ spec/spec_50bayes_filter.rb 2014-02-28 19:10:55 +0900 (09d2dde) @@ -22,13 +22,13 @@ class << Object.new @base_url = "http://www.example.org/hiki.cgi" @opt = {} @conf = stub("conf", - :data_path=>@tmpdir, - :cache_path=>"#{@tmpdir}/cache", - :bayes_threshold=>nil, - :filter_type=>nil, - :cgi_name=>@base_url, - :index_url=>@base_url, - :null_object=>false) + data_path:@tmpdir, + cache_path:"#{@tmpdir}/cache", + bayes_threshold:nil, + filter_type:nil, + cgi_name:@base_url, + index_url:@base_url, + null_object:false) @conf.should_receive("[]".intern).any_number_of_times{|k| @opt[k]} @conf.should_receive("[]=".intern).any_number_of_times{|k, v| @opt[k]=v} BayesFilter.init(@conf) @@ -41,13 +41,13 @@ class << Object.new ex.before do @params = Hash.new{|h, k| h[k]=[]} @cgi = stub("cgi", - :params=>@params, - :request_method=>"POST", - :null_object=>false) + params:@params, + request_method:"POST", + null_object:false) @pages = [] @db = stub("db", - :pages=>@pages, - :null_object=>false) + pages:@pages, + null_object:false) @c = BayesFilterConfig.new(@cgi, @conf, "saveconf", @db) end end Modified: spec/spec_bayes_filter.rb (+6 -6) =================================================================== --- spec/spec_bayes_filter.rb 2014-02-28 19:00:09 +0900 (11f578d) +++ spec/spec_bayes_filter.rb 2014-02-28 19:10:55 +0900 (d6f3bb1) @@ -17,12 +17,12 @@ module SetupBayesFilter @opt = { } @conf = stub("Hiki::Config", - :data_path=>@tmpdir, - :cache_path=>"#{@tmpdir}/cache", - :bayes_threshold=>nil, - :site_name=>"SiteName", - :index_url=>@index_url, - :null_object=>false) + data_path:@tmpdir, + cache_path:"#{@tmpdir}/cache", + bayes_threshold:nil, + site_name:"SiteName", + index_url:@index_url, + null_object:false) @conf.should_receive("[]".intern).any_number_of_times{|k| @opt[k]} @bf = Hiki::Filter::BayesFilter.init(@conf) end Modified: spec/spec_filter.rb (+4 -4) =================================================================== --- spec/spec_filter.rb 2014-02-28 19:00:09 +0900 (da0e1b1) +++ spec/spec_filter.rb 2014-02-28 19:10:55 +0900 (78a94f9) @@ -21,10 +21,10 @@ describe Hiki::Filter, "when error raised in filtering" do raise "ERROR" end - @conf = stub("conf", :null_object=>true) - @cgi = stub("cgi", :null_object=>true) - @plugin = stub("plugin", :null_object=>true) - @db = stub("db", :null_object=>true) + @conf = stub("conf", null_object:true) + @cgi = stub("cgi", null_object:true) + @plugin = stub("plugin", null_object:true) + @db = stub("db", null_object:true) Hiki::Filter.init(@conf, @cgi, @plugin, @db) end Modified: style/default/parser.rb (+2 -2) =================================================================== --- style/default/parser.rb 2014-02-28 19:00:09 +0900 (6f1be97) +++ style/default/parser.rb 2014-02-28 19:10:55 +0900 (92b1132) @@ -25,8 +25,8 @@ module Hiki end def parse( s, top_level = 2 ) - HikiDoc.to_html( s, :level => top_level, - :use_wiki_name => @use_wiki_name ) + HikiDoc.to_html( s, level: top_level, + use_wiki_name: @use_wiki_name ) end end end Modified: test/acceptance/basic_scenario_test.rb (+3 -3) =================================================================== --- test/acceptance/basic_scenario_test.rb 2014-02-28 19:00:09 +0900 (e2c8db2) +++ test/acceptance/basic_scenario_test.rb 2014-02-28 19:10:55 +0900 (732da40) @@ -23,9 +23,9 @@ module BasicScenario def test_create_new_page visit("/?c=create") - fill_in("key", :with => "NewPage") + fill_in("key", with: "NewPage") click_button("New") - fill_in("contents", :with => "Test Test") + fill_in("contents", with: "Test Test") click_button("Save") click_link("Click here!") @@ -57,7 +57,7 @@ Hikiの書式はオリジナルWikiに似てますので、オリジナルの書 書式もありますので、詳細についてはTextFormattingRulesを参照してください。 TEXT end - fill_in("contents", :with => "FrontPage contents") + fill_in("contents", with: "FrontPage contents") click_button("Save") click_link("Click here!") assert_title("FrontPage") Modified: test/ptstore_test.rb (+4 -4) =================================================================== --- test/ptstore_test.rb 2014-02-28 19:00:09 +0900 (e5abb63) +++ test/ptstore_test.rb 2014-02-28 19:10:55 +0900 (0a357ed) @@ -11,10 +11,10 @@ class PTStore_Unit_Tests < Test::Unit::TestCase @db = PTStore.new(tempfile.path) @db.transaction do - @db['Taro'] = {:age => 22, :lang => 'Ruby', :man => true, :day => Time.now} - @db['Hanako'] = {:age => 23, :lang => 'Perl', :man => false, :day => Time.now} - @db['Jirou'] = {:age => 15, :lang => 'Smalltalk', :man => true, :day => Time.now} - @db['Rika'] = {:age => 4, :lang => 'Lisp', :man => false, :day => Time.now} + @db['Taro'] = {age: 22, lang: 'Ruby', man: true, day: Time.now} + @db['Hanako'] = {age: 23, lang: 'Perl', man: false, day: Time.now} + @db['Jirou'] = {age: 15, lang: 'Smalltalk', man: true, day: Time.now} + @db['Rika'] = {age: 4, lang: 'Lisp', man: false, day: Time.now} end end Modified: tool/convert.rb (+1 -1) =================================================================== --- tool/convert.rb 2014-02-28 19:00:09 +0900 (6b24bd2) +++ tool/convert.rb 2014-02-28 19:10:55 +0900 (c63763b) @@ -111,7 +111,7 @@ def encode(text, input_encoding, output_encoding, nkf) if nkf NKF.nkf("-m0 --ic=#{input_encoding} --oc=#{output_encoding}", text) else - text.dup.encode!(output_encoding, input_encoding, :invalid => :replace, :undef => :replace) + text.dup.encode!(output_encoding, input_encoding, invalid: :replace, undef: :replace) end end