meteor 0.9.29 → 0.9.31

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.
@@ -9,44 +9,44 @@ module Meteor
9
9
  #
10
10
  class ParserImpl < Meteor::Core::Kernel
11
11
  # KAIGYO_CODE = "\r?\n|\r"
12
- KAIGYO_CODE = ["\r\n", "\n", "\r"]
13
- BR = "<br/>"
14
- BR_RE = "<br\\/>"
12
+ KAIGYO_CODE = ["\r\n", "\n", "\r"].freeze
13
+ BR = '<br/>'
14
+ BR_RE = '<br\\/>'
15
15
 
16
16
  # @@match_tag_2 = "textarea|option|pre"
17
- #[Array] elements where line breaks do not need to be converted to <br> (改行を<br/>に変換する必要のない要素)
18
- @@match_tag_2 = ["textarea", "option", "pre"]
17
+ # [Array] elements where line breaks do not need to be converted to <br> (改行を<br/>に変換する必要のない要素)
18
+ @@match_tag_2 = %w[textarea option pre]
19
19
 
20
- #[Array] boolean attributes (論理値で指定する属性)
21
- @@attr_bool = ["disabled", "readonly", "checked", "selected", "multiple"]
20
+ # [Array] boolean attributes (論理値で指定する属性)
21
+ @@attr_bool = %w[disabled readonly checked selected multiple]
22
22
 
23
23
  # DISABLE_ELEMENT = "input|textarea|select|optgroup"
24
- #[Array] element with disablled attribute (disabled属性のある要素)
25
- DISABLE_ELEMENT = ["input", "textarea", "select", "optgroup"]
24
+ # [Array] element with disablled attribute (disabled属性のある要素)
25
+ DISABLE_ELEMENT = %w[input textarea select optgroup].freeze
26
26
  # READONLY_TYPE = "text|password"
27
- #[Array] the type of an input element with a readonly attribute (readonly属性のあるinput要素のタイプ)
28
- READONLY_TYPE = ["text", "password"]
29
-
30
- SELECTED_M = "\\sselected=\"[^\"]*\"\\s|\\sselected=\"[^\"]*\"$"
31
- SELECTED_M1 = "\\sselected=\"([^\"]*)\"\\s|\\sselected=\"([^\"]*)\"$"
32
- SELECTED_R = "selected=\"[^\"]*\""
33
- SELECTED_U = "selected=\"selected\""
34
- CHECKED_M = "\\schecked=\"[^\"]*\"\\s|\\schecked=\"[^\"]*\"$"
35
- CHECKED_M1 = "\\schecked=\"([^\"]*)\"\\s|\\schecked=\"([^\"]*)\"$"
36
- CHECKED_R = "checked=\"[^\"]*\""
37
- CHECKED_U = "checked=\"checked\""
38
- DISABLED_M = "\\sdisabled=\"[^\"]*\"\\s|\\sdisabled=\"[^\"]*\"$"
39
- DISABLED_M1 = "\\sdisabled=\"([^\"]*)\"\\s|\\sdisabled=\"([^\"]*)\"$"
40
- DISABLED_R = "disabled=\"[^\"]*\""
41
- DISABLED_U = "disabled=\"disabled\""
42
- READONLY_M = "\\sreadonly=\"[^\"]*\"\\s|\\sreadonly=\"[^\"]*\"$"
43
- READONLY_M1 = "\\sreadonly=\"([^\"]*)\"\\s|\\sreadonly=\"([^\"]*)\"$"
44
- READONLY_R = "readonly=\"[^\"]*\""
45
- READONLY_U = "readonly=\"readonly\""
46
- MULTIPLE_M = "\\smultiple=\"[^\"]*\"\\s|\\smultiple=\"[^\"]*\"$"
47
- MULTIPLE_M1 = "\\smultiple=\"([^\"]*)\"\\s|\\smultiple=\"([^\"]*)\"$"
48
- MULTIPLE_R = "multiple=\"[^\"]*\""
49
- MULTIPLE_U = "multiple=\"multiple\""
27
+ # [Array] the type of an input element with a readonly attribute (readonly属性のあるinput要素のタイプ)
28
+ READONLY_TYPE = %w[text password].freeze
29
+
30
+ SELECTED_M = '\\sselected="[^"]*"\\s|\\sselected="[^"]*"$'
31
+ SELECTED_M1 = '\\sselected="([^"]*)"\\s|\\sselected="([^"]*)"$'
32
+ SELECTED_R = 'selected="[^"]*"'
33
+ SELECTED_U = 'selected="selected"'
34
+ CHECKED_M = '\\schecked="[^"]*"\\s|\\schecked="[^"]*"$'
35
+ CHECKED_M1 = '\\schecked="([^"]*)"\\s|\\schecked="([^"]*)"$'
36
+ CHECKED_R = 'checked="[^"]*"'
37
+ CHECKED_U = 'checked="checked"'
38
+ DISABLED_M = '\\sdisabled="[^"]*"\\s|\\sdisabled="[^"]*"$'
39
+ DISABLED_M1 = '\\sdisabled="([^"]*)"\\s|\\sdisabled="([^"]*)"$'
40
+ DISABLED_R = 'disabled="[^"]*"'
41
+ DISABLED_U = 'disabled="disabled"'
42
+ READONLY_M = '\\sreadonly="[^"]*"\\s|\\sreadonly="[^"]*"$'
43
+ READONLY_M1 = '\\sreadonly="([^"]*)"\\s|\\sreadonly="([^"]*)"$'
44
+ READONLY_R = 'readonly="[^"]*"'
45
+ READONLY_U = 'readonly="readonly"'
46
+ MULTIPLE_M = '\\smultiple="[^"]*"\\s|\\smultiple="[^"]*"$'
47
+ MULTIPLE_M1 = '\\smultiple="([^"]*)"\\s|\\smultiple="([^"]*)"$'
48
+ MULTIPLE_R = 'multiple="[^"]*"'
49
+ MULTIPLE_U = 'multiple="multiple"'
50
50
 
