From: Kouhei S. <nu...@co...> - 2017-08-06 07:08:23
|
Kouhei Sutou 2017-08-06 16:08:03 +0900 (Sun, 06 Aug 2017) New Revision: 33cf5d90f9d2b3d9670c2d205e7ccedee35cfb41 https://github.com/ruby-gnome2/ruby-gnome2/commit/33cf5d90f9d2b3d9670c2d205e7ccedee35cfb41 Message: Merge pull request #1087 from cedlemo/vte3_regex Vte3 regex Patch by cedlemo. Thanks!!! |
From: cedlemo <nu...@co...> - 2017-08-06 07:08:23
|
cedlemo 2017-08-03 02:09:45 +0900 (Thu, 03 Aug 2017) New Revision: f70505e0a871bb748370dfe0c336400c926f9421 https://github.com/ruby-gnome2/ruby-gnome2/commit/f70505e0a871bb748370dfe0c336400c926f9421 Merged 33cf5d9: Merge pull request #1087 from cedlemo/vte3_regex Message: Fix copyright date Modified files: vte3/lib/vte3/regex.rb Modified: vte3/lib/vte3/regex.rb (+1 -1) =================================================================== --- vte3/lib/vte3/regex.rb 2017-08-03 02:08:16 +0900 (3d99735d2) +++ vte3/lib/vte3/regex.rb 2017-08-03 02:09:45 +0900 (dd3ddb07b) @@ -1,4 +1,4 @@ -# Copyright (C) 2015 Ruby-GNOME2 Project Team +# Copyright (C) 2017 Ruby-GNOME2 Project Team # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public |
From: cedlemo <nu...@co...> - 2017-08-06 07:08:23
|
cedlemo 2017-08-03 02:08:16 +0900 (Thu, 03 Aug 2017) New Revision: be9d3d51f45ef62df408bf986557ec806004d3ab https://github.com/ruby-gnome2/ruby-gnome2/commit/be9d3d51f45ef62df408bf986557ec806004d3ab Merged 33cf5d9: Merge pull request #1087 from cedlemo/vte3_regex Message: Add stupid and meaningless tests Added files: vte3/test/test-terminal-regex.rb Added: vte3/test/test-terminal-regex.rb (+37 -0) 100644 =================================================================== --- /dev/null +++ vte3/test/test-terminal-regex.rb 2017-08-03 02:08:16 +0900 (88b4dbf1f) @@ -0,0 +1,37 @@ +# Copyright (C) 2017 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +class TestTerminalRegex < Test::Unit::TestCase + include VteTestUtils + + def setup + @terminal = Vte::Terminal.new + end + + if Vte::Version.or_later?(0, 46) + def test_regex_for_match + regex = Vte::Regex.new("test", GLib::RegexCompileFlags::OPTIMIZE, :for_match => true) + assert_instance_of(Vte::Regex, regex) + end + + def test_regex_for_match_multiple_flags + flags = [:optimize, + :multiline] + regex = Vte::Regex.new("test", flags, :for_match => true) + assert_instance_of(Vte::Regex, regex) + end + end +end |
From: cedlemo <nu...@co...> - 2017-08-06 07:08:23
|
cedlemo 2017-08-03 02:07:48 +0900 (Thu, 03 Aug 2017) New Revision: 94891b801b5ecb9d7421cbf8eed52d6da659628a https://github.com/ruby-gnome2/ruby-gnome2/commit/94891b801b5ecb9d7421cbf8eed52d6da659628a Merged 33cf5d9: Merge pull request #1087 from cedlemo/vte3_regex Message: Add support for Vte::Regex Added files: vte3/lib/vte3/regex.rb Modified files: vte3/lib/vte3/loader.rb Modified: vte3/lib/vte3/loader.rb (+1 -0) =================================================================== --- vte3/lib/vte3/loader.rb 2017-08-03 00:10:10 +0900 (0d445a5d4) +++ vte3/lib/vte3/loader.rb 2017-08-03 02:07:48 +0900 (ee5dd52c4) @@ -44,6 +44,7 @@ module Vte require "vte3/pty" require "vte3/terminal" require "vte3/version" + require "vte3/regex" # need to be after version because I use Version.or_later? in it require "vte3/deprecated" end Added: vte3/lib/vte3/regex.rb (+52 -0) 100644 =================================================================== --- /dev/null +++ vte3/lib/vte3/regex.rb 2017-08-03 02:07:48 +0900 (3d99735d2) @@ -0,0 +1,52 @@ +# Copyright (C) 2015 Ruby-GNOME2 Project Team +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +module Vte + if Version.or_later?(0, 46) + class Regex + alias_method :initialize_raw, :initialize + def initialize(pattern, compile_flags, options) + flags = parse_compile_flags(compile_flags) + if options[:for_match] + initialize_new_for_match(pattern, pattern.length, flags) + elsif options[:for_search] + initialize_new_for_search(pattern, pattern.length, flags) + else + raise(ArgumentError, + "must specify usage :for_match or :for_search : #{options.inspect}") + end + end + + private + + def parse_compile_flags(compile_flags) + return compile_flags if compile_flags.class == Integer + + flags = 0 + return flags unless compile_flags.class == Array + + compile_flags.each do |flag| + begin + flags = flags | GLib::RegexCompileFlags.const_get(flag.to_s.upcase).to_i + rescue + end + end + + flags + end + end + end +end |