asip-meteor 0.9.1.3 → 0.9.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/meteor.rb +184 -144
- metadata +3 -3
data/lib/meteor.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
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.1.
|
21
|
+
# @version 0.9.1.5
|
22
22
|
#
|
23
23
|
|
24
24
|
|
@@ -31,8 +31,19 @@ end
|
|
31
31
|
|
32
32
|
module Meteor
|
33
33
|
|
34
|
-
VERSION = "0.9.1.
|
35
|
-
|
34
|
+
VERSION = "0.9.1.5"
|
35
|
+
|
36
|
+
ZERO = 0
|
37
|
+
ONE = 1
|
38
|
+
TWO = 2
|
39
|
+
THREE = 3
|
40
|
+
FOUR = 4
|
41
|
+
FIVE = 5
|
42
|
+
SIX = 6
|
43
|
+
SEVEN = 7
|
44
|
+
|
45
|
+
CONTENT_STR = ':content'
|
46
|
+
|
36
47
|
#
|
37
48
|
# 要素クラス
|
38
49
|
#
|
@@ -44,7 +55,7 @@ module Meteor
|
|
44
55
|
#
|
45
56
|
def initialize(*args)
|
46
57
|
case args.length
|
47
|
-
when
|
58
|
+
when ONE
|
48
59
|
if args[0].kind_of?(String) then
|
49
60
|
initialize_s(args[0])
|
50
61
|
elsif args[0].kind_of?(Meteor::Element)
|
@@ -74,8 +85,9 @@ module Meteor
|
|
74
85
|
#@parent = false
|
75
86
|
@arguments = AttributeMap.new
|
76
87
|
@origin = self.object_id
|
77
|
-
@usable =
|
88
|
+
@usable = ZERO
|
78
89
|
end
|
90
|
+
private :initialize_s
|
79
91
|
|
80
92
|
#
|
81
93
|
# イニシャライザ
|
@@ -94,8 +106,9 @@ module Meteor
|
|
94
106
|
@parser = elm.parser
|
95
107
|
@arguments = AttributeMap.new(elm.arguments)
|
96
108
|
@origin = elm.object_id
|
97
|
-
@usable =
|
109
|
+
@usable = ZERO
|
98
110
|
end
|
111
|
+
private :initialize_e
|
99
112
|
|
100
113
|
def self.new!(elm)
|
101
114
|
@obj = elm.parser.e_cache[elm.origin]
|
@@ -104,7 +117,7 @@ module Meteor
|
|
104
117
|
@obj.pattern = String.new(elm.pattern)
|
105
118
|
@obj.document = String.new(elm.document)
|
106
119
|
@obj.arguments = AttributeMap.new(elm.arguments)
|
107
|
-
@obj.usable =
|
120
|
+
@obj.usable = ZERO
|
108
121
|
@obj
|
109
122
|
else
|
110
123
|
self.new(elm)
|
@@ -145,17 +158,29 @@ module Meteor
|
|
145
158
|
def attribute_map
|
146
159
|
@parser.attribute_map(self)
|
147
160
|
end
|
148
|
-
|
161
|
+
|
162
|
+
|
163
|
+
|
149
164
|
#
|
150
165
|
# 内容をセットする or 内容を取得する
|
151
|
-
#
|
166
|
+
#
|
152
167
|
# @param [Array] args 引数配列
|
153
168
|
# @return [String] 内容
|
154
169
|
#
|
155
170
|
def content(*args)
|
156
|
-
@parser.content(self
|
171
|
+
@parser.content(self,args)
|
157
172
|
end
|
158
173
|
|
174
|
+
#
|
175
|
+
# 内容をセットする
|
176
|
+
#
|
177
|
+
# @param [String] value 内容の値
|
178
|
+
#
|
179
|
+
def content=(value)
|
180
|
+
@parser.content(self,value)
|
181
|
+
end
|
182
|
+
|
183
|
+
|
159
184
|
#
|
160
185
|
# 属性を編集するor内容をセットする
|
161
186
|
#
|
@@ -163,10 +188,10 @@ module Meteor
|
|
163
188
|
# @param [String] value 属性の値or内容
|
164
189
|
#
|
165
190
|
def []=(name,value)
|
166
|
-
if !name.kind_of?(String) || name !=
|
191
|
+
if !name.kind_of?(String) || name != CONTENT_STR then
|
167
192
|
attribute(name,value)
|
168
193
|
else
|
169
|
-
content(value)
|
194
|
+
content=(value)
|
170
195
|
end
|
171
196
|
end
|
172
197
|
|
@@ -177,7 +202,7 @@ module Meteor
|
|
177
202
|
# @return [String] 属性の値or内容
|
178
203
|
#
|
179
204
|
def [](name)
|
180
|
-
if !name.kind_of?(String) || name !=
|
205
|
+
if !name.kind_of?(String) || name != CONTENT_STR then
|
181
206
|
attribute(name)
|
182
207
|
else
|
183
208
|
content()
|
@@ -207,6 +232,8 @@ module Meteor
|
|
207
232
|
#
|
208
233
|
class RootElement
|
209
234
|
|
235
|
+
EMPTY = ''
|
236
|
+
|
210
237
|
#
|
211
238
|
# イニシャライザ
|
212
239
|
#
|
@@ -219,7 +246,7 @@ module Meteor
|
|
219
246
|
#@character_encoding=''
|
220
247
|
|
221
248
|
#フックドキュメント
|
222
|
-
@hook_document =
|
249
|
+
@hook_document = EMPTY
|
223
250
|
#フック判定フラグ
|
224
251
|
#@hook = false
|
225
252
|
#単一要素フック判定フラグ
|
@@ -248,9 +275,9 @@ module Meteor
|
|
248
275
|
|
249
276
|
def initialize(*args)
|
250
277
|
case args.length
|
251
|
-
when
|
278
|
+
when ZERO
|
252
279
|
initialize_0
|
253
|
-
when
|
280
|
+
when ONE
|
254
281
|
initialize_1(args[0])
|
255
282
|
else
|
256
283
|
raise ArgumentError
|
@@ -267,6 +294,7 @@ module Meteor
|
|
267
294
|
end
|
268
295
|
@recordable = false
|
269
296
|
end
|
297
|
+
private :initialize_0
|
270
298
|
|
271
299
|
#
|
272
300
|
# イニシャライザ
|
@@ -279,7 +307,8 @@ module Meteor
|
|
279
307
|
end
|
280
308
|
@recordable = attr_map.recordable
|
281
309
|
end
|
282
|
-
|
310
|
+
private :initialize_1
|
311
|
+
|
283
312
|
#
|
284
313
|
# 属性名と属性値を対としてセットする
|
285
314
|
#
|
@@ -412,7 +441,7 @@ module Meteor
|
|
412
441
|
attr_accessor :name
|
413
442
|
attr_accessor :value
|
414
443
|
attr_accessor :changed
|
415
|
-
attr_accessor :removed
|
444
|
+
attr_accessor :removed
|
416
445
|
|
417
446
|
end
|
418
447
|
|
@@ -420,8 +449,8 @@ module Meteor
|
|
420
449
|
# パーサ共通クラス
|
421
450
|
#
|
422
451
|
class Parser
|
423
|
-
HTML =
|
424
|
-
XHTML =
|
452
|
+
HTML = ZERO
|
453
|
+
XHTML = ONE
|
425
454
|
XML = 2
|
426
455
|
end
|
427
456
|
|
@@ -438,9 +467,9 @@ module Meteor
|
|
438
467
|
#
|
439
468
|
def self.build(*args)
|
440
469
|
case args.length
|
441
|
-
when
|
470
|
+
when THREE
|
442
471
|
build_3(args[0],args[1],args[2])
|
443
|
-
when
|
472
|
+
when TWO
|
444
473
|
build_2(args[0],args[1])
|
445
474
|
else
|
446
475
|
raise ArgumentError
|
@@ -730,13 +759,18 @@ module Meteor
|
|
730
759
|
#escape
|
731
760
|
AND_1 = '&'
|
732
761
|
AND_2 = '&'
|
762
|
+
AND_3 = 'amp'
|
733
763
|
LT_1 = '<'
|
734
764
|
LT_2 = '<'
|
765
|
+
LT_3 = 'lt'
|
735
766
|
GT_1 = '>'
|
736
767
|
GT_2 = '>'
|
768
|
+
GT_3 = 'gt'
|
737
769
|
QO_2 = '"'
|
770
|
+
QO_3 = 'quot'
|
738
771
|
AP_1 = '\''
|
739
772
|
AP_2 = '''
|
773
|
+
AP_3 = 'apos'
|
740
774
|
#EN_1 = "\\\\"
|
741
775
|
EN_1 = "\\"
|
742
776
|
#EN_2 = "\\\\\\\\"
|
@@ -837,6 +871,7 @@ module Meteor
|
|
837
871
|
#@_attrValue2 = nil
|
838
872
|
|
839
873
|
#@sbuf = nil;
|
874
|
+
#@sbuf = ''
|
840
875
|
#@rx_document = nil;
|
841
876
|
#@rx_document2 = nil;
|
842
877
|
end
|
@@ -1010,15 +1045,15 @@ module Meteor
|
|
1010
1045
|
#
|
1011
1046
|
def element(*args)
|
1012
1047
|
case args.length
|
1013
|
-
when
|
1048
|
+
when ONE
|
1014
1049
|
element_1(args[0])
|
1015
|
-
when
|
1050
|
+
when TWO
|
1016
1051
|
element_2(args[0],args[1])
|
1017
|
-
when
|
1052
|
+
when THREE
|
1018
1053
|
element_3(args[0],args[1],args[2])
|
1019
|
-
when
|
1054
|
+
when FOUR
|
1020
1055
|
element_4(args[0],args[1],args[2],args[3])
|
1021
|
-
when
|
1056
|
+
when FIVE
|
1022
1057
|
element_5(args[0],args[1],args[2],args[3],args[4])
|
1023
1058
|
else
|
1024
1059
|
raise ArgumentError
|
@@ -1195,7 +1230,7 @@ module Meteor
|
|
1195
1230
|
|
1196
1231
|
def element_with_3_1(elm_name)
|
1197
1232
|
|
1198
|
-
if @res.captures.length ==
|
1233
|
+
if @res.captures.length == FOUR then
|
1199
1234
|
#要素
|
1200
1235
|
@elm_ = Element.new(elm_name)
|
1201
1236
|
#属性
|
@@ -1216,7 +1251,7 @@ module Meteor
|
|
1216
1251
|
|
1217
1252
|
@elm_.parser = self
|
1218
1253
|
|
1219
|
-
elsif @res.captures.length ==
|
1254
|
+
elsif @res.captures.length == SIX then
|
1220
1255
|
#内容
|
1221
1256
|
@elm_ = Element.new(elm_name)
|
1222
1257
|
#属性
|
@@ -1269,7 +1304,7 @@ module Meteor
|
|
1269
1304
|
|
1270
1305
|
@pattern_cc = @sbuf
|
1271
1306
|
|
1272
|
-
if @sbuf.length ==
|
1307
|
+
if @sbuf.length == ZERO || @cnt != ZERO then
|
1273
1308
|
# raise NoSuchElementException.new(elm_name,attr_name,attr_value);
|
1274
1309
|
return nil;
|
1275
1310
|
end
|
@@ -1416,7 +1451,7 @@ module Meteor
|
|
1416
1451
|
|
1417
1452
|
def element_with_5_1(elm_name)
|
1418
1453
|
|
1419
|
-
if @res.captures.length ==
|
1454
|
+
if @res.captures.length == FOUR then
|
1420
1455
|
#要素
|
1421
1456
|
@elm_ = Element.new(elm_name)
|
1422
1457
|
#属性
|
@@ -1440,7 +1475,7 @@ module Meteor
|
|
1440
1475
|
|
1441
1476
|
@elm_.parser = self
|
1442
1477
|
|
1443
|
-
elsif @res.captures.length ==
|
1478
|
+
elsif @res.captures.length == SIX then
|
1444
1479
|
|
1445
1480
|
@elm_ = Element.new(elm_name)
|
1446
1481
|
#属性
|
@@ -1499,7 +1534,7 @@ module Meteor
|
|
1499
1534
|
|
1500
1535
|
@pattern_cc = @sbuf
|
1501
1536
|
|
1502
|
-
if @sbuf.length ==
|
1537
|
+
if @sbuf.length == ZERO || @cnt != ZERO then
|
1503
1538
|
# raise NoSuchElementException.new(elm_name,attr_name1,attr_value1,attr_name2,attr_value2);
|
1504
1539
|
return nil
|
1505
1540
|
end
|
@@ -1581,11 +1616,11 @@ module Meteor
|
|
1581
1616
|
|
1582
1617
|
@position = 0
|
1583
1618
|
|
1584
|
-
while (@res = @pattern.match(@root.document,@position)) || @cnt >
|
1619
|
+
while (@res = @pattern.match(@root.document,@position)) || @cnt > ZERO
|
1585
1620
|
|
1586
1621
|
if @res then
|
1587
1622
|
|
1588
|
-
if @cnt >
|
1623
|
+
if @cnt > ZERO then
|
1589
1624
|
|
1590
1625
|
@position2 = @res.end(0)
|
1591
1626
|
|
@@ -1597,7 +1632,7 @@ module Meteor
|
|
1597
1632
|
|
1598
1633
|
if @position > @position2 then
|
1599
1634
|
|
1600
|
-
if @cnt ==
|
1635
|
+
if @cnt == ZERO then
|
1601
1636
|
@sbuf << @pattern_cc_1_1
|
1602
1637
|
else
|
1603
1638
|
@sbuf << @pattern_cc_1_2
|
@@ -1608,40 +1643,40 @@ module Meteor
|
|
1608
1643
|
@position = @position2
|
1609
1644
|
else
|
1610
1645
|
|
1611
|
-
@cnt -=
|
1646
|
+
@cnt -= ONE
|
1612
1647
|
|
1613
|
-
if @cnt !=
|
1648
|
+
if @cnt != ZERO then
|
1614
1649
|
@sbuf << @pattern_cc_2_1
|
1615
1650
|
else
|
1616
1651
|
@sbuf << @pattern_cc_2_2
|
1617
1652
|
end
|
1618
1653
|
|
1619
|
-
if @cnt ==
|
1654
|
+
if @cnt == ZERO then
|
1620
1655
|
break
|
1621
1656
|
end
|
1622
1657
|
end
|
1623
1658
|
else
|
1624
1659
|
|
1625
|
-
if @cnt ==
|
1660
|
+
if @cnt == ZERO then
|
1626
1661
|
@sbuf << @pattern_cc_1_1
|
1627
1662
|
else
|
1628
1663
|
@sbuf << @pattern_cc_1_2
|
1629
1664
|
end
|
1630
1665
|
|
1631
|
-
@cnt +=
|
1666
|
+
@cnt += ONE
|
1632
1667
|
|
1633
1668
|
@position = @position2
|
1634
1669
|
end
|
1635
1670
|
else
|
1636
1671
|
@position = @res.end(0)
|
1637
1672
|
|
1638
|
-
if @cnt ==
|
1673
|
+
if @cnt == ZERO then
|
1639
1674
|
@sbuf << @pattern_cc_1_1
|
1640
1675
|
else
|
1641
1676
|
@sbuf << @pattern_cc_1_2
|
1642
1677
|
end
|
1643
1678
|
|
1644
|
-
@cnt +=
|
1679
|
+
@cnt += ONE
|
1645
1680
|
end
|
1646
1681
|
else
|
1647
1682
|
|
@@ -1649,9 +1684,9 @@ module Meteor
|
|
1649
1684
|
|
1650
1685
|
if @res then
|
1651
1686
|
|
1652
|
-
@cnt -=
|
1687
|
+
@cnt -= ONE
|
1653
1688
|
|
1654
|
-
if @cnt !=
|
1689
|
+
if @cnt != ZERO then
|
1655
1690
|
@sbuf << @pattern_cc_2_1
|
1656
1691
|
else
|
1657
1692
|
@sbuf << @pattern_cc_2_2
|
@@ -1660,7 +1695,7 @@ module Meteor
|
|
1660
1695
|
@position = @res.end(0)
|
1661
1696
|
end
|
1662
1697
|
|
1663
|
-
if @cnt ==
|
1698
|
+
if @cnt == ZERO then
|
1664
1699
|
break
|
1665
1700
|
end
|
1666
1701
|
|
@@ -1675,11 +1710,11 @@ module Meteor
|
|
1675
1710
|
|
1676
1711
|
@rx_document = @root.document
|
1677
1712
|
|
1678
|
-
while (@res = @pattern.match(@rx_document)) || @cnt >
|
1713
|
+
while (@res = @pattern.match(@rx_document)) || @cnt > ZERO
|
1679
1714
|
|
1680
1715
|
if @res then
|
1681
1716
|
|
1682
|
-
if @cnt >
|
1717
|
+
if @cnt > ZERO then
|
1683
1718
|
|
1684
1719
|
@rx_document2 = @res.post_match
|
1685
1720
|
|
@@ -1691,51 +1726,51 @@ module Meteor
|
|
1691
1726
|
|
1692
1727
|
if @rx_document2.length > @rx_document.length then
|
1693
1728
|
|
1694
|
-
if @cnt ==
|
1729
|
+
if @cnt == ZERO then
|
1695
1730
|
@sbuf << @pattern_cc_1_1
|
1696
1731
|
else
|
1697
1732
|
@sbuf << @pattern_cc_1_2
|
1698
1733
|
end
|
1699
1734
|
|
1700
|
-
@cnt +=
|
1735
|
+
@cnt += ONE
|
1701
1736
|
|
1702
1737
|
@rx_document = @rx_document2
|
1703
1738
|
else
|
1704
1739
|
|
1705
|
-
@cnt -=
|
1740
|
+
@cnt -= ONE
|
1706
1741
|
|
1707
|
-
if @cnt !=
|
1742
|
+
if @cnt != ZERO then
|
1708
1743
|
@sbuf << @pattern_cc_2_1
|
1709
1744
|
else
|
1710
1745
|
@sbuf << @pattern_cc_2_2
|
1711
1746
|
end
|
1712
1747
|
|
1713
|
-
if @cnt ==
|
1748
|
+
if @cnt == ZERO then
|
1714
1749
|
break
|
1715
1750
|
end
|
1716
1751
|
end
|
1717
1752
|
else
|
1718
1753
|
|
1719
|
-
if @cnt ==
|
1754
|
+
if @cnt == ZERO then
|
1720
1755
|
@sbuf << @pattern_cc_1_1
|
1721
1756
|
else
|
1722
1757
|
@sbuf << @pattern_cc_1_2
|
1723
1758
|
end
|
1724
1759
|
|
1725
|
-
@cnt +=
|
1760
|
+
@cnt += ONE
|
1726
1761
|
|
1727
1762
|
@rx_document = @rx_document2
|
1728
1763
|
end
|
1729
1764
|
else
|
1730
1765
|
@rx_document = @res.post_match
|
1731
1766
|
|
1732
|
-
if @cnt ==
|
1767
|
+
if @cnt == ZERO then
|
1733
1768
|
@sbuf << @pattern_cc_1_1
|
1734
1769
|
else
|
1735
1770
|
@sbuf << @pattern_cc_1_2
|
1736
1771
|
end
|
1737
1772
|
|
1738
|
-
@cnt +=
|
1773
|
+
@cnt += ONE
|
1739
1774
|
end
|
1740
1775
|
else
|
1741
1776
|
|
@@ -1743,9 +1778,9 @@ module Meteor
|
|
1743
1778
|
|
1744
1779
|
if @res then
|
1745
1780
|
|
1746
|
-
@cnt -=
|
1781
|
+
@cnt -= ONE
|
1747
1782
|
|
1748
|
-
if @cnt !=
|
1783
|
+
if @cnt != ZERO then
|
1749
1784
|
@sbuf << @pattern_cc_2_1
|
1750
1785
|
else
|
1751
1786
|
@sbuf << @pattern_cc_2_2
|
@@ -1754,7 +1789,7 @@ module Meteor
|
|
1754
1789
|
@rx_document = @res.post_match
|
1755
1790
|
end
|
1756
1791
|
|
1757
|
-
if @cnt ==
|
1792
|
+
if @cnt == ZERO then
|
1758
1793
|
break
|
1759
1794
|
end
|
1760
1795
|
|
@@ -1777,9 +1812,9 @@ module Meteor
|
|
1777
1812
|
#
|
1778
1813
|
def attribute(*args)
|
1779
1814
|
case args.length
|
1780
|
-
when
|
1815
|
+
when ONE
|
1781
1816
|
get_attribute_value_1(args[0])
|
1782
|
-
when
|
1817
|
+
when TWO
|
1783
1818
|
if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String) then
|
1784
1819
|
get_attribute_value_2(args[0],args[1])
|
1785
1820
|
elsif args[0].kind_of?(String) && args[1].kind_of?(String) then
|
@@ -1789,7 +1824,7 @@ module Meteor
|
|
1789
1824
|
else
|
1790
1825
|
raise ArgumentError
|
1791
1826
|
end
|
1792
|
-
when
|
1827
|
+
when THREE
|
1793
1828
|
set_attribute_3(args[0],args[1],args[2])
|
1794
1829
|
else
|
1795
1830
|
raise ArgumentError
|
@@ -1872,7 +1907,7 @@ module Meteor
|
|
1872
1907
|
if !elm.cx then
|
1873
1908
|
@_attributes = elm.attributes
|
1874
1909
|
replace2regex(@_attributes)
|
1875
|
-
|
1910
|
+
|
1876
1911
|
if elm.empty then
|
1877
1912
|
#内容あり要素の場合
|
1878
1913
|
@_content = elm.mixed_content
|
@@ -1997,9 +2032,9 @@ module Meteor
|
|
1997
2032
|
#
|
1998
2033
|
def attribute_map(*args)
|
1999
2034
|
case args.length
|
2000
|
-
when
|
2035
|
+
when ZERO
|
2001
2036
|
get_attribute_map_0
|
2002
|
-
when
|
2037
|
+
when ONE
|
2003
2038
|
get_attribute_map_1(args[0])
|
2004
2039
|
else
|
2005
2040
|
raise ArgumentError
|
@@ -2070,13 +2105,13 @@ module Meteor
|
|
2070
2105
|
#
|
2071
2106
|
def content(*args)
|
2072
2107
|
case args.length
|
2073
|
-
when
|
2108
|
+
when ONE
|
2074
2109
|
if args[0].kind_of?(Meteor::Element) then
|
2075
2110
|
get_content_1(args[0])
|
2076
2111
|
elsif args[0].kind_of?(String) then
|
2077
2112
|
set_content_1(args[0])
|
2078
2113
|
end
|
2079
|
-
when
|
2114
|
+
when TWO
|
2080
2115
|
if args[0].kind_of?(Meteor::Element) && args[1].kind_of?(String) then
|
2081
2116
|
set_content_2_s(args[0],args[1])
|
2082
2117
|
elsif args[0].kind_of?(String) && (args[1].kind_of?(TrueClass) || args[1].kind_of?(FalseClass)) then
|
@@ -2084,7 +2119,7 @@ module Meteor
|
|
2084
2119
|
else
|
2085
2120
|
raise ArgumentError
|
2086
2121
|
end
|
2087
|
-
when
|
2122
|
+
when THREE
|
2088
2123
|
set_content_3(args[0],args[1],args[2])
|
2089
2124
|
else
|
2090
2125
|
raise ArgumentError
|
@@ -2170,9 +2205,9 @@ module Meteor
|
|
2170
2205
|
#
|
2171
2206
|
def remove_attribute(*args)
|
2172
2207
|
case args.length
|
2173
|
-
when
|
2208
|
+
when ONE
|
2174
2209
|
remove_attribute_1(args[0])
|
2175
|
-
when
|
2210
|
+
when TWO
|
2176
2211
|
remove_attribute_2(args[0],args[1])
|
2177
2212
|
else
|
2178
2213
|
raise ArgumentError
|
@@ -2243,9 +2278,9 @@ module Meteor
|
|
2243
2278
|
#
|
2244
2279
|
def cxtag(*args)
|
2245
2280
|
case args.length
|
2246
|
-
when
|
2281
|
+
when ONE
|
2247
2282
|
cxtag_1(args[0])
|
2248
|
-
when
|
2283
|
+
when TWO
|
2249
2284
|
cxtag_2(args[0],args[1])
|
2250
2285
|
else
|
2251
2286
|
raise ArgumentError
|
@@ -2327,7 +2362,7 @@ module Meteor
|
|
2327
2362
|
#
|
2328
2363
|
def replace(elm,replace_document)
|
2329
2364
|
#文字エスケープ
|
2330
|
-
if replace_document.size >
|
2365
|
+
if replace_document.size > ZERO && elm.parent && elm.mono then
|
2331
2366
|
replace2regex(replace_document)
|
2332
2367
|
end
|
2333
2368
|
#タグ置換パターン
|
@@ -2339,7 +2374,7 @@ module Meteor
|
|
2339
2374
|
def reflect()
|
2340
2375
|
|
2341
2376
|
@e_cache.values.each do |item|
|
2342
|
-
if item.usable ==
|
2377
|
+
if item.usable == ZERO then
|
2343
2378
|
edit_document_1(item)
|
2344
2379
|
edit_pattern_(item)
|
2345
2380
|
item.usable = 1
|
@@ -2458,9 +2493,9 @@ module Meteor
|
|
2458
2493
|
#
|
2459
2494
|
def execute(*args)
|
2460
2495
|
case args.length
|
2461
|
-
when
|
2496
|
+
when ONE
|
2462
2497
|
execute_2(args[0],args[1])
|
2463
|
-
when
|
2498
|
+
when TWO
|
2464
2499
|
execute_3(args[0],args[1],args[2])
|
2465
2500
|
else
|
2466
2501
|
raise ArgumentError
|
@@ -2616,7 +2651,7 @@ module Meteor
|
|
2616
2651
|
# @param [String] value 属性値or内容
|
2617
2652
|
#
|
2618
2653
|
def []=(name,value)
|
2619
|
-
if !name.kind_of?(String)|| name !=
|
2654
|
+
if !name.kind_of?(String)|| name != CONTENT_STR then
|
2620
2655
|
attribute(name,value)
|
2621
2656
|
else
|
2622
2657
|
content(value)
|
@@ -2629,7 +2664,7 @@ module Meteor
|
|
2629
2664
|
# @return [String] 属性値or内容
|
2630
2665
|
#
|
2631
2666
|
def [](name)
|
2632
|
-
if !name.kind_of?(String)|| name !=
|
2667
|
+
if !name.kind_of?(String)|| name != CONTENT_STR then
|
2633
2668
|
attribute(name)
|
2634
2669
|
else
|
2635
2670
|
content()
|
@@ -2653,9 +2688,9 @@ module Meteor
|
|
2653
2688
|
|
2654
2689
|
def self.get(*args)
|
2655
2690
|
case args.length
|
2656
|
-
when
|
2691
|
+
when ONE
|
2657
2692
|
get_1(args[0])
|
2658
|
-
when
|
2693
|
+
when TWO
|
2659
2694
|
get_2(args[0],args[1])
|
2660
2695
|
else
|
2661
2696
|
raise ArgumentError
|
@@ -2807,6 +2842,7 @@ module Meteor
|
|
2807
2842
|
|
2808
2843
|
KAIGYO_CODE = '(\r?\n|\r)'
|
2809
2844
|
NBSP_2 = ' '
|
2845
|
+
NBSP_3 = 'nbsp'
|
2810
2846
|
BR_1 = '\r?\n|\r'
|
2811
2847
|
BR_2 = '<br>'
|
2812
2848
|
|
@@ -2946,9 +2982,9 @@ module Meteor
|
|
2946
2982
|
def initialize(*args)
|
2947
2983
|
super(args)
|
2948
2984
|
case args.length
|
2949
|
-
when
|
2985
|
+
when ZERO
|
2950
2986
|
initialize_0
|
2951
|
-
when
|
2987
|
+
when ONE
|
2952
2988
|
initialize_1(args[0])
|
2953
2989
|
else
|
2954
2990
|
raise ArgumentError
|
@@ -3534,18 +3570,18 @@ module Meteor
|
|
3534
3570
|
#end
|
3535
3571
|
element.gsub!(@@pattern_unescape) do
|
3536
3572
|
case $1
|
3537
|
-
when
|
3538
|
-
|
3539
|
-
when
|
3540
|
-
|
3541
|
-
when
|
3542
|
-
|
3543
|
-
when
|
3544
|
-
|
3545
|
-
when
|
3546
|
-
|
3547
|
-
when
|
3548
|
-
|
3573
|
+
when AND_3 then
|
3574
|
+
AND_1
|
3575
|
+
when QO_3 then
|
3576
|
+
DOUBLE_QUATATION
|
3577
|
+
when AP_3 then
|
3578
|
+
AP_1
|
3579
|
+
when GT_3 then
|
3580
|
+
GT_1
|
3581
|
+
when LT_3 then
|
3582
|
+
LT_1
|
3583
|
+
when NBSP_3 then
|
3584
|
+
SPACE
|
3549
3585
|
end
|
3550
3586
|
end
|
3551
3587
|
|
@@ -3579,6 +3615,7 @@ module Meteor
|
|
3579
3615
|
|
3580
3616
|
KAIGYO_CODE = '(\r?\n|\r)'
|
3581
3617
|
NBSP_2 = ' '
|
3618
|
+
NBSP_3 = 'nbsp'
|
3582
3619
|
BR_1 = '\r?\n|\r'
|
3583
3620
|
BR_2 = '<br/>'
|
3584
3621
|
BR_3 = '<br\\/>'
|
@@ -3723,9 +3760,9 @@ module Meteor
|
|
3723
3760
|
def initialize(*args)
|
3724
3761
|
super(args)
|
3725
3762
|
case args.length
|
3726
|
-
when
|
3763
|
+
when ZERO
|
3727
3764
|
initialize_0
|
3728
|
-
when
|
3765
|
+
when ONE
|
3729
3766
|
initialize_1(args[0])
|
3730
3767
|
else
|
3731
3768
|
raise ArgumentError
|
@@ -4057,18 +4094,18 @@ module Meteor
|
|
4057
4094
|
#end
|
4058
4095
|
element.gsub!(@@pattern_unescape) do
|
4059
4096
|
case $1
|
4060
|
-
when
|
4061
|
-
|
4062
|
-
when
|
4063
|
-
|
4064
|
-
when
|
4065
|
-
|
4066
|
-
when
|
4067
|
-
|
4068
|
-
when
|
4069
|
-
|
4070
|
-
when
|
4071
|
-
|
4097
|
+
when AND_3 then
|
4098
|
+
AND_1
|
4099
|
+
when QO_3 then
|
4100
|
+
DOUBLE_QUATATION
|
4101
|
+
when AP_3 then
|
4102
|
+
AP_1
|
4103
|
+
when GT_3 then
|
4104
|
+
GT_1
|
4105
|
+
when LT_3 then
|
4106
|
+
LT_1
|
4107
|
+
when NBSP_3 then
|
4108
|
+
SPACE
|
4072
4109
|
end
|
4073
4110
|
end
|
4074
4111
|
|
@@ -4098,31 +4135,34 @@ module Meteor
|
|
4098
4135
|
#
|
4099
4136
|
# XMLパーサ
|
4100
4137
|
#
|
4101
|
-
class ParserImpl < Meteor::Core::Kernel
|
4138
|
+
class ParserImpl < Meteor::Core::Kernel
|
4139
|
+
|
4140
|
+
if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
|
4141
|
+
TABLE_FOR_ESCAPE_ = {
|
4142
|
+
'&' => '&',
|
4143
|
+
'"' => '"',
|
4144
|
+
'\'' => ''',
|
4145
|
+
'<' => '<',
|
4146
|
+
'>' => '>',
|
4147
|
+
}
|
4148
|
+
PATTERN_ESCAPE = '[&\"\'<>]'
|
4149
|
+
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
4150
|
+
else
|
4151
|
+
@@pattern_and_1 = Regexp.new(AND_1)
|
4152
|
+
@@pattern_lt_1 = Regexp.new(LT_1)
|
4153
|
+
@@pattern_gt_1 = Regexp.new(GT_1)
|
4154
|
+
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION)
|
4155
|
+
@@pattern_ap_1 = Regexp.new(AP_1)
|
4156
|
+
@@pattern_lt_2 = Regexp.new(LT_2)
|
4157
|
+
@@pattern_gt_2 = Regexp.new(GT_2)
|
4158
|
+
@@pattern_dq_2 = Regexp.new(QO_2)
|
4159
|
+
@@pattern_ap_2 = Regexp.new(AP_2)
|
4160
|
+
@@pattern_and_2 = Regexp.new(AND_2)
|
4161
|
+
end
|
4162
|
+
|
4163
|
+
|
4102
4164
|
|
4103
|
-
TABLE_FOR_ESCAPE_ = {
|
4104
|
-
'&' => '&',
|
4105
|
-
'"' => '"',
|
4106
|
-
'\'' => ''',
|
4107
|
-
'<' => '<',
|
4108
|
-
'>' => '>',
|
4109
|
-
}
|
4110
|
-
|
4111
|
-
PATTERN_ESCAPE = '[&\"\'<>]'
|
4112
4165
|
PATTERN_UNESCAPE = '&(amp|quot|apos|gt|lt);'
|
4113
|
-
|
4114
|
-
@@pattern_and_1 = Regexp.new(AND_1)
|
4115
|
-
@@pattern_lt_1 = Regexp.new(LT_1)
|
4116
|
-
@@pattern_gt_1 = Regexp.new(GT_1)
|
4117
|
-
@@pattern_dq_1 = Regexp.new(DOUBLE_QUATATION)
|
4118
|
-
@@pattern_ap_1 = Regexp.new(AP_1)
|
4119
|
-
@@pattern_lt_2 = Regexp.new(LT_2)
|
4120
|
-
@@pattern_gt_2 = Regexp.new(GT_2)
|
4121
|
-
@@pattern_dq_2 = Regexp.new(QO_2)
|
4122
|
-
@@pattern_ap_2 = Regexp.new(AP_2)
|
4123
|
-
@@pattern_and_2 = Regexp.new(AND_2)
|
4124
|
-
|
4125
|
-
@@pattern_escape = Regexp.new(PATTERN_ESCAPE)
|
4126
4166
|
@@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
|
4127
4167
|
|
4128
4168
|
@@pattern_set_mono1 = Regexp.new(SET_MONO_1)
|
@@ -4136,9 +4176,9 @@ module Meteor
|
|
4136
4176
|
super(args)
|
4137
4177
|
|
4138
4178
|
case args.length
|
4139
|
-
when
|
4179
|
+
when ZERO
|
4140
4180
|
initialize_0
|
4141
|
-
when
|
4181
|
+
when ONE
|
4142
4182
|
initialize_1(args[0])
|
4143
4183
|
else
|
4144
4184
|
raise ArgumentError
|
@@ -4275,16 +4315,16 @@ module Meteor
|
|
4275
4315
|
#else
|
4276
4316
|
element.gsub!(@@pattern_unescape) do
|
4277
4317
|
case $1
|
4278
|
-
when
|
4279
|
-
|
4280
|
-
when
|
4281
|
-
|
4282
|
-
when
|
4283
|
-
|
4284
|
-
when
|
4285
|
-
|
4286
|
-
when
|
4287
|
-
|
4318
|
+
when AND_3 then
|
4319
|
+
AND_1
|
4320
|
+
when QO_3 then
|
4321
|
+
DOUBLE_QUATATION
|
4322
|
+
when AP_3 then
|
4323
|
+
AP_1
|
4324
|
+
when GT_3 then
|
4325
|
+
GT_1
|
4326
|
+
when LT_3 then
|
4327
|
+
LT_1
|
4288
4328
|
end
|
4289
4329
|
end
|
4290
4330
|
#end
|
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.1.
|
4
|
+
version: 0.9.1.5
|
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-
|
12
|
+
date: 2009-05-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -64,7 +64,7 @@ requirements: []
|
|
64
64
|
rubyforge_project: meteor
|
65
65
|
rubygems_version: 1.2.0
|
66
66
|
signing_key:
|
67
|
-
specification_version:
|
67
|
+
specification_version: 3
|
68
68
|
summary: A lightweight (X)HTML & XML parser
|
69
69
|
test_files:
|
70
70
|
- test/meteor_test.rb
|