51
51
  @@pattern_selected_m = Regexp.new(SELECTED_M)
52
52
  @@pattern_selected_m1 = Regexp.new(SELECTED_M1)
@@ -115,6 +115,8 @@ module Meteor
115
115
  analyze_ml
116
116
  end
117
117
 
118
+ protected :parse
119
+
118
120
  #
119
121
  # analyze document (ドキュメントをパースする)
120
122
  #
@@ -140,21 +142,19 @@ module Meteor
140
142
  def analyze_content_type
141
143
  @error_check = false
142
144
 
143
- element_3("meta", "http-equiv", "Content-Type")
145
+ element_3('meta', 'http-equiv', 'Content-Type')
144
146
 
145
- if !@elm_
146
- element_3("meta", "http-equiv", "Content-Type")
147
- end
147
+ element_3('meta', 'http-equiv', 'Content-Type') unless @elm_
148
148
 
149
149
  @error_check = true
150
150
 
151
151
  if @elm_
152
- content = @elm_.attr("content")
153
- content_arr = content&.split(";")
154
- @root.content_type = content_arr&.at(0) || ""
155
- @root.charset = content_arr&.at(1)&.split("=")&.at(1) || ""
152
+ content = @elm_.attr('content')
153
+ content_arr = content&.split(';')
154
+ @root.content_type = content_arr&.at(0) || ''
155
+ @root.charset = content_arr&.at(1)&.split('=')&.at(1) || ''
156
156
  else
157
- @root.content_type = ""
157
+ @root.content_type = ''
158
158
  end
159
159
  end
160
160
 
@@ -164,26 +164,25 @@ module Meteor
164
164
  # analyze document , set newline (ドキュメントをパースし、改行コードをセットする)
165
165
  #
166
166
  def analyze_newline
167
- for a in KAIGYO_CODE
168
- if @root.document.include?(a)
169
- @root.newline = a
170
- end
167
+ KAIGYO_CODE.each do |a|
168
+ @root.newline = a if @root.document.include?(a)
171
169
  end
172
170
  end
173
171
 
174
172
  private :analyze_newline
175
173
 
176
174
  def edit_attrs_(elm, attr_name, attr_value)
