asip-meteor 0.9.2.0 → 0.9.2.1

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 (2) hide show
  1. data/lib/meteor.rb +156 -95
  2. metadata +2 -2
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.2.0
21
+ # @version 0.9.2.1
22
22
  #
23
23
 
24
24
  module Meteor
25
25
 
26
- VERSION = "0.9.2.0"
26
+ VERSION = "0.9.2.1"
27
27
 
28
28
  RUBY_VERSION_1_9_0 = '1.9.0'
29
29
 
@@ -61,6 +61,19 @@ module Meteor
61
61
  else
62
62
  raise ArgumentError
63
63
  end
64
+ when TWO
65
+ @name = args[0].name
66
+ @attributes = String.new(args[0].attributes)
67
+ @mixed_content = String.new(args[0].mixed_content)
68
+ @pattern = String.new(args[0].pattern)
69
+ @document = String.new(args[0].document)
70
+ @empty = args[0].empty
71
+ @cx = args[0].cx
72
+ @mono = args[0].mono
73
+ @parser = args[1]
74
+ @arguments = AttributeMap.new(args[0].arguments)
75
+ #@usable = false
76
+ @origin = args[0]
64
77
  else
65
78
  raise ArgumentError
66
79
  end
@@ -93,7 +106,6 @@ module Meteor
93
106
  def initialize_e(elm)
94
107
  @name = elm.name
95
108
  @attributes = String.new(elm.attributes)
96
- @mixed_content = String.new(elm.mixed_content)
97
109
  @pattern = String.new(elm.pattern)
98
110
  @document = String.new(elm.document)
99
111
  @empty = elm.empty
@@ -101,27 +113,55 @@ module Meteor
101
113
  @mono = elm.mono
102
114
  @parser = elm.parser
103
115
  @arguments = AttributeMap.new(elm.arguments)
104
- @usable = true
105
- @origin = elm
106
- elm.parser.e_cache.store(elm.object_id,self)
116
+ @origin = elm
117
+ @usable = true
118
+ end
119
+ private :initialize_e
120
+
121
+ #
122
+ # コピーを作成する
123
+ # @param [Array] args 引数配列
124
+ #
125
+ def self.new!(*args)
126
+ case args.length
127
+ when ONE
128
+ self.new_1!(args[0])
129
+ when TWO
130
+ @obj = args[1].root_element.element
131
+ if @obj then
132
+ @obj.attributes = String.new(args[0].attributes)
133
+ @obj.mixed_content = String.new(args[0].mixed_content)
134
+ @obj.pattern = String.new(args[0].pattern)
135
+ @obj.document = String.new(args[0].document)
136
+ @obj.arguments = AttributeMap.new(args[0].arguments)
137
+ @obj
138
+ else
139
+ @obj = self.new(args[0],args[1])
140
+ args[1].root_element.element = @obj
141
+ @obj
142
+ end
143
+ end
107
144
  end
108
- private :initialize_e
109
145
 
110
- def self.new!(elm)
146
+ #
147
+ # コピーを作成する
148
+ # @param [Element] elm 要素
149
+ #
150
+ def self.new_1!(elm)
111
151
  @obj = elm.parser.e_cache[elm.object_id]
112
- if @obj then
152
+ if @obj then
113
153
  @obj.attributes = String.new(elm.attributes)
114
154
  @obj.mixed_content = String.new(elm.mixed_content)
115
155
  @obj.pattern = String.new(elm.pattern)
116
- @obj.document = String.new(elm.document)
156
+ @obj.document = String.new(elm.document)
117
157
  @obj.arguments = AttributeMap.new(elm.arguments)
118
158
  @obj.usable = true
119
159
  @obj
120
- else
160
+ else
121
161
  @obj = self.new(elm)
162
+ elm.parser.e_cache[elm.object_id] = @obj
122
163
  @obj
123
164
  end
124
-
125
165
  end
126
166
 
127
167
  attr_accessor :name
@@ -183,7 +223,7 @@ module Meteor
183
223
  # @return [String] 内容
184
224
  #
185
225
  def content(*args)
186
- @parser.content(self,args)
226
+ @parser.content(self,*args)
187
227
  end
188
228
 
