asip-meteor 0.9.0.5 → 0.9.0.6

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.
Files changed (3) hide show
  1. data/README +1 -1
  2. data/lib/meteor.rb +154 -326
  3. metadata +2 -2
data/README CHANGED
@@ -27,4 +27,4 @@ by asip <ys.ashida@gmail.com>
27
27
 
28
28
  Author:: asip <ys.ashida@gmail.com>
29
29
  Copyright:: Copyright (c) 2008 asip
30
- License:: GPL V2
30
+ License:: LGPL V2.1
data/lib/meteor.rb CHANGED
@@ -4,21 +4,21 @@
4
4
  # Copyright (C) 2008 Yasumasa Ashida.
5
5
  #
6
6
  # This program is free software; you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation; either version 2 of the License, or
7
+ # it under the terms of the GNU Lesser General Public License as published by
8
+ # the Free Software Foundation; either version 2.1 of the License, or
9
9
  # (at your option) any later version.
10
10
  #
11
11
  # This program is distributed in the hope that it will be useful,
12
12
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
13
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
14
+ # GNU Lesser General Public License for more details.
15
15
  #
16
- # You should have received a copy of the GNU General Public License
16
+ # You should have received a copy of the GNU Lesser General Public License
17
17
  # along with this program; if not, write to the Free Software
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.0.5
21
+ # @version 0.9.0.6
22
22
  #
23
23
  if RUBY_VERSION < '1.9.0' then
24
24
  require 'kconv'
@@ -27,7 +27,7 @@ end
27
27
 
28
28
  module Meteor
29
29
 
30
- VERSION = "0.9.0.5"
30
+ VERSION = "0.9.0.6"
31
31
 
32
32
  #
33
33
  # 要素クラス
@@ -1227,195 +1227,7 @@ module Meteor
1227
1227
  @pattern_2 = Meteor::Core::Util::PatternCache.get(@pattern_cc_2)
1228
1228
  @pattern_1b = Meteor::Core::Util::PatternCache.get(@pattern_cc_1b);
1229
1229
 