177
- if is_match("selected", attr_name) && is_match("option", elm.name)
175
+ if is_match('selected', attr_name) && is_match('option', elm.name)
178
176
  edit_attrs_5(elm, attr_value, @@pattern_selected_m, @@pattern_selected_r, SELECTED_U)
179
- elsif is_match("multiple", attr_name) && is_match("select", elm.name)
177
+ elsif is_match('multiple', attr_name) && is_match('select', elm.name)
180
178
  edit_attrs_5(elm, attr_value, @@pattern_multiple_m, @@pattern_multiple_r, MULTIPLE_U)
181
- elsif is_match("disabled", attr_name) && is_match(DISABLE_ELEMENT, elm.name)
179
+ elsif is_match('disabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
182
180
  edit_attrs_5(elm, attr_value, @@pattern_disabled_m, @@pattern_disabled_r, DISABLED_U)
183
- elsif is_match("checked", attr_name) && is_match("input", elm.name) && is_match("radio", get_type(elm))
181
+ elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
184
182
  edit_attrs_5(elm, attr_value, @@pattern_checked_m, @@pattern_checked_r, CHECKED_U)
185
- elsif is_match("readonly", attr_name) &&
186
- (is_match("textarea", elm.name) || (is_match("input", elm.name) && is_match(READONLY_TYPE, get_type(elm))))
183
+ elsif is_match('readonly', attr_name) &&
184
+ (is_match('textarea',
185
+ elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
187
186
  edit_attrs_5(elm, attr_value, @@pattern_readonly_m, @@pattern_readonly_r, READONLY_U)
188
187
  else
189
188
  super(elm, attr_name, attr_value)
@@ -195,41 +194,42 @@ module Meteor
195
194
  def edit_attrs_5(elm, attr_value, match_p, replace_regex, replace_update)
196
195
  # attr_value = escape(attr_value)
197
196
 
198
- if true.equal?(attr_value) || is_match("true", attr_value)
197
+ if true.equal?(attr_value) || is_match('true', attr_value)
199
198
  @res = match_p.match(elm.attributes)
200
199
 
201
200
  if !@res
202
201
  # add an attribute to attributes (属性文字列の最後に新規の属性を追加する)
203
- if elm.attributes != ""
204
- elm.attributes = String.new("") << " " << elm.attributes.strip
202
+ if elm.attributes != ''
203
+ elm.attributes = String.new('') << ' ' << elm.attributes.strip
205
204
  # else
206
205
  end
207
206
 
208
- elm.attributes << " " << replace_update
207
+ elm.attributes << ' ' << replace_update
209
208
  else
210
209
  # replace attribute (属性の置換)
211
210
  elm.attributes.gsub!(replace_regex, replace_update)
212
211
  end
213
- elsif false.equal?(attr_value) || is_match("false", attr_value)
212
+ elsif false.equal?(attr_value) || is_match('false', attr_value)
214
213
  # delete if attribute_name attrubute exeists (attr_name属性が存在するなら削除)
215
214
  # replace attribute (属性の置換)
216
- elm.attributes.gsub!(replace_regex, "")
215
+ elm.attributes.gsub!(replace_regex, '')
217
216
  end
218
217
  end
219
218
 
220
219
  private :edit_attrs_5
221
220
 
222
221
  def get_attr_value_(elm, attr_name)
223
- if is_match("selected", attr_name) && is_match("option", elm.name)
222
+ if is_match('selected', attr_name) && is_match('option', elm.name)
224
223
  get_attr_value_r(elm, attr_name, @@pattern_selected_m1)
225
- elsif is_match("multiple", attr_name) && is_match("select", elm.name)
224
+ elsif is_match('multiple', attr_name) && is_match('select', elm.name)
226
225
  get_attr_value_r(elm, attr_name, @@pattern_multiple_m1)
227
- elsif is_match("diabled", attr_name) && is_match(DISABLE_ELEMENT, elm.name)
226
+ elsif is_match('diabled', attr_name) && is_match(DISABLE_ELEMENT, elm.name)
228
227
  get_attr_value_r(elm, attr_name, @@pattern_disabled_m1)
229
- elsif is_match("checked", attr_name) && is_match("input", elm.name) && is_match("radio", get_type(elm))
228
+ elsif is_match('checked', attr_name) && is_match('input', elm.name) && is_match('radio', get_type(elm))
230
229
  get_attr_value_r(elm, attr_name, @@pattern_checked_m1)
231
- elsif is_match("readonly", attr_name) &&
232
- (is_match("textarea", elm.name) || (is_match("input", elm.name) && is_match(READONLY_TYPE, get_type(elm))))
230
+ elsif is_match('readonly', attr_name) &&
231
+ (is_match('textarea',
232
+ elm.name) || (is_match('input', elm.name) && is_match(READONLY_TYPE, get_type(elm))))
233
233
  get_attr_value_r(elm, attr_name, @@pattern_readonly_m1)
234
234
  else
235
235
  super(elm, attr_name)
@@ -239,11 +239,9 @@ module Meteor
239
239
  private :get_attr_value_
240
240
 
241
241
  def get_type(elm)
242
- if !elm.type_value
243
- elm.type_value = get_attr_value(elm, "type")
244
- if !elm.type_value
245
- elm.type_value = get_attr_value(elm, "TYPE")
246
- end
242
+ unless elm.type_value
243
+ elm.type_value = get_attr_value(elm, 'type')
244
+ elm.type_value = get_attr_value(elm, 'TYPE') unless elm.type_value
247
245
  end
248
246
 
249
247
  elm.type_value
@@ -257,31 +255,31 @@ module Meteor
257
255
  if @res
258
256
  if @res[1]
259
257
  if attr_name == @res[1]
260
- "true"
258
+ 'true'
261
259
  else
262
260
  @res[1]
263
261
  end
264
262
  elsif @res[2]
265
263
  if attr_name == @res[2]
266
- "true"
264
+ 'true'
267
265
  else
268
266
  @res[2]
269
267
  end
270
268
  elsif @res[3]
271
269
  if attr_name == @res[3]
272
- "true"
270
+ 'true'
273
271
  else
274
272
  @res[3]
275
273
  end
276
274
  elsif @res[4]
277
275
  if attr_name == @res[4]
278
- "true"
276
+ 'true'
279
277
  else
280
278
  @res[4]
281
279
  end
282
280
  end
283
281
  else
284
- "false"
282
+ 'false'
285
283
  end
286
284
  end
287
285
 
@@ -297,7 +295,7 @@ module Meteor
297
295
 
298
296
  elm.attributes.scan(@@pattern_get_attrs_map) do |a, b|
299
297
  if is_match(@@attr_bool, a) && a == b
300
- attrs.store(a, "true")
298
+ attrs.store(a, 'true')
301
299
  else
302
300
  attrs.store(a, unescape(b))
303
301
  end
@@ -9,20 +9,20 @@ module Meteor
9
9
  #
10
10
  class ParserImpl < Meteor::Core::Kernel
11
11
  # KAIGYO_CODE = "\r?\n|\r"
12
- KAIGYO_CODE = ["\r\n", "\n", "\r"]
12
+ KAIGYO_CODE = ["\r\n", "\n", "\r"].freeze
13
13
 
14
14
  TABLE_FOR_ESCAPE_ = {
15
- "&" => "&amp;",
16
- "\"" => "&quot;",
17
- "'" => "&apos;",
18
- "<" => "&lt;",
19
- ">" => "&gt;"
20
- }
15
+ '&' => '&amp;',
16
+ '"' => '&quot;',
17
+ "'" => '&apos;',
18
+ '<' => '&lt;',
19
+ '>' => '&gt;'
20
+ }.freeze
21
21
 
22
22
  PATTERN_ESCAPE = "[&\\\"'<>]"
23
23
  @@pattern_escape = Regexp.new(PATTERN_ESCAPE)
24
24
 
25
- PATTERN_UNESCAPE = "&(amp|quot|apos|gt|lt);"
25
+ PATTERN_UNESCAPE = '&(amp|quot|apos|gt|lt);'
26
26
  @@pattern_unescape = Regexp.new(PATTERN_UNESCAPE)
27
27
 
28
28
  #
@@ -72,6 +72,8 @@ module Meteor
72
72
  analyze_ml
73
73
  end
74
74
 
75
+ protected :parse
76
+
75
77
  #
76
78
  # analyze document (ドキュメントをパースする)
77
79
  #
@@ -96,7 +98,7 @@ module Meteor
96
98
  # analuze document , set newline (ドキュメントをパースし、改行コードをセットする)
97
99
  #
98
100
  def analyze_newline
99
- for a in KAIGYO_CODE
101
+ KAIGYO_CODE.each do |a|
100
102
  if @root.document.include?(a)
101
103
  @root.newline = a
102
104
  # puts "kaigyo:" << @root.newline
@@ -110,16 +112,14 @@ module Meteor
110
112
  # analyze document , set content type (ドキュメントをパースし、コンテントタイプをセットする)
111
113
  #
112
114
  def analyze_content_type
113
- @root.content_type = "text/xml"
115
+ @root.content_type = 'text/xml'
114
116
  end
115
117
 
116
118
  private :analyze_content_type
117
119
 
118
120
  def escape(content)
119
121
  # replace special character (特殊文字の置換)
120
- content = content.gsub(@@pattern_escape, TABLE_FOR_ESCAPE_)
121
-
122
- content
122
+ content.gsub(@@pattern_escape, TABLE_FOR_ESCAPE_)
123
123
  end
124
124
 
125
125
  private :escape
@@ -138,17 +138,17 @@ module Meteor
138
138
  # 「'」<-「&apos;」
139
139
  # 「&」<-「&amp;」
140
140
  content.gsub(@@pattern_unescape) do
141
- case $1
142
- when "amp"
143
- "&"
144
- when "quot"
145
- "\""
146
- when "apos"
141
+ case ::Regexp.last_match(1)
142
+ when 'amp'
143
+ '&'
144
+ when 'quot'
145
+ '"'
146
+ when 'apos'
147
147
  "'"
148
- when "gt"
149
- ">"
150
- when "lt"
151
- "<"
148
+ when 'gt'
149
+ '>'
150
+ when 'lt'
151
+ '<'
152
152
  end
153
153
  end
154
154
 
@@ -13,19 +13,17 @@ module Meteor
13
13
  # @return [String] default character encoding (デフォルトエンコーディング)
14
14
  #
15
15
  class Parsers
16
- attr_accessor :type
17
- attr_accessor :root
18
- attr_accessor :enc
16
+ attr_accessor :type, :root, :enc
19
17
 
20
- alias_method :base_type, :type
21
- alias_method :base_type=, :type=
22
- alias_method :base_dir, :root
23
- alias_method :base_dir=, :root=
24
- alias_method :base_enc, :enc
25
- alias_method :base_enc=, :enc=
18
+ alias base_type type
19
+ alias base_type= type=
20
+ alias base_dir root
21
+ alias base_dir= root=
22
+ alias base_enc enc
23
+ alias base_enc= enc=
26
24
 
27
- alias_method :base_encoding, :enc
28
- alias_method :base_encoding=, :enc=
25
+ alias base_encoding enc
26
+ alias base_encoding= enc=
29
27
 
30
28
  #
31
29
  # initializer (イニシャライザ)
@@ -79,8 +77,8 @@ module Meteor
79
77
  # @param [String] root root directory (基準ディレクトリ)
80
78
  # @param [String] enc default character encoding (デフォルト文字エンコーディング)
81
79
  #
82
- def initialize_2(root = ".", enc = "UTF-8")
83
- @cache = Hash.new
80
+ def initialize_2(root = '.', enc = 'UTF-8')
81
+ @cache = {}
84
82
  @root = root
85
83
  @enc = enc
86
84
  end
@@ -93,8 +91,8 @@ module Meteor
93
91
  # @param [String] root root directory (基準ディレクトリ)
94
92
  # @param [String] enc default character encoding (デフォルト文字エンコーディング)
95
93
  #
96
- def initialize_3(type, root=".", enc = "UTF-8")
97
- @cache = Hash.new
94
+ def initialize_3(type, root = '.', enc = 'UTF-8')
95
+ @cache = {}
98
96
  @type = type
99
97
  @root = root
100
98
  @enc = enc
@@ -113,46 +111,44 @@ module Meteor
113
111
  # @option @deprecated opts [Integer | Symbol] :base_type default type of parser (デフォルトのパーサ・タイプ)
114
112
  #
115
113
  def options=(opts)
116
- if opts.kind_of?(Hash)
117
- if opts.include?(:root)
118
- @root = opts[:root]
119
- elsif opts.include?(:base_dir)
120
- @root = opts[:base_dir]
121
- end
114
+ raise ArgumentError unless opts.is_a?(Hash)
122
115
 
123
- if opts.include?(:enc)
124
- @enc = opts[:enc]
125
- elsif opts.include?(:base_enc)
126
- @enc = opts[:base_enc]
127
- end
116
+ if opts.include?(:root)
117
+ @root = opts[:root]
118
+ elsif opts.include?(:base_dir)
119
+ @root = opts[:base_dir]
120
+ end
128
121
 
129
- if opts.include?(:type)
130
- @type = opts[:type]
131
- elsif opts.include?(:base_type)
132
- @type = opts[:base_type]
133
- end
134
- else
135
- raise ArgumentError
122
+ if opts.include?(:enc)
123
+ @enc = opts[:enc]
124
+ elsif opts.include?(:base_enc)
125
+ @enc = opts[:base_enc]
126
+ end
127
+
128
+ if opts.include?(:type)
129
+ @type = opts[:type]
130
+ elsif opts.include?(:base_type)
131
+ @type = opts[:base_type]
136
132
  end
137
133
  end
138
134
 
139
135
  #
140
- #@overload add(relative_path,enc)
136
+ # @overload add(relative_path,enc)
141
137
  # add parser (パーサを追加する)
142
138
  # @param [String] relative_path relative file path (相対ファイルパス)
143
139
  # @param [String] enc character encoding (文字エンコーディング)
144
140
  # @return [Meteor::Parser] parser (パーサ)
145
- #@overload add(relative_path)
141
+ # @overload add(relative_path)
146
142
  # add parser (パーサを追加する)
147
143
  # @param [String] relative_path relative file path (相対ファイルパス)
148
144
  # @return [Meteor::Parser] parser (パーサ)
149
- #@overload add(type,relative_path,enc)
145
+ # @overload add(type,relative_path,enc)
150
146
  # add parser (パーサを追加する)
151
147
  # @param [Integer,Symbol] type type of parser (パーサ・タイプ)
152
148
  # @param [String] relative_path relative file path (相対ファイルパス)
153
149
  # @param [String] enc character encoding (文字エンコーディング)
154
150
  # @return [Meteor::Parser] parser (パーサ)
155
- #@overload add(type,relative_path)
151
+ # @overload add(type,relative_path)
156
152
  # add parser (パーサを追加する)
157
153
  # @param [Integer,Symbol] type type of parser (パーサ・タイプ)
158
154
  # @param [String] relative_path relative file path (相対ファイルパス)
@@ -163,9 +159,9 @@ module Meteor
163
159
  when 1
164
160
  add_file_1(args[0])
165
161
  when 2
166
- if args[0].kind_of?(Integer) || args[0].kind_of?(Symbol)
162
+ if args[0].is_a?(Integer) || args[0].is_a?(Symbol)
167
163
  add_file_2_n(args[0], args[1])
168
- elsif args[0].kind_of?(String)
164
+ elsif args[0].is_a?(String)
169
165
  add_file_2_s(args[0], args[1])
170
166
  else
171
167
  raise ArgumentError
@@ -177,7 +173,7 @@ module Meteor
177
173
  end
178
174
  end
179
175
 
180
- alias_method :link, :add
176
+ alias link add
181
177
 
182
178
  #
183
179
  # change relative path to relative url (相対パスを相対URLにする)
@@ -188,16 +184,14 @@ module Meteor
188
184
  paths = File.split(path)
189
185
 
190
186
  if paths.length == 1
191
- return File.basename(paths[0], ".*")
187
+ File.basename(paths[0], '.*')
188
+ elsif paths[0] == '.'
189
+ paths.delete_at(0)
190
+ paths[paths.length - 1] = File.basename(paths[paths.length - 1], '.*')
191
+ String.new('') << '/' << paths.join('/')
192
192
  else
193
- if paths[0] == "."
194
- paths.delete_at(0)
195
- paths[paths.length - 1] = File.basename(paths[paths.length - 1], ".*")
196
- return String.new("") << "/" << paths.join("/")
197
- else
198
- paths[paths.length - 1] = File.basename(paths[paths.length - 1], ".*")
199
- return String.new("") << "/" << paths.join("/")
200
- end
193
+ paths[paths.length - 1] = File.basename(paths[paths.length - 1], '.*')
194
+ String.new('') << '/' << paths.join('/')
201
195
  end
202
196
  end
203
197
 
@@ -210,12 +204,11 @@ module Meteor
210
204
  # @param [String] enc character encoding (文字エンコーディング)
211
205
  # @return [Meteor::Parser] parser(パーサ)
212
206
  #
213
- def add_file_3(type, relative_path, enc = "UTF-8")
214
- ps = new_parser(type)
215
- ps.read(File.expand_path(relative_path, @root), enc)
216
-
207
+ def add_file_3(type, relative_path, enc = 'UTF-8')
217
208
  relative_url = path_to_url(relative_path)
218
- @cache[relative_url] = ps
209
+
210
+ add_template_3(type, relative_url,
211
+ Meteor::Core::Util::FileReader.read(File.expand_path(relative_path, @root), enc))
219
212
  end
220
213
 
221
214
  private :add_file_3
@@ -289,7 +282,6 @@ module Meteor
289
282
  def add_template_3(type, relative_url, doc)
290
283
  ps = new_parser(type)
291
284
  ps.document = doc
292
- ps.parse
293
285
 
294
286
  @cache[relative_url] = ps
295
287
  end
@@ -308,23 +300,23 @@ module Meteor
308
300
 
309
301
  private :add_template_2
310
302
 
311
- alias_method :link_str, :add_template
312
- alias_method :add_str, :add_template
313
- alias_method :parser_str, :add_template
303
+ alias link_str add_template
304
+ alias add_str add_template
305
+ alias parser_str add_template
314
306
 
315
307
  #
316
- #@overload parser(key)
308
+ # @overload parser(key)
317
309
  # get parser (パーサを取得する)
318
310
  # @param [String,Symbol] key identifier (キー)
319
311
  # @return [Meteor::Parser] parser (パーサ)
320
- #@overload parser(type,relative_path,enc)
312
+ # @overload parser(type,relative_path,enc)
321
313
  # add parser (パーサを追加する)
322
314
  # @param [Integer] type type of parser (パーサ・タイプ)
323
315
  # @param [String] relative_path relative file path (相対ファイルパス)
324
316
  # @param [String] enc character encoding (エンコーディング)
325
317
  # @return [Meteor::Parser] parser (パーサ)
326
318
  # @deprecated
327
- #@overload parser(type,relative_path)
319
+ # @overload parser(type,relative_path)
328
320
  # add parser (パーサを追加する)
329
321
  # @param [Integer] type type of parser (パーサ・タイプ)
330
322
  # @param [String] relative_path relative file path (相対ファイルパス)
@@ -406,7 +398,7 @@ module Meteor
406
398
  # @return [Meteor::Parser] parser (パーサ)
407
399
  #
408
400
  def [](key)
409
- self.parser(key)
401
+ parser(key)
410
402
  end
411
403
  end
412
404
 
@@ -15,16 +15,13 @@ module Meteor
15
15
  # @return [String] character encoding (文字エンコーディング)
16
16
  #
17
17
  class RootElement < Element
18
- attr_accessor :content_type
19
- attr_accessor :newline
20
- attr_accessor :charset
21
- attr_accessor :enc
18
+ attr_accessor :content_type, :newline, :charset, :enc
22
19
  # attr_accessor :document #[String] document (ドキュメント)
23
20
 
24
- alias_method :character_encoding, :enc
25
- alias_method :character_encoding=, :enc=
21
+ alias character_encoding enc
22
+ alias character_encoding= enc=
26
23
 
27
- alias_method :kaigyo_code, :newline
28
- alias_method :kaigyo_code=, :newline=
24
+ alias kaigyo_code newline
25
+ alias kaigyo_code= newline=
29
26
  end
30
27
  end