asip-meteor 0.9.3.2 → 0.9.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +3 -3
- data/lib/meteor.rb +150 -140
- metadata +4 -3
data/README
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
= meteor - A lightweight (X)HTML & XML Parser
|
3
3
|
|
4
|
-
by
|
4
|
+
by Yasumasa Ashida<ys.ashida@gmail.com>
|
5
5
|
|
6
6
|
== Description
|
7
7
|
|
@@ -25,6 +25,6 @@ by asip <ys.ashida@gmail.com>
|
|
25
25
|
|
26
26
|
== Copyright
|
27
27
|
|
28
|
-
Author::
|
29
|
-
Copyright:: Copyright (c) 2009 asip
|
28
|
+
Author:: Yasumasa Ashida <ys.ashida@gmail.com>
|
29
|
+
Copyright:: Copyright (c) 2008-2009 asip
|
30
30
|
License:: LGPL V2.1
|
data/lib/meteor.rb
CHANGED
@@ -18,12 +18,12 @@
|
|
18
18
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
19
19
|
#
|
20
20
|
# @author Yasumasa Ashida
|
21
|
-
# @version 0.9.3.
|
21
|
+
# @version 0.9.3.3
|
22
22
|
#
|
23
23
|
|
24
24
|
module Meteor
|
25
25
|
|
26
|
-
VERSION = "0.9.3.
|
26
|
+
VERSION = "0.9.3.3"
|
27
27
|
|
28
28
|
RUBY_VERSION_1_9_0 = '1.9.0'
|
29
29
|
|
@@ -837,7 +837,7 @@ module Meteor
|
|
837
837
|
# @param [Meteor::Parser] ps パーサ
|
838
838
|
#
|
839
839
|
def []=(key,ps)
|
840
|
-
@cache[
|
840
|
+
@cache[key] = ps
|
841
841
|
end
|
842
842
|
|
843
843
|
#
|
@@ -1150,11 +1150,12 @@ module Meteor
|
|
1150
1150
|
#@pattern = nil
|
1151
1151
|
#ルート要素
|
1152
1152
|
@root = RootElement.new
|
1153
|
-
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
1153
|
+
#if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
1154
1154
|
@element_cache = Hash.new()
|
1155
|
-
else
|
1156
|
-
|
1157
|
-
end
|
1155
|
+
#else
|
1156
|
+
# @element_cache = Meteor::Core::Util::OrderHash.new
|
1157
|
+
#end
|
1158
|
+
|
1158
1159
|
#@res = nil
|
1159
1160
|
#@_attributes = nil
|
1160
1161
|
#@_mixed_content = nil
|
@@ -1204,7 +1205,7 @@ module Meteor
|
|
1204
1205
|
end
|
1205
1206
|
|
1206
1207
|
attr_accessor :element_cache #[Hash] 要素キャッシュ
|
1207
|
-
attr_accessor :doc_type #[
|
1208
|
+
attr_accessor :doc_type #[Fixnum] ドキュメントタイプ
|
1208
1209
|
|
1209
1210
|
#
|
1210
1211
|
# 文字エンコーディングをセットする
|
@@ -1500,7 +1501,7 @@ module Meteor
|
|
1500
1501
|
@res2 = @pattern.match(@root.document)
|
1501
1502
|
|
1502
1503
|
if !@res2 then
|
1503
|
-
@res2 = element_with_3_2
|
1504
|
+
@res2 = element_with_3_2
|
1504
1505
|
@pattern_cc_2 = @pattern_cc
|
1505
1506
|
end
|
1506
1507
|
|
@@ -1579,7 +1580,7 @@ module Meteor
|
|
1579
1580
|
end
|
1580
1581
|
private :element_with_3_1
|
1581
1582
|
|
1582
|
-
def element_with_3_2
|
1583
|
+
def element_with_3_2
|
1583
1584
|
|
1584
1585
|
#@pattern_cc_1 = '' << TAG_OPEN << @_elm_name << TAG_SEARCH_2_1 << @_attr_name << ATTR_EQ
|
1585
1586
|
#@pattern_cc_1 << @_attr_value << TAG_SEARCH_2_4_2
|
@@ -1945,11 +1946,11 @@ module Meteor
|
|
1945
1946
|
|
1946
1947
|
if @position > @position2 then
|
1947
1948
|
|
1948
|
-
if @cnt == ZERO then
|
1949
|
-
|
1950
|
-
else
|
1951
|
-
|
1952
|
-
end
|
1949
|
+
#if @cnt == ZERO then
|
1950
|
+
#@sbuf << @pattern_cc_1_1
|
1951
|
+
#else
|
1952
|
+
@sbuf << @pattern_cc_1_2
|
1953
|
+
#end
|
1953
1954
|
|
1954
1955
|
@cnt += 1
|
1955
1956
|
|
@@ -1970,11 +1971,11 @@ module Meteor
|
|
1970
1971
|
end
|
1971
1972
|
else
|
1972
1973
|
|
1973
|
-
if @cnt == ZERO then
|
1974
|
-
|
1975
|
-
else
|
1976
|
-
|
1977
|
-
end
|
1974
|
+
#if @cnt == ZERO then
|
1975
|
+
# @sbuf << @pattern_cc_1_1
|
1976
|
+
#else
|
1977
|
+
@sbuf << @pattern_cc_1_2
|
1978
|
+
#end
|
1978
1979
|
|
1979
1980
|
@cnt += 1
|
1980
1981
|
|
@@ -1983,11 +1984,11 @@ module Meteor
|
|
1983
1984
|
else
|
1984
1985
|
@position = @res.end(0)
|
1985
1986
|
|
1986
|
-
if @cnt == ZERO then
|
1987
|
-
|
1988
|
-
else
|
1989
|
-
|
1990
|
-
end
|
1987
|
+
#if @cnt == ZERO then
|
1988
|
+
@sbuf << @pattern_cc_1_1
|
1989
|
+
#else
|
1990
|
+
# @sbuf << @pattern_cc_1_2
|
1991
|
+
#end
|
1991
1992
|
|
1992
1993
|
@cnt += ONE
|
1993
1994
|
end
|
@@ -2003,18 +2004,21 @@ module Meteor
|
|
2003
2004
|
@sbuf << @pattern_cc_2_1
|
2004
2005
|
else
|
2005
2006
|
@sbuf << @pattern_cc_2_2
|
2007
|
+
break
|
2006
2008
|
end
|
2007
2009
|
|
2008
2010
|
@position = @res.end(0)
|
2009
|
-
|
2010
|
-
|
2011
|
-
if @cnt == ZERO then
|
2011
|
+
else
|
2012
2012
|
break
|
2013
2013
|
end
|
2014
2014
|
|
2015
|
-
if
|
2016
|
-
|
2017
|
-
end
|
2015
|
+
#if @cnt == ZERO then
|
2016
|
+
# break
|
2017
|
+
#end
|
2018
|
+
|
2019
|
+
#if !@res then
|
2020
|
+
# break
|
2021
|
+
#end
|
2018
2022
|
end
|
2019
2023
|
|
2020
2024
|
@pattern = @pattern_1b
|
@@ -2039,11 +2043,11 @@ module Meteor
|
|
2039
2043
|
|
2040
2044
|
if @rx_document2.length > @rx_document.length then
|
2041
2045
|
|
2042
|
-
if @cnt == ZERO then
|
2043
|
-
|
2044
|
-
else
|
2045
|
-
|
2046
|
-
end
|
2046
|
+
#if @cnt == ZERO then
|
2047
|
+
# @sbuf << @pattern_cc_1_1
|
2048
|
+
#else
|
2049
|
+
@sbuf << @pattern_cc_1_2
|
2050
|
+
#end
|
2047
2051
|
|
2048
2052
|
@cnt += ONE
|
2049
2053
|
|
@@ -2056,19 +2060,20 @@ module Meteor
|
|
2056
2060
|
@sbuf << @pattern_cc_2_1
|
2057
2061
|
else
|
2058
2062
|
@sbuf << @pattern_cc_2_2
|
2059
|
-
end
|
2060
|
-
|
2061
|
-
if @cnt == ZERO then
|
2062
2063
|
break
|
2063
2064
|
end
|
2065
|
+
|
2066
|
+
#if @cnt == ZERO then
|
2067
|
+
# break
|
2068
|
+
#end
|
2064
2069
|
end
|
2065
2070
|
else
|
2066
2071
|
|
2067
|
-
if @cnt == ZERO then
|
2068
|
-
|
2069
|
-
else
|
2070
|
-
|
2071
|
-
end
|
2072
|
+
#if @cnt == ZERO then
|
2073
|
+
# @sbuf << @pattern_cc_1_1
|
2074
|
+
#else
|
2075
|
+
@sbuf << @pattern_cc_1_2
|
2076
|
+
#end
|
2072
2077
|
|
2073
2078
|
@cnt += ONE
|
2074
2079
|
|
@@ -2077,11 +2082,11 @@ module Meteor
|
|
2077
2082
|
else
|
2078
2083
|
@rx_document = @res.post_match
|
2079
2084
|
|
2080
|
-
if @cnt == ZERO then
|
2081
|
-
|
2082
|
-
else
|
2083
|
-
|
2084
|
-
end
|
2085
|
+
#if @cnt == ZERO then
|
2086
|
+
@sbuf << @pattern_cc_1_1
|
2087
|
+
#else
|
2088
|
+
#@sbuf << @pattern_cc_1_2
|
2089
|
+
#end
|
2085
2090
|
|
2086
2091
|
@cnt += ONE
|
2087
2092
|
end
|
@@ -2097,18 +2102,21 @@ module Meteor
|
|
2097
2102
|
@sbuf << @pattern_cc_2_1
|
2098
2103
|
else
|
2099
2104
|
@sbuf << @pattern_cc_2_2
|
2105
|
+
break
|
2100
2106
|
end
|
2101
2107
|
|
2102
2108
|
@rx_document = @res.post_match
|
2103
|
-
|
2104
|
-
|
2105
|
-
if @cnt == ZERO then
|
2109
|
+
else
|
2106
2110
|
break
|
2107
2111
|
end
|
2108
2112
|
|
2109
|
-
if
|
2110
|
-
|
2111
|
-
end
|
2113
|
+
#if @cnt == ZERO then
|
2114
|
+
# break
|
2115
|
+
#end
|
2116
|
+
|
2117
|
+
#if !@res then
|
2118
|
+
# break
|
2119
|
+
#end
|
2112
2120
|
end
|
2113
2121
|
|
2114
2122
|
@pattern = @pattern_1b
|
@@ -2818,13 +2826,13 @@ module Meteor
|
|
2818
2826
|
def create(pif)
|
2819
2827
|
case pif.doc_type
|
2820
2828
|
when Parser::HTML then
|
2821
|
-
|
2829
|
+
Meteor::Core::Html::ParserImpl.new
|
2822
2830
|
when Parser::XHTML then
|
2823
|
-
|
2831
|
+
Meteor::Core::Xhtml::ParserImpl.new
|
2824
2832
|
when Parser::XML then
|
2825
|
-
|
2833
|
+
Meteor::Core::Xml::ParserImpl.new
|
2826
2834
|
else
|
2827
|
-
|
2835
|
+
nil
|
2828
2836
|
end
|
2829
2837
|
end
|
2830
2838
|
private :create
|
@@ -2981,85 +2989,85 @@ module Meteor
|
|
2981
2989
|
#end
|
2982
2990
|
end
|
2983
2991
|
|
2984
|
-
class OrderHash < Hash
|
2985
|
-
|
2986
|
-
|
2987
|
-
|
2988
|
-
|
2989
|
-
|
2990
|
-
|
2991
|
-
|
2992
|
-
|
2993
|
-
|
2994
|
-
|
2995
|
-
|
2996
|
-
|
2997
|
-
|
2998
|
-
|
2999
|
-
|
3000
|
-
|
3001
|
-
|
3002
|
-
|
3003
|
-
|
3004
|
-
|
3005
|
-
|
3006
|
-
|
3007
|
-
|
3008
|
-
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3012
|
-
|
3013
|
-
|
3014
|
-
|
3015
|
-
|
3016
|
-
|
3017
|
-
|
3018
|
-
|
3019
|
-
|
3020
|
-
|
3021
|
-
|
3022
|
-
|
3023
|
-
|
3024
|
-
|
3025
|
-
|
3026
|
-
|
3027
|
-
|
3028
|
-
|
3029
|
-
|
3030
|
-
|
3031
|
-
|
3032
|
-
|
3033
|
-
|
3034
|
-
|
3035
|
-
|
3036
|
-
|
3037
|
-
|
3038
|
-
|
3039
|
-
|
3040
|
-
|
3041
|
-
|
3042
|
-
|
3043
|
-
|
3044
|
-
|
3045
|
-
|
3046
|
-
|
3047
|
-
|
3048
|
-
|
3049
|
-
|
3050
|
-
|
3051
|
-
|
3052
|
-
|
3053
|
-
|
3054
|
-
|
3055
|
-
|
3056
|
-
|
3057
|
-
|
3058
|
-
|
3059
|
-
|
3060
|
-
|
3061
|
-
|
3062
|
-
end
|
2992
|
+
#class OrderHash < Hash
|
2993
|
+
#
|
2994
|
+
# def initialize
|
2995
|
+
# @keys = Array.new
|
2996
|
+
# @values = Array.new
|
2997
|
+
# end
|
2998
|
+
#
|
2999
|
+
# attr_accessor :keys
|
3000
|
+
# attr_accessor :values
|
3001
|
+
#
|
3002
|
+
# def store(key, value)
|
3003
|
+
# unless @keys.include?(key)
|
3004
|
+
# @keys << key
|
3005
|
+
# @values << value
|
3006
|
+
# end
|
3007
|
+
# super(key, value)
|
3008
|
+
# end
|
3009
|
+
#
|
3010
|
+
# def clear
|
3011
|
+
# @keys.clear
|
3012
|
+
# @values.clear
|
3013
|
+
# super
|
3014
|
+
# end
|
3015
|
+
#
|
3016
|
+
# def delete(key)
|
3017
|
+
# if @keys.include?(key)
|
3018
|
+
# @keys.delete(key)
|
3019
|
+
# @values.delete(fetch(key))
|
3020
|
+
# super(key)
|
3021
|
+
# elsif yield(key)
|
3022
|
+
# end
|
3023
|
+
# end
|
3024
|
+
#
|
3025
|
+
# #superとして、Hash#[]=を呼び出す
|
3026
|
+
#
|
3027
|
+
# def []=(key, value)
|
3028
|
+
# store(key, value)
|
3029
|
+
# end
|
3030
|
+
#
|
3031
|
+
# def each
|
3032
|
+
# @keys.each do |k|
|
3033
|
+
# arr_tmp = Array.new
|
3034
|
+
# arr_tmp << k
|
3035
|
+
# arr_tmp << self[k]
|
3036
|
+
# yield(arr_tmp)
|
3037
|
+
# end
|
3038
|
+
# return self
|
3039
|
+
# end
|
3040
|
+
#
|
3041
|
+
# def each_pair
|
3042
|
+
# @keys.each do |k|
|
3043
|
+
# yield(k, self[k])
|
3044
|
+
# end
|
3045
|
+
# return self
|
3046
|
+
# end
|
3047
|
+
#
|
3048
|
+
# def map
|
3049
|
+
# arr_tmp = Array.new
|
3050
|
+
# @keys.each do |k|
|
3051
|
+
# arg_arr = Array.new
|
3052
|
+
# arg_arr << k
|
3053
|
+
# arg_arr << self[k]
|
3054
|
+
# arr_tmp << yield(arg_arr)
|
3055
|
+
# end
|
3056
|
+
# return arr_tmp
|
3057
|
+
# end
|
3058
|
+
#
|
3059
|
+
# def sort_hash(&block)
|
3060
|
+
# if block_given?
|
3061
|
+
# arr_tmp = self.sort(&block)
|
3062
|
+
# elsif arr_tmp = self.sort
|
3063
|
+
# end
|
3064
|
+
# hash_tmp = OrderHash.new
|
3065
|
+
# arr_tmp.each do |item|
|
3066
|
+
# hash_tmp[item[0]] = item[1]
|
3067
|
+
# end
|
3068
|
+
# return hash_tmp
|
3069
|
+
# end
|
3070
|
+
#end
|
3063
3071
|
|
3064
3072
|
end
|
3065
3073
|
|
@@ -3085,6 +3093,8 @@ module Meteor
|
|
3085
3093
|
#MATCH_TAG_2 = "textarea|option|pre"
|
3086
3094
|
MATCH_TAG_2 =['textarea','option','pre']
|
3087
3095
|
|
3096
|
+
MATCH_TAG_SNG = ['texarea','option','form']
|
3097
|
+
|
3088
3098
|
HTTP_EQUIV = 'http-equiv'
|
3089
3099
|
CONTENT_TYPE = 'Content-Type'
|
3090
3100
|
CONTENT = 'content'
|
@@ -3435,7 +3445,7 @@ module Meteor
|
|
3435
3445
|
#内容あり要素検索
|
3436
3446
|
@res = @pattern.match(@root.document)
|
3437
3447
|
|
3438
|
-
if !@res then
|
3448
|
+
if !@res && !is_match(MATCH_TAG_SNG) then
|
3439
3449
|
@res = element_with_3_2(elm_name)
|
3440
3450
|
end
|
3441
3451
|
|
@@ -3537,7 +3547,7 @@ module Meteor
|
|
3537
3547
|
#内容あり要素検索
|
3538
3548
|
@res = @pattern.match(@root.document)
|
3539
3549
|
|
3540
|
-
if !@res then
|
3550
|
+
if !@res && !is_match(MATCH_TAG_SNG) then
|
3541
3551
|
@res = element_with_5_2(elm_name)
|
3542
3552
|
end
|
3543
3553
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asip-meteor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.3.
|
4
|
+
version: 0.9.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- asip
|
@@ -9,7 +9,7 @@ autorequire: meteor
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-31 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -31,6 +31,7 @@ files:
|
|
31
31
|
- lib/meteor.rb
|
32
32
|
has_rdoc: false
|
33
33
|
homepage: http://meteor.rubyforge.org
|
34
|
+
licenses:
|
34
35
|
post_install_message:
|
35
36
|
rdoc_options:
|
36
37
|
- --title
|
@@ -62,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
63
|
requirements: []
|
63
64
|
|
64
65
|
rubyforge_project: meteor
|
65
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.3.5
|
66
67
|
signing_key:
|
67
68
|
specification_version: 3
|
68
69
|
summary: A lightweight (X)HTML & XML parser
|