1230
- if RUBY_VERSION >= '1.9.0' then
1231
-
1232
- @position = 0
1233
-
1234
- while (@res = @pattern.match(@root.document,@position)) || @cnt > 0
1235
-
1236
- if @res then
1237
-
1238
- if @cnt > 0 then
1239
-
1240
- @position2 = @res.end(0)
1241
-
1242
- @res = @pattern_2.match(@root.document,@position)
1243
-
1244
- if @res then
1245
-
1246
- @position = @res.end(0)
1247
-
1248
- if @position > @position2 then
1249
-
1250
- if @cnt == 0 then
1251
- @sbuf << @pattern_cc_1_1
1252
- else
1253
- @sbuf << @pattern_cc_1_2
1254
- end
1255
-
1256
- @cnt += 1
1257
-
1258
- @position = @position2
1259
- else
1260
-
1261
- @cnt -= 1
1262
-
1263
- if @cnt != 0 then
1264
- @sbuf << @pattern_cc_2_1
1265
- else
1266
- @sbuf << @pattern_cc_2_2
1267
- end
1268
-
1269
- if @cnt == 0 then
1270
- break
1271
- end
1272
- end
1273
- else
1274
-
1275
- if @cnt == 0 then
1276
- @sbuf << @pattern_cc_1_1
1277
- else
1278
- @sbuf << @pattern_cc_1_2
1279
- end
1280
-
1281
- @cnt += 1
1282
-
1283
- @position = @position2
1284
- end
1285
- else
1286
-
1287
- @position = @res.end(0)
1288
-
1289
- if @cnt == 0 then
1290
- @sbuf << @pattern_cc_1_1
1291
- else
1292
- @sbuf << @pattern_cc_1_2
1293
- end
1294
-
1295
- @cnt += 1
1296
- end
1297
- else
1298
-
1299
- @res = @pattern_2.match(@root.document,@position)
1300
-
1301
- if @res then
1302
- @cnt -= 1
1303
-
1304
- if @cnt != 0 then
1305
- @sbuf << @pattern_cc_2_1
1306
- else
1307
- @sbuf << @pattern_cc_2_2
1308
- end
1309
-
1310
- @position = @res.end(0)
1311
- end
1312
-
1313
- if !@res then
1314
- break
1315
- end
1316
-
1317
- if @cnt == 0 then
1318
- break
1319
- end
1320
- end
1321
-
1322
- @pattern = @pattern_1b
1323
- end
1324
- else
1325
-
1326
- @rx_document = @root.document
1327
-
1328
- while (@res = @pattern.match(@rx_document)) || @cnt > 0
1329
-
1330
- if @res then
1331
-
1332
- if @cnt > 0 then
1333
-
1334
- @rx_document2 = @res.post_match
1335
-
1336
- @res = @pattern_2.match(@rx_document)
1337
-
1338
- if @res then
1339
-
1340
- @rx_document = @res.post_match
1341
-
1342
- if @rx_document2.length > @rx_document.length then
1343
-
1344
- if @cnt == 0 then
1345
- @sbuf << @pattern_cc_1_1
1346
- else
1347
- @sbuf << @pattern_cc_1_2
1348
- end
1349
-
1350
- @cnt += 1
1351
-
1352
- @rx_document = @rx_document2
1353
- else
1354
-
1355
- @cnt -= 1
1356
-
1357
- if @cnt != 0 then
1358
- @sbuf << @pattern_cc_2_1
1359
- else
1360
- @sbuf << @pattern_cc_2_2
1361
- end
1362
-
1363
- if @cnt == 0 then
1364
- break
1365
- end
1366
- end
1367
- else
1368
-
1369
- if @cnt == 0 then
1370
- @sbuf << @pattern_cc_1_1
1371
- else
1372
- @sbuf << @pattern_cc_1_2
1373
- end
1374
-
1375
- @cnt += 1
1376
-
1377
- @rx_document = @rx_document2
1378
- end
1379
- else
1380
-
1381
- @rx_document = @res.post_match
1382
-
1383
- if @cnt == 0 then
1384
- @sbuf << @pattern_cc_1_1
1385
- else
1386
- @sbuf << @pattern_cc_1_2
1387
- end
1388
-
1389
- @cnt += 1
1390
- end
1391
- else
1392
-
1393
- @res = @pattern_2.match(@rx_document)
1394
-
1395
- if @res then
1396
- @cnt -= 1
1397
-
1398
- if @cnt != 0 then
1399
- @sbuf << @pattern_cc_2_1
1400
- else
1401
- @sbuf << @pattern_cc_2_2
1402
- end
1403
-
1404
- @rx_document = @res.post_match
1405
- end
1406
-
1407
- if !@res then
1408
- break
1409
- end
1410
-
1411
- if @cnt == 0 then
1412
- break
1413
- end
1414
- end
1415
-
1416
- @pattern = @pattern_1b
1417
- end
1418
- end
1230
+ create_element_pattern
1419
1231
 
1420
1232
  @pattern_cc = @sbuf
1421
1233
 
@@ -1634,270 +1446,276 @@ module Meteor
1634
1446
  @pattern_2 = Meteor::Core::Util::PatternCache.get(@pattern_cc_2)
1635
1447
  @pattern_1b = Meteor::Core::Util::PatternCache.get(@pattern_cc_1b);
1636
1448
 