189
229
  #
@@ -205,7 +245,7 @@ module Meteor
205
245
  if !name.kind_of?(String) || name != CONTENT_STR then
206
246
  attribute(name,value)
207
247
  else
208
- content=(value)
248
+ @parser.content(self,value)
209
249
  end
210
250
  end
211
251
 
@@ -807,9 +847,9 @@ module Meteor
807
847
 
808
848
  ESCAPE_ENTITY_REF = ''
809
849
 
810
- SUB_REGEX1 = '(\\\\*)\\\\([0-9]+)'
811
- SUB_REGEX2 = '\\1\\1\\\\\\\\\\2'
812
- SUB_REGEX3 = '\\1\\1\\1\\1\\\\\\\\\\\\\\\\\\2'
850
+ #SUB_REGEX1 = (\\\\*)\\\\([0-9]+)'
851
+ #SUB_REGEX2 = '\\1\\1\\\\\\\\\\2'
852
+ #SUB_REGEX3 = '\\1\\1\\1\\1\\\\\\\\\\\\\\\\\\2'
813
853
 
814
854
  @@pattern_get_attrs_map = Regexp.new(GET_ATTRS_MAP)
815
855
 
@@ -848,7 +888,7 @@ module Meteor
848
888
  #@@pattern_qmark = Regexp.new(QMARK_1)
849
889
  #@@pattern_asterisk = Regexp.new(ASTERISK_1)
850
890
 
851
- @@pattern_sub_regex1 = Regexp.new(SUB_REGEX1)
891
+ #@@pattern_sub_regex1 = Regexp.new(SUB_REGEX1)
852
892
 
853
893
  @@pattern_clean1 = Regexp.new(CLEAN_1)
854
894
  @@pattern_clean2 = Regexp.new(CLEAN_2)
@@ -1019,6 +1059,7 @@ module Meteor
1019
1059
  when ONE
1020
1060
  if args[0].kind_of?(String) then
1021
1061
  element_1(args[0])
1062
+ @e_cache.store(@elm_.object_id,@elm_)
1022
1063
  elsif args[0].kind_of?(Meteor::Element) then
1023
1064
  shadow(args[0])
1024
1065
  else
@@ -1026,16 +1067,19 @@ module Meteor
1026
1067
  end
1027
1068
  when TWO
1028
1069
  element_2(args[0],args[1])
1070
+ @e_cache.store(@elm_.object_id,@elm_)
1029
1071
  when THREE
1030
1072
  element_3(args[0],args[1],args[2])
1073
+ @e_cache.store(@elm_.object_id,@elm_)
1031
1074
  when FOUR
1032
1075
  element_4(args[0],args[1],args[2],args[3])
1076
+ @e_cache.store(@elm_.object_id,@elm_)
1033
1077
  when FIVE
1034
1078
  element_5(args[0],args[1],args[2],args[3],args[4])
1079
+ @e_cache.store(@elm_.object_id,@elm_)
1035
1080
  else
1036
1081
  raise ArgumentError
1037
1082
  end
1038
- @e_cache.store(@elm_.object_id,@elm_)
1039
1083
  @elm_
1040
1084
  end
1041
1085
 
@@ -1849,12 +1893,12 @@ module Meteor
1849
1893
  if elm.attributes.include?(' ' << attr_name << ATTR_EQ) then
1850
1894
 
1851
1895
  @_attr_value = attr_value
1852
- #replace2regex(@_attr_value)
1853
- if elm.origin then
1854
- replace4regex(@_attr_value)
1855
- else
1856
- replace2regex(@_attr_value)
1857
- end
1896
+ ##replace2regex(@_attr_value)
1897
+ #if elm.origin then
1898
+ # replace4regex(@_attr_value)
1899
+ #else
1900
+ # replace2regex(@_attr_value)
1901
+ #end
1858
1902
  #属性の置換
1859
1903
  @pattern = Meteor::Core::Util::PatternCache.get('' << attr_name << SET_ATTR_1)
1860
1904
 
@@ -1863,11 +1907,11 @@ module Meteor
1863
1907
  else
1864
1908
  #属性文字列の最後に新規の属性を追加する
1865
1909
  @_attr_value = attr_value
