asip-meteor 0.9.1.6 → 0.9.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/meteor.rb +126 -110
- metadata +2 -2
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.7
|
22
22
|
#
|
23
23
|
|
24
24
|
|
@@ -31,7 +31,7 @@ end
|
|
31
31
|
|
32
32
|
module Meteor
|
33
33
|
|
34
|
-
VERSION = "0.9.1.
|
34
|
+
VERSION = "0.9.1.7"
|
35
35
|
|
36
36
|
ZERO = 0
|
37
37
|
ONE = 1
|
@@ -84,8 +84,8 @@ module Meteor
|
|
84
84
|
#@mono = false
|
85
85
|
#@parent = false
|
86
86
|
@arguments = AttributeMap.new
|
87
|
-
|
88
|
-
@usable = ZERO
|
87
|
+
#@origin = self.object_id
|
88
|
+
@usable = ZERO
|
89
89
|
end
|
90
90
|
private :initialize_s
|
91
91
|
|
@@ -105,22 +105,27 @@ module Meteor
|
|
105
105
|
@parent = elm.parent
|
106
106
|
@parser = elm.parser
|
107
107
|
@arguments = AttributeMap.new(elm.arguments)
|
108
|
-
|
108
|
+
#@origin = elm.object_id
|
109
109
|
@usable = ZERO
|
110
|
+
elm.parser.e_cache.store(elm.object_id,self)
|
110
111
|
end
|
111
112
|
private :initialize_e
|
112
113
|
|
113
114
|
def self.new!(elm)
|
114
|
-
|
115
|
+
#@obj = elm.parser.e_cache[elm.origin]
|
116
|
+
@obj = elm.parser.e_cache[elm.object_id]
|
115
117
|
if @obj then
|
116
118
|
@obj.attributes = String.new(elm.attributes)
|
119
|
+
@obj.mixed_content = String.new(elm.mixed_content)
|
117
120
|
@obj.pattern = String.new(elm.pattern)
|
118
121
|
@obj.document = String.new(elm.document)
|
119
122
|
@obj.arguments = AttributeMap.new(elm.arguments)
|
120
123
|
@obj.usable = ZERO
|
121
124
|
@obj
|
122
125
|
else
|
123
|
-
self.new(elm)
|
126
|
+
@obj = self.new(elm)
|
127
|
+
#elm.parser.e_cache.store(elm.origin,@obj)
|
128
|
+
@obj
|
124
129
|
end
|
125
130
|
|
126
131
|
end
|
@@ -138,7 +143,7 @@ module Meteor
|
|
138
143
|
attr_accessor :type_value
|
139
144
|
attr_accessor :arguments
|
140
145
|
attr_accessor :usable
|
141
|
-
attr_accessor :origin
|
146
|
+
#attr_accessor :origin
|
142
147
|
|
143
148
|
#
|
144
149
|
# 属性を編集する or 属性の値を取得する
|
@@ -174,7 +179,7 @@ module Meteor
|
|
174
179
|
#
|
175
180
|
# 内容をセットする
|
176
181
|
#
|
177
|
-
# @param [String] value
|
182
|
+
# @param [String] value 内容
|
178
183
|
#
|
179
184
|
def content=(value)
|
180
185
|
@parser.content(self,value)
|
@@ -1058,6 +1063,8 @@ module Meteor
|
|
1058
1063
|
else
|
1059
1064
|
raise ArgumentError
|
1060
1065
|
end
|
1066
|
+
@e_cache.store(@elm_.object_id,@elm_)
|
1067
|
+
@elm_
|
1061
1068
|
end
|
1062
1069
|
|
1063
1070
|
#
|
@@ -1267,6 +1274,7 @@ module Meteor
|
|
1267
1274
|
|
1268
1275
|
@elm_.parser = self
|
1269
1276
|
end
|
1277
|
+
@elm_
|
1270
1278
|
end
|
1271
1279
|
private :element_with_3_1
|
1272
1280
|
|
@@ -1335,6 +1343,8 @@ module Meteor
|
|
1335
1343
|
@elm_.pattern = @pattern_cc
|
1336
1344
|
|
1337
1345
|
@elm_.parser = self
|
1346
|
+
|
1347
|
+
@elm_
|
1338
1348
|
end
|
1339
1349
|
private :element_without_3_1
|
1340
1350
|
|
@@ -1491,6 +1501,7 @@ module Meteor
|
|
1491
1501
|
|
1492
1502
|
@elm_.parser = self
|
1493
1503
|
end
|
1504
|
+
@elm_
|
1494
1505
|
end
|
1495
1506
|
private :element_with_5_1
|
1496
1507
|
|
@@ -1570,6 +1581,8 @@ module Meteor
|
|
1570
1581
|
@elm_.pattern = @pattern_cc
|
1571
1582
|
|
1572
1583
|
@elm_.parser = self
|
1584
|
+
|
1585
|
+
@elm_
|
1573
1586
|
end
|
1574
1587
|
private :element_without_5_1
|
1575
1588
|
|
@@ -1849,7 +1862,7 @@ module Meteor
|
|
1849
1862
|
elm.arguments.store(attr_name, attr_value)
|
1850
1863
|
end
|
1851
1864
|
|
1852
|
-
|
1865
|
+
#@e_cache.store(elm.origin, elm)
|
1853
1866
|
end
|
1854
1867
|
end
|
1855
1868
|
elm
|
@@ -2089,9 +2102,9 @@ module Meteor
|
|
2089
2102
|
end
|
2090
2103
|
end
|
2091
2104
|
|
2092
|
-
if !elm.parent then
|
2093
|
-
|
2094
|
-
end
|
2105
|
+
#if !elm.parent then
|
2106
|
+
# @e_cache.store(elm.origin,elm)
|
2107
|
+
#end
|
2095
2108
|
end
|
2096
2109
|
elm
|
2097
2110
|
end
|
@@ -2141,9 +2154,9 @@ module Meteor
|
|
2141
2154
|
|
2142
2155
|
elm.mixed_content = content
|
2143
2156
|
|
2144
|
-
if !elm.parent then
|
2145
|
-
|
2146
|
-
end
|
2157
|
+
#if !elm.parent then
|
2158
|
+
# @e_cache.store(elm.origin,elm)
|
2159
|
+
#end
|
2147
2160
|
|
2148
2161
|
elm
|
2149
2162
|
end
|
@@ -2230,7 +2243,7 @@ module Meteor
|
|
2230
2243
|
elm.arguments.delete(attr_name)
|
2231
2244
|
end
|
2232
2245
|
|
2233
|
-
|
2246
|
+
#@e_cache.store(elm.origin,elm)
|
2234
2247
|
end
|
2235
2248
|
end
|
2236
2249
|
|
@@ -2267,7 +2280,8 @@ module Meteor
|
|
2267
2280
|
#
|
2268
2281
|
def remove_element(elm)
|
2269
2282
|
replace(elm,EMPTY)
|
2270
|
-
|
2283
|
+
#@e_cache.delete(elm.origin)
|
2284
|
+
elm.usable = ONE
|
2271
2285
|
end
|
2272
2286
|
|
2273
2287
|
#
|
@@ -2683,20 +2697,21 @@ module Meteor
|
|
2683
2697
|
#
|
2684
2698
|
# イニシャライザ
|
2685
2699
|
#
|
2700
|
+
|
2686
2701
|
def initialize
|
2687
2702
|
end
|
2688
|
-
|
2703
|
+
|
2689
2704
|
def self.get(*args)
|
2690
2705
|
case args.length
|
2691
|
-
|
2692
|
-
|
2693
|
-
|
2694
|
-
|
2695
|
-
|
2696
|
-
|
2706
|
+
when ONE
|
2707
|
+
get_1(args[0])
|
2708
|
+
when TWO
|
2709
|
+
get_2(args[0], args[1])
|
2710
|
+
else
|
2711
|
+
raise ArgumentError
|
2697
2712
|
end
|
2698
2713
|
end
|
2699
|
-
|
2714
|
+
|
2700
2715
|
#
|
2701
2716
|
# パターンを取得する
|
2702
2717
|
# @param [String] regex 正規表現
|
@@ -2710,26 +2725,26 @@ module Meteor
|
|
2710
2725
|
if !@@regex_cache[regex.to_sym] then
|
2711
2726
|
#pattern = Regexp.new(regex)
|
2712
2727
|
#@@regex_cache[regex] = pattern
|
2713
|
-
@@regex_cache[regex.to_sym] = Regexp.new(regex,Regexp::MULTILINE)
|
2728
|
+
@@regex_cache[regex.to_sym] = Regexp.new(regex, Regexp::MULTILINE)
|
2714
2729
|
end
|
2715
|
-
|
2730
|
+
|
2716
2731
|
#return pattern
|
2717
2732
|
@@regex_cache[regex.to_sym]
|
2718
2733
|
elsif regex.kind_of?(Symbol) then
|
2719
2734
|
if !@@regex_cache[regex] then
|
2720
|
-
@@regex_cache[regex] = Regexp.new(regex.to_s,Regexp::MULTILINE)
|
2735
|
+
@@regex_cache[regex] = Regexp.new(regex.to_s, Regexp::MULTILINE)
|
2721
2736
|
end
|
2722
|
-
|
2737
|
+
|
2723
2738
|
@@regex_cache[regex]
|
2724
|
-
end
|
2739
|
+
end
|
2725
2740
|
end
|
2726
|
-
|
2741
|
+
|
2727
2742
|
#
|
2728
2743
|
# パターンを取得する
|
2729
2744
|
# @param [String] regex 正規表現
|
2730
2745
|
# @return [Regexp] パターン
|
2731
2746
|
#
|
2732
|
-
def self.get_2(regex,option)
|
2747
|
+
def self.get_2(regex, option)
|
2733
2748
|
#pattern = @@regex_cache[regex]
|
2734
2749
|
#
|
2735
2750
|
#if pattern == nil then
|
@@ -2737,99 +2752,100 @@ module Meteor
|
|
2737
2752
|
if !@@regex_cache[regex.to_sym] then
|
2738
2753
|
#pattern = Regexp.new(regex)
|
2739
2754
|
#@@regex_cache[regex] = pattern
|
2740
|
-
@@regex_cache[regex.to_sym] = Regexp.new(regex,option)
|
2755
|
+
@@regex_cache[regex.to_sym] = Regexp.new(regex, option)
|
2741
2756
|
end
|
2742
|
-
|
2757
|
+
|
2743
2758
|
#return pattern
|
2744
2759
|
@@regex_cache[regex.to_sym]
|
2745
2760
|
elsif regex.kind_of?(Symbol) then
|
2746
2761
|
if !@@regex_cache[regex] then
|
2747
|
-
@@regex_cache[regex] = Regexp.new(regex.to_s,option)
|
2762
|
+
@@regex_cache[regex] = Regexp.new(regex.to_s, option)
|
2748
2763
|
end
|
2749
|
-
|
2764
|
+
|
2750
2765
|
@@regex_cache[regex]
|
2751
|
-
end
|
2766
|
+
end
|
2752
2767
|
end
|
2753
2768
|
end
|
2754
|
-
|
2755
|
-
|
2756
|
-
|
2757
|
-
|
2758
|
-
|
2759
|
-
|
2760
|
-
|
2761
|
-
|
2762
|
-
attr_accessor :keys
|
2763
|
-
attr_accessor :values
|
2764
|
-
|
2765
|
-
def store(key, value)
|
2766
|
-
super(key, value)
|
2767
|
-
unless @keys.include?(key)
|
2768
|
-
@keys << key
|
2769
|
-
@values << value
|
2769
|
+
|
2770
|
+
if RUBY_VERSION < RUBY_VERSION_1_9_0 then
|
2771
|
+
class OrderHash <Hash
|
2772
|
+
|
2773
|
+
def initialize
|
2774
|
+
@keys = Array.new
|
2775
|
+
@values = Array.new
|
2770
2776
|
end
|
2771
|
-
|
2772
|
-
|
2773
|
-
|
2774
|
-
|
2775
|
-
|
2776
|
-
|
2777
|
-
|
2778
|
-
|
2779
|
-
|
2780
|
-
|
2781
|
-
@keys.delete(key)
|
2782
|
-
@values.delete(fetch(key))
|
2783
|
-
super(key)
|
2784
|
-
elsif
|
2785
|
-
yield(key)
|
2777
|
+
|
2778
|
+
attr_accessor :keys
|
2779
|
+
attr_accessor :values
|
2780
|
+
|
2781
|
+
def store(key, value)
|
2782
|
+
super(key, value)
|
2783
|
+
unless @keys.include?(key)
|
2784
|
+
@keys << key
|
2785
|
+
@values << value
|
2786
|
+
end
|
2786
2787
|
end
|
2787
|
-
|
2788
|
-
|
2789
|
-
|
2790
|
-
|
2791
|
-
|
2792
|
-
end
|
2793
|
-
|
2794
|
-
def each
|
2795
|
-
@keys.each do |k|
|
2796
|
-
arr_tmp = Array.new
|
2797
|
-
arr_tmp << k
|
2798
|
-
arr_tmp << self[k]
|
2799
|
-
yield(arr_tmp)
|
2788
|
+
|
2789
|
+
def clear
|
2790
|
+
@keys.clear
|
2791
|
+
@values.clear
|
2792
|
+
super
|
2800
2793
|
end
|
2801
|
-
|
2802
|
-
|
2803
|
-
|
2804
|
-
|
2805
|
-
|
2806
|
-
|
2794
|
+
|
2795
|
+
def delete(key)
|
2796
|
+
if @keys.include?(key)
|
2797
|
+
@keys.delete(key)
|
2798
|
+
@values.delete(fetch(key))
|
2799
|
+
super(key)
|
2800
|
+
elsif yield(key)
|
2801
|
+
end
|
2807
2802
|
end
|
2808
|
-
|
2809
|
-
|
2810
|
-
|
2811
|
-
|
2812
|
-
|
2813
|
-
@keys.each do |k|
|
2814
|
-
arg_arr = Array.new
|
2815
|
-
arg_arr << k
|
2816
|
-
arg_arr << self[k]
|
2817
|
-
arr_tmp << yield(arg_arr)
|
2803
|
+
|
2804
|
+
#superとして、Hash#[]=を呼び出す
|
2805
|
+
|
2806
|
+
def []=(key, value)
|
2807
|
+
store(key, value)
|
2818
2808
|
end
|
2819
|
-
|
2820
|
-
|
2821
|
-
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
2825
|
-
|
2826
|
-
|
2809
|
+
|
2810
|
+
def each
|
2811
|
+
@keys.each do |k|
|
2812
|
+
arr_tmp = Array.new
|
2813
|
+
arr_tmp << k
|
2814
|
+
arr_tmp << self[k]
|
2815
|
+
yield(arr_tmp)
|
2816
|
+
end
|
2817
|
+
return self
|
2827
2818
|
end
|
2828
|
-
|
2829
|
-
|
2830
|
-
|
2819
|
+
|
2820
|
+
def each_pair
|
2821
|
+
@keys.each do |k|
|
2822
|
+
yield(k, self[k])
|
2823
|
+
end
|
2824
|
+
return self
|
2825
|
+
end
|
2826
|
+
|
2827
|
+
def map
|
2828
|
+
arr_tmp = Array.new
|
2829
|
+
@keys.each do |k|
|
2830
|
+
arg_arr = Array.new
|
2831
|
+
arg_arr << k
|
2832
|
+
arg_arr << self[k]
|
2833
|
+
arr_tmp << yield(arg_arr)
|
2834
|
+
end
|
2835
|
+
return arr_tmp
|
2836
|
+
end
|
2837
|
+
|
2838
|
+
def sort_hash(&block)
|
2839
|
+
if block_given?
|
2840
|
+
arr_tmp = self.sort(&block)
|
2841
|
+
elsif arr_tmp = self.sort
|
2842
|
+
end
|
2843
|
+
hash_tmp = OrderHash.new
|
2844
|
+
arr_tmp.each do |item|
|
2845
|
+
hash_tmp[item[0]] = item[1]
|
2846
|
+
end
|
2847
|
+
return hash_tmp
|
2831
2848
|
end
|
2832
|
-
return hash_tmp
|
2833
2849
|
end
|
2834
2850
|
end
|
2835
2851
|
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.7
|
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-05-
|
12
|
+
date: 2009-05-13 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|