1449
+ create_element_pattern
1450
+
1451
+ @pattern_cc = @sbuf
1452
+
1453
+ if @sbuf.length == 0 || @cnt != 0 then
1454
+ # raise NoSuchElementException.new(elmName,attrName1,attrValue1,attrName2,attrValue2);
1455
+ return nil
1456
+ end
1457
+
1458
+ @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
1459
+ @res = @pattern.match(@root.document)
1460
+
1461
+ @res
1462
+ end
1463
+ private :elementWithContent_5_2
1464
+
1465
+ def elementWithoutContent_5(elmName)
1466
+ elementWithoutContent_5_1(elmName,TAG_SEARCH_NC_2_3_2_2);
1467
+ end
1468
+ private :elementWithoutContent_5
1469
+
1470
+ def elementWithoutContent_5_1(elmName,closer)
1471
+
1472
+ #要素
1473
+ @elm_ = Element.new(elmName)
1474
+ #属性
1475
+ @elm_.attributes = @res[1]
1476
+ #全体
1477
+ @elm_.document = @res[0]
1478
+ #空要素検索用パターン
1479
+ @pattern_cc = '' << TAG_OPEN << @_elmName << TAG_SEARCH_NC_2_1_2 << @_attrName1 << ATTR_EQ
1480
+ @pattern_cc << @_attrValue1 << TAG_SEARCH_NC_2_6 << @_attrName2 << ATTR_EQ
1481
+ @pattern_cc << @_attrValue2 << TAG_SEARCH_NC_2_7 << @_attrName2 << ATTR_EQ
1482
+ @pattern_cc << @_attrValue2 << TAG_SEARCH_NC_2_6 << @_attrName1 << ATTR_EQ
1483
+ @pattern_cc << @_attrValue1 << closer
1484
+ @elm_.pattern = @pattern_cc
1485
+
1486
+ @elm_.parser = self
1487
+ end
1488
+ private :elementWithoutContent_5_1
1489
+
1490
+ #
1491
+ # 属性1・属性2(属性名="属性値")で検索し、要素を取得する
1492
+ #
1493
+ # @param [String] attrName1 属性名1
1494
+ # @param [String] attrValue1 属性値1
1495
+ # @param [String] attrName2 属性名2
1496
+ # @param [String]attrValue2 属性値2
1497
+ # @return [Meteor::Element] 要素
1498
+ #
1499
+ def element_4(attrName1,attrValue1,attrName2,attrValue2)
1500
+
1501
+ @_attrName1 = escapeRegex(attrName1)
1502
+ @_attrName2 = escapeRegex(attrName2)
1503
+ @_attrValue1 = escapeRegex(attrValue1)
1504
+ @_attrValue2 = escapeRegex(attrValue2)
1505
+
1506
+ @pattern_cc = '' << TAG_SEARCH_3_1_2_2 << @_attrName1 << ATTR_EQ
1507
+ @pattern_cc << @_attrValue1 << TAG_SEARCH_2_6 << @_attrName2 << ATTR_EQ
1508
+ @pattern_cc << @_attrValue2 << TAG_SEARCH_2_7 << @_attrName2 << ATTR_EQ
1509
+ @pattern_cc << @_attrValue2 << TAG_SEARCH_2_6 << @_attrName1 << ATTR_EQ
1510
+ @pattern_cc << @_attrValue1 << TAG_SEARCH_2_4_2_3
1511
+
1512
+ @pattern = PatternCache.get(@pattern_cc)
1513
+
1514
+ @res = @pattern.match(@root.document)
1515
+
1516
+ if @res then
1517
+ @elm_ = element_5(@res[1], attrName1, attrValue1,attrName2, attrValue2);
1518
+ else
1519
+ @elm_ = nil
1520
+ end
1521
+
1522
+ @elm_
1523
+ end
1524
+ private :element_4
1525
+
1526
+ def create_element_pattern
1527
+
1637
1528
  if RUBY_VERSION >= '1.9.0' then
1638
-
1529
+
1639
1530
  @position = 0
1640
-
1531
+
1641
1532
  while (@res = @pattern.match(@root.document,@position)) || @cnt > 0
1642
-
1533
+
1643
1534
  if @res then
1644
-
1535
+
1645
1536
  if @cnt > 0 then
1646
-
1537
+
1647
1538
  @position2 = @res.end(0)
1648
-
1539
+
1649
1540
  @res = @pattern_2.match(@root.document,@position)
1650
-
1541
+
1651
1542
  if @res then
1652
-
1543
+
1653
1544
  @position = @res.end(0)
1654
-
1545
+
1655
1546
  if @position > @position2 then