1866
- #replace2regex(@_attr_value)
1867
- if elm.origin then
1868
- replace2regex(@_attr_value)
1869
- end
1870
-
1910
+ ##replace2regex(@_attr_value)
1911
+ #if elm.origin then
1912
+ # replace2regex(@_attr_value)
1913
+ #end
1914
+
1871
1915
  if EMPTY != elm.attributes && EMPTY != elm.attributes.strip then
1872
1916
  elm.attributes = '' << SPACE << elm.attributes.strip
1873
1917
  else
@@ -1889,44 +1933,40 @@ module Meteor
1889
1933
  def edit_document_2(elm,closer)
1890
1934
  if !elm.cx then
1891
1935
  @_attributes = elm.attributes
1892
- replace2regex(@_attributes)
1936
+ #replace2regex(@_attributes)
1893
1937
 
1894
1938
  if elm.empty then
1895
1939
  #内容あり要素の場合
1896
1940
  @_content = elm.mixed_content
1897
- #replace2regex(@_content)
1898
- if elm.origin then
1899
- replace4regex(@_content)
1900
- else
1901
- replace2regex(@_content)
1902
- end
1903
-
1904
- #タグ検索用パターン
1905
- @pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
1906
- @root.document.sub!(@pattern,'' << TAG_OPEN << elm.name << @_attributes << TAG_CLOSE << @_content << TAG_OPEN3 << elm.name << TAG_CLOSE)
1907
- #@root.document.sub!(@pattern,"<#{elm.name}#{@_attributes}>#{@_content}</#{elm.name}>")
1941
+ ##replace2regex(@_content)
1942
+ #if elm.origin then
1943
+ # replace4regex(@_content)
1944
+ #else
1945
+ # replace2regex(@_content)
1946
+ #end
1947
+
1948
+ elm.document = '' << TAG_OPEN << elm.name << @_attributes << TAG_CLOSE << @_content << TAG_OPEN3 << elm.name << TAG_CLOSE
1949
+ #elm.document = "<#{elm.name}#{@_attributes}>#{@_content}</#{elm.name}>"
1908
1950
  else
1909
1951
  #空要素の場合
1910
- #タグ置換用パターン
1911
- @pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
1912
- @root.document.sub!(@pattern,'' << TAG_OPEN << elm.name << @_attributes << closer)
1952
+ elm.document = '' << TAG_OPEN << elm.name << @_attributes << closer
1913
1953
  end
1914
1954
  else
1915
1955
  @_content = elm.mixed_content
1916
- if elm.origin then
1917
- replace4regex(@_content)
1918
- else
1919
- replace2regex(@_content)
1920
- end
1921
-
1922
- @pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
1923
-
1924
- #タグ置換
1925
- #@pattern_cc = '' << SET_CX_1 << elm.name << SPACE << elm.attributes << SET_CX_2
1926
- #@pattern_cc << @_content << SET_CX_3 << elm.name << SET_CX_4
1927
- @pattern_cc = "<!-- @#{elm.name} #{elm.attributes}-->#{@_content}<!-- /@#{elm.name} -->"
1928
- @root.document.sub!(@pattern,@pattern_cc)
1956
+ #if elm.origin then
1957
+ # replace4regex(@_content)
1958
+ #else
1959
+ # replace2regex(@_content)
1960
+ #end
1961
+
1962
+ #elm.document = '' << SET_CX_1 << elm.name << SPACE << elm.attributes << SET_CX_2
1963
+ #elm.document << @_content << SET_CX_3 << elm.name << SET_CX_4
1964
+ elm.document = "<!-- @#{elm.name} #{elm.attributes}-->#{@_content}<!-- /@#{elm.name} -->"
1929
1965
  end
1966
+
1967
+ #タグ置換
1968
+ @pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
1969
+ @root.document.sub!(@pattern,elm.document)
1930
1970
  end
1931
1971
  private :edit_document_2
1932
1972
 
@@ -1935,7 +1975,7 @@ module Meteor
1935
1975
  elm.arguments.map.each do |name, attr|
1936
1976
  if attr.changed then
1937
1977
  @_attr_value = escape_regex(attr.value)