1656
-
1547
+
1657
1548
  if @cnt == 0 then
1658
1549
  @sbuf << @pattern_cc_1_1
1659
1550
  else
1660
1551
  @sbuf << @pattern_cc_1_2
1661
1552
  end
1662
-
1553
+
1663
1554
  @cnt << 1
1664
-
1555
+
1665
1556
  @position = @position2
1666
1557
  else
1667
-
1558
+
1668
1559
  @cnt -= 1
1669
-
1560
+
1670
1561
  if @cnt != 0 then
1671
1562
  @sbuf << @pattern_cc_2_1
1672
1563
  else
1673
1564
  @sbuf << @pattern_cc_2_2
1674
1565
  end
1675
-
1566
+
1676
1567
  if @cnt == 0 then
1677
1568
  break
1678
1569
  end
1679
1570
  end
1680
1571
  else
1681
-
1572
+
1682
1573
  if @cnt == 0 then
1683
1574
  @sbuf << @pattern_cc_1_1
1684
1575
  else
1685
1576
  @sbuf << @pattern_cc_1_2
1686
1577
  end
1687
-
1578
+
1688
1579
  @cnt += 1
1689
-
1580
+
1690
1581
  @position = @position2
1691
1582
  end
1692
1583
  else
1693
1584
  @position = @res.end(0)
1694
-
1585
+
1695
1586
  if @cnt == 0 then
1696
1587
  @sbuf << @pattern_cc_1_1
1697
1588
  else
1698
1589
  @sbuf << @pattern_cc_1_2
1699
1590
  end
1700
-
1591
+
1701
1592
  @cnt += 1
1702
1593
  end
1703
1594
  else
1704
-
1595
+
1705
1596
  @res = @pattern_2.match(@root.document,@position)
1706
-
1597
+
1707
1598
  if @res then
1708
-
1599
+
1709
1600
  @cnt -= 1
1710
-
1601
+
1711
1602
  if @cnt != 0 then
1712
1603
  @sbuf << @pattern_cc_2_1
1713
1604
  else
1714
1605
  @sbuf << @pattern_cc_2_2
1715
1606
  end
1716
-
1607
+
1717
1608
  @position = @res.end(0)
1718
1609
  end
1719
-
1610
+
1720
1611
  if @cnt == 0 then
1721
1612
  break
1722
1613
  end
1723
-
1614
+
1724
1615
  if !@res then
1725
1616
  break
1726
1617
  end
1727
1618
  end
1728
-
1619
+
1729
1620
  @pattern = @pattern_1b
1730
1621
  end
1731
1622
  else
1732
-
1623
+
1733
1624
  @rx_document = @root.document
1734
-
1625
+
1735
1626
  while (@res = @pattern.match(@rx_document)) || @cnt > 0
1736
-
1627
+
1737
1628
  if @res then
1738
-
1629
+
1739
1630
  if @cnt > 0 then
1740
-
1631
+
1741
1632
  @rx_document2 = @res.post_match
1742
-
1633
+
1743
1634
  @res = @pattern_2.match(@rx_document)
1744
-
1635
+
1745
1636
  if @res then
1746
-
1637
+
1747
1638
  @rx_document = @res.post_match
1748
-
1639
+
1749
1640
  if @rx_document2.length > @rx_document.length then
1750
-
1641
+
1751
1642
  if @cnt == 0 then
1752
1643
  @sbuf << @pattern_cc_1_1
1753
1644
  else
1754
1645
  @sbuf << @pattern_cc_1_2
1755
1646
  end
1756
-
1647
+
1757
1648
  @cnt += 1
1758
-
1649
+
1759
1650
  @rx_document = @rx_document2
1760
1651
  else
1761
-
1652
+
1762
1653
  @cnt -= 1
1763
-
1654
+
1764
1655
  if @cnt != 0 then
1765
1656
  @sbuf << @pattern_cc_2_1
1766
1657
  else
1767
1658
  @sbuf << @pattern_cc_2_2
1768
1659
  end