1938
- #replace2regex(@_attr_value)
1978
+ ##replace2regex(@_attr_value)
1939
1979
  #@pattern_cc = '' << name << SET_ATTR_1
1940
1980
  @pattern_cc = "#{attr.name}=\"[^\"]*\""
1941
1981
  @pattern = Meteor::Core::Util::PatternCache.get(@pattern_cc)
@@ -2336,21 +2376,28 @@ module Meteor
2336
2376
  #
2337
2377
  def replace(elm,replace_document)
2338
2378
  #文字エスケープ
2339
- if replace_document.size > ZERO && elm.origin && elm.mono then
2340
- replace2regex(replace_document)
2341
- end
2379
+ #if replace_document.size > ZERO && elm.origin && elm.mono then
2380
+ # replace2regex(replace_document)
2381
+ #end
2342
2382
  #タグ置換パターン
2343
2383
  @pattern = Meteor::Core::Util::PatternCache.get(elm.pattern)
2344
2384
  #タグ置換
2345
2385
  @root.document.sub!(@pattern,replace_document)
2346
2386
  end
2347
-
2387
+ private :replace
2388
+
2348
2389
  def reflect()
2349
-
2390
+ #puts @e_cache.size.to_s
2350
2391
  @e_cache.values.each do |item|
2351
2392
  if item.usable then
2352
- edit_document_1(item)
2353
- edit_pattern_(item)
2393
+ #puts "#{item.name}:#{item.document}"
2394
+ if item.name == EMPTY then
2395
+ @pattern = Meteor::Core::Util::PatternCache.get(item.pattern)
2396
+ @root.document.sub!(@pattern,item.document)
2397
+ else
2398
+ edit_document_1(item)
2399
+ edit_pattern_(item)
2400
+ end
2354
2401
  item.usable = false
2355
2402
  end
2356
2403
  end
@@ -2361,12 +2408,13 @@ module Meteor
2361
2408
  # 出力する
2362
2409
  #
2363
2410
  def print
2364
- reflect()
2365
-
2366
- if @root.element then
2411
+ reflect
2412
+
2413
+ #puts @root.document
2414
+ if @root.element then
2367
2415
  if !@root.element.origin.mono then
2368
2416
  @_attributes = @root.element.attributes
2369
- replace2regex(@_attributes)
2417
+ #replace2regex(@_attributes)
2370
2418
  if @root.element.origin.cx then
2371
2419
  #@root.hookDocument << SET_CX_1 << @root.element.name << SPACE
2372
2420
  #@root.hookDocument << @_attributes << SET_CX_2
@@ -2379,8 +2427,7 @@ module Meteor
2379
2427
  #@root.hookDocument << TAG_OPEN3 << @root.element.name << TAG_CLOSE
2380
2428
  @root.hook_document << "<#{@root.element.name}#{@_attributes}>#{@root.document}</#{@root.element.name}>"
2381
2429
  end
2382
- @root.element = Element.new!(@root.element.origin)
2383
- @root.document = String.new(@root.element.origin.mixed_content)
2430
+ @root.element = Element.new!(@root.element.origin,self)
2384
2431
  else
2385
2432
  if @root.element.origin.cx then
2386
2433
  #@root.hookDocument << SET_CX_1 << @root.element.name << SPACE
@@ -2388,14 +2435,20 @@ module Meteor
2388
2435
  #@root.hookDocument << @root.element.mixed_content << SET_CX_3
2389
2436
  #@root.hookDocument << @root.element.name << SET_CX_4
2390
2437
  @root.hook_document << "<!-- @#{@root.element.name} #{@root.element.attributes}-->#{@root.element.mixed_content}<!-- /@#{@root.element.name} -->"
2438
+ #@root.hook_document << @root.document
2391
2439
  else
2392
2440
  #@root.hookDocument << TAG_OPEN << @root.element.name
2393
2441
  #@root.hookDocument << @root.element.attributes << TAG_CLOSE << @root.element.mixed_content
2394
2442
  #@root.hookDocument << TAG_OPEN3 << @root.element.name << TAG_CLOSE
2395
2443
  @root.hook_document << "<#{@root.element.name}#{@root.element.attributes}>#{@root.element.mixed_content}</#{@root.element.name}>"
2444
+ #@root.hook_document << @root.document
2396
2445
  end
2397
- @root.element = Element.new!(@root.element.origin)
2446
+ #@root.hook_document << @root.document
2447
+ @root.element = Element.new!(@root.element.origin,self)
2448
+ #@root.document = String.new(@root.element.document)
2398
2449
  end
2450
+ #@root.element.origin.document = @root.hook_document
2451
+ #@root.element.origin.name = EMPTY
2399
2452
  else
2400
2453
  #フック判定がFALSEの場合
2401
2454
  clean
@@ -2426,13 +2479,15 @@ module Meteor
2426
2479
 
2427
2480
  pif2 = create(self)
2428
2481
 
2429
- @elm_ = Element.new(elm)
2430
- @elm_.parser = pif2
2431
-
2482
+ #@elm_ = Element.new(elm,pif2)
2483
+ @elm_ = Element.new!(elm,pif2)
2484
+
2432
2485
  if !elm.mono then
2433
- pif2.root_element.document = String.new(elm.mixed_content)
2434
- end
2435
- pif2.root_element.element = @elm_
2486
+ pif2.root_element.document = String.new(elm.mixed_content)
2487
+ else
2488
+ pif2.root_element.document = String.new(elm.document)
2489
+ end
2490
+ #pif2.root_element.element = @elm_
2436
2491
 
2437
2492
  @elm_
2438
2493
  end
@@ -2460,8 +2515,12 @@ module Meteor
2460
2515
  #
2461
2516
  def flush
2462
2517
  if @root.element && @root.element.origin then
2463
- @root.element.origin.parser.reflect
2464
- @root.element.origin.parser.replace(@root.element.origin, @root.hook_document)
2518
+ ##@root.element.origin.parser.reflect
2519
+ ##@root.element.origin.parser.replace(@root.element.origin, @root.hook_document)
2520
+ ##puts "[aa]"
2521
+ ##puts @root.hook_document
2522
+ @root.element.origin.document = @root.hook_document
2523
+ @root.element.origin.name = EMPTY
2465
2524
  end
2466
2525
  end
2467
2526
 
@@ -2501,19 +2560,19 @@ module Meteor
2501
2560
  end
2502
2561
  private :escape_regex
2503
2562
 
2504
- def replace2regex(str)
2505
- if str.include?(EN_1) then
2506
- str.gsub!(@@pattern_sub_regex1,SUB_REGEX2)
2507
- end
2508
- end
2509
- private :replace2regex
2510
-
2511
- def replace4regex(str)
2512
- if str.include?(EN_1) then
2513
- str.gsub!(@@pattern_sub_regex1,SUB_REGEX3)
2514
- end
2515
- end
2516
- private :replace4regex
2563
+ #def replace2regex(str)
2564
+ # #if str.include?(EN_1) then
2565
+ # # str.gsub!(@@pattern_sub_regex1,SUB_REGEX2)
2566
+ # #end
2567
+ #end
2568
+ #private :replace2regex
2569
+
2570
+ #def replace4regex(str)
2571
+ # #if str.include?(EN_1) then
2572
+ # # str.gsub!(@@pattern_sub_regex1,SUB_REGEX3)
2573
+ # #end
2574
+ #end
2575
+ #private :replace4regex
2517
2576
 
2518
2577
  #
2519
2578
  # @param [String] content 入力文字列
@@ -4135,7 +4194,8 @@ module Meteor
4135
4194
  #
4136
4195
  def initialize_0
4137
4196
  end
4138
-
4197
+ private :initialize_0
4198
+
4139
4199
  #
4140
4200
  # イニシャライザ
4141
4201
  #
@@ -4145,6 +4205,7 @@ module Meteor
4145
4205
  @root.document = String.new(ps.document)
4146
4206
  @root.hook_document = String.new(ps.root_element.hook_document)
4147
4207
  end
4208
+ private :initialize_1
4148
4209
 
4149
4210
  #
4150
4211
  # ドキュメントをパーサにセットする
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.2.0
4
+ version: 0.9.2.1
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-31 00:00:00 -07:00
12
+ date: 2009-06-04 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15