1769
-
1660
+
1770
1661
  if @cnt == 0 then
1771
1662
  break
1772
1663
  end
1773
1664
  end
1774
1665
  else
1775
-
1666
+
1776
1667
  if @cnt == 0 then
1777
1668
  @sbuf << @pattern_cc_1_1
1778
1669
  else
1779
1670
  @sbuf << @pattern_cc_1_2
1780
1671
  end
1781
-
1672
+
1782
1673
  @cnt += 1
1783
-
1674
+
1784
1675
  @rx_document = @rx_document2
1785
1676
  end
1786
1677
  else
1787
1678
  @rx_document = @res.post_match
1788
-
1679
+
1789
1680
  if @cnt == 0 then
1790
1681
  @sbuf << @pattern_cc_1_1
1791
1682
  else
1792
1683
  @sbuf << @pattern_cc_1_2
1793
1684
  end
1794
-
1685
+
1795
1686
  @cnt += 1
1796
1687
  end
1797
1688
  else
1798
-
1689
+
1799
1690
  @res = @pattern_2.match(@rx_document)
1800
-
1691
+
1801
1692
  if @res then
1802
-
1693
+
1803
1694
  @cnt -= 1
1804
-
1695
+
1805
1696
  if @cnt != 0 then
1806
1697
  @sbuf << @pattern_cc_2_1
1807
1698
  else
1808
1699
  @sbuf << @pattern_cc_2_2
1809
1700
  end
1810
-
1701
+
1811
1702
  @rx_document = @res.post_match
1812
1703
  end
1813
-
1704
+
1814
1705
  if @cnt == 0 then
1815
1706
  break
1816
1707
  end
1817
-
1708
+
1818
1709
  if !@res then
1819
1710
  break
1820
1711
  end
1821
1712
  end
1822
-
1713
+
1823
1714
  @pattern = @pattern_1b
1824
1715
  end
1825
1716
  end
1826
-
1827
- @pattern_cc = @sbuf
1828
-
1829
- if @sbuf.length == 0 || @cnt != 0 then
1830
- # raise NoSuchElementException.new(elmName,attrName1,attrValue1,attrName2,attrValue2);
1831
- return nil
1832
- end
1833
-
1834
- @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
1835
- @res = @pattern.match(@root.document)
1836
-
1837
- @res
1838
- end
1839
- private :elementWithContent_5_2
1840
-
1841
- def elementWithoutContent_5(elmName)
1842
- elementWithoutContent_5_1(elmName,TAG_SEARCH_NC_2_3_2_2);
1843
- end
1844
- private :elementWithoutContent_5
1845
-
1846
- def elementWithoutContent_5_1(elmName,closer)
1847
-
1848
- #要素
1849
- @elm_ = Element.new(elmName)
1850
- #属性
1851
- @elm_.attributes = @res[1]
1852
- #全体
1853
- @elm_.document = @res[0]
1854
- #空要素検索用パターン
1855
- @pattern_cc = '' << TAG_OPEN << @_elmName << TAG_SEARCH_NC_2_1_2 << @_attrName1 << ATTR_EQ
1856
- @pattern_cc << @_attrValue1 << TAG_SEARCH_NC_2_6 << @_attrName2 << ATTR_EQ
1857
- @pattern_cc << @_attrValue2 << TAG_SEARCH_NC_2_7 << @_attrName2 << ATTR_EQ
1858
- @pattern_cc << @_attrValue2 << TAG_SEARCH_NC_2_6 << @_attrName1 << ATTR_EQ
1859
- @pattern_cc << @_attrValue1 << closer
1860
- @elm_.pattern = @pattern_cc
1861
-
1862
- @elm_.parser = self
1863
- end
1864
- private :elementWithoutContent_5_1
1865
-
1866
- #
1867
- # 属性1・属性2(属性名="属性値")で検索し、要素を取得する
1868
- #
1869
- # @param [String] attrName1 属性名1
1870
- # @param [String] attrValue1 属性値1
1871
- # @param [String] attrName2 属性名2
1872
- # @param [String]attrValue2 属性値2
1873
- # @return [Meteor::Element] 要素
1874
- #
1875
- def element_4(attrName1,attrValue1,attrName2,attrValue2)
1876
-
1877
- @_attrName1 = escapeRegex(attrName1)
1878
- @_attrName2 = escapeRegex(attrName2)
1879
- @_attrValue1 = escapeRegex(attrValue1)
1880
- @_attrValue2 = escapeRegex(attrValue2)
1881
-
1882
- @pattern_cc = '' << TAG_SEARCH_3_1_2_2 << @_attrName1 << ATTR_EQ
1883
- @pattern_cc << @_attrValue1 << TAG_SEARCH_2_6 << @_attrName2 << ATTR_EQ
1884
- @pattern_cc << @_attrValue2 << TAG_SEARCH_2_7 << @_attrName2 << ATTR_EQ
1885
- @pattern_cc << @_attrValue2 << TAG_SEARCH_2_6 << @_attrName1 << ATTR_EQ
1886
- @pattern_cc << @_attrValue1 << TAG_SEARCH_2_4_2_3
1887
-
1888
- @pattern = PatternCache.get(@pattern_cc)
1889
-
1890
- @res = @pattern.match(@root.document)
1891
-
1892
- if @res then
1893
- @elm_ = element_5(@res[1], attrName1, attrValue1,attrName2, attrValue2);
1894
- else
1895
- @elm_ = nil
1896
- end
1897
-
1898
- @elm_
1899
1717
  end
1900
- private :element_4
1718
+ private :create_element_pattern
1901
1719
 
1902
1720
  #
1903
1721
  # 要素の属性をセットする or 属性の値を取得する
@@ -1947,6 +1765,7 @@ module Meteor
1947
1765
  @e_cache.store(elm.object_id, elm)
1948
1766
  end
1949
1767
  end
1768
+ elm
1950
1769
  end
1951
1770
  private :setAttribute_3
1952
1771
 
@@ -2070,6 +1889,7 @@ module Meteor
2070
1889
  if @root.hook || @root.monoHook then
2071
1890
  setAttribute_3(@root.mutableElement, attrName, attrValue)
2072
1891
  end
1892
+ @root.mutableElement
2073
1893
  end
2074
1894
  private :setAttribute_2
2075
1895
 
@@ -2184,6 +2004,7 @@ module Meteor
2184
2004
  @e_cache.store(elm.object_id,elm)
2185
2005
  end
2186
2006
  end
2007
+ elm
2187
2008
  end
2188
2009
  private :setAttribute_2_m
2189
2010
 
@@ -2234,7 +2055,8 @@ module Meteor
2234
2055
  if !elm.parent then
2235
2056
  @e_cache.store(elm.object_id,elm)
2236
2057
  end
2237
-
2058
+
2059
+ elm
2238
2060
  end
2239
2061
  private :setContent_3
2240
2062
 
@@ -2271,6 +2093,8 @@ module Meteor
2271
2093
  if @root.monoHook then
2272
2094
  setContent_3(@root.mutableElement, content, entityRef)
2273
2095
  end
2096
+
2097
+ elm
2274
2098
  end
2275
2099
  private :setContent_2_b
2276
2100
 
@@ -2320,6 +2144,8 @@ module Meteor
2320
2144
  @e_cache.store(elm.object_id,elm)
2321
2145
  end
2322
2146
  end
2147
+
2148
+ elm
2323
2149
  end
2324
2150
  private :removeAttribute_2
2325
2151
 
@@ -2340,6 +2166,8 @@ module Meteor
2340
2166
  if @root.hook || @root.monoHook then
2341
2167
  removeAttribute_2(@root.mutableElement, attrName)
2342
2168
  end
2169
+
2170
+ @root.mutableElement
2343
2171
  end
2344
2172
  private :removeAttribute_1
2345
2173
 
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.0.5
4
+ version: 0.9.0.6
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: 2008-11-15 00:00:00 -08:00
12
+ date: 2009-03-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15