asip-meteor 0.9.3.0 → 0.9.3.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 +39 -23
  2. metadata +1 -1
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.3.0
21
+ # @version 0.9.3.1
22
22
  #
23
23
 
24
24
  module Meteor
25
25
 
26
- VERSION = "0.9.3.0"
26
+ VERSION = "0.9.3.1"
27
27
 
28
28
  RUBY_VERSION_1_9_0 = '1.9.0'
29
29
 
@@ -286,7 +286,7 @@ module Meteor
286
286
 
287
287
  #
288
288
  # 属性を削除する
289
- #
289
+ #
290
290
  # @param args 引数配列
291
291
  #
292
292
  def remove_attribute(*args)
@@ -298,6 +298,9 @@ module Meteor
298
298
  @document = doc
299
299
  end
300
300
 
301
+ #
302
+ # ドキュメントを取得する
303
+ #
301
304
  def document
302
305
  if @document_sync then
303
306
  @document_sync = false
@@ -575,6 +578,11 @@ module Meteor
575
578
  #
576
579
  class ParserFactory
577
580
 
581
+ ABST_EXT_NAME = '.*'
582
+ CURRENT_DIR = '.'
583
+ SLASH = '/'
584
+ ENC_UTF8 = 'UTF-8'
585
+
578
586
  attr_accessor :base_dir
579
587
  attr_accessor :base_encoding
580
588
 
@@ -600,8 +608,8 @@ module Meteor
600
608
  #
601
609
  def initialize_0
602
610
  @cache = Hash.new
603
- @base_dir = '.'
604
- @base_encoding = 'UTF-8'
611
+ @base_dir = CURRENT_DIR
612
+ @base_encoding = ENC_UTF8
605
613
  end
606
614
  private :initialize_0
607
615
 
@@ -612,14 +620,14 @@ module Meteor
612
620
  def initialize_1(bs_dir)
613
621
  @cache = Hash.new
614
622
  @base_dir = bs_dir
615
- @base_encoding = 'UTF-8'
623
+ @base_encoding = ENC_UTF8
616
624
  end
617
625
  private :initialize_1
618
626
 
619
627
  #
620
628
  # イニシャライザ
621
629
  # @param [String] bs_dir 基準ディレクトリ
622
- # @param [String] bs_encoding エンコーディング
630
+ # @param [String] bs_encoding デフォルトエンコーディング
623
631
  #
624
632
  def initialize_2(bs_dir,bs_encoding)
625
633
  @cache = Hash.new
@@ -630,7 +638,8 @@ module Meteor
630
638
 
631
639
  #
632
640
  # パーサをセットする
633
- #
641
+ # @param [Array] args 引数配列
642
+ # @return [Meteor::Parser] パーサ
634
643
  #
635
644
  def parser(*args)
636
645
  case args.length
@@ -645,10 +654,11 @@ module Meteor
645
654
 
646
655
  #
647
656
  # パーサを取得する
648
- # @param [String] name 名前
657
+ # @param [String] key キー
658
+ # @return [Meteor::Parser] パーサ
649
659
  #
650
- def parser_1(name)
651
- @pif = @cache[name]
660
+ def parser_1(key)
661
+ @pif = @cache[key]
652
662
 
653
663
  if @pif.instance_of?(Meteor::Core::Html::ParserImpl) then
654
664
  Meteor::Core::Html::ParserImpl.new(@pif)
@@ -666,16 +676,16 @@ module Meteor
666
676
  # @param [Fixnum] type パーサのタイプ
667
677
  # @param [String] relative_path 相対ファイルパス
668
678
  # @param [String] encoding エンコーディング
669
- # @return [Meteor::ParserFactory] パーサファクトリ
679
+ # @return [Meteor::Parser] パーサ
670
680
  #
671
681
  def parser_3(type,relative_path,encoding)
672
682
 
673
683
  paths = File.split(relative_path)
674
684
 
675
- if '.'.eql?(paths[0]) then
676
- relative_url = File.basename(paths[1],'.*')
685
+ if CURRENT_DIR.eql?(paths[0]) then
686
+ relative_url = File.basename(paths[1],ABST_EXT_NAME)
677
687
  else
678
- relative_url = [paths[0],File.basename(paths[1],'.*')].join("/")
688
+ relative_url = [paths[0],File.basename(paths[1],ABST_EXT_NAME)].join(SLASH)
679
689
  end
680
690
 
681
691
  case type
@@ -703,14 +713,14 @@ module Meteor
703
713
  #
704
714
  # @param [Fixnum] type パーサのタイプ
705
715
  # @param [String] relative_path 相対ファイルパス
706
- # @return [Meteor::ParserFactory] パーサファクトリ
716
+ # @return [Meteor::Parser] パーサ
707
717
  #
708
718
  def parser_2(type,relative_path)
709
719
 
710
720
  paths = File.split(relative_path)
711
721
 
712
722
  if '.'.eql?(paths[0]) then
713
- relative_url = File.basename(paths[1],'.*')
723
+ relative_url = File.basename(paths[1],ABST_EXT_NAME)
714
724
  else
715
725
  relative_url = [paths[0],File.basename(paths[1],'.*')].join("/")
716
726
  end
@@ -1018,11 +1028,17 @@ module Meteor
1018
1028
  #SUB_REGEX3 = '\\1\\1\\1\\1\\\\\\\\\\\\\\\\\\2'
1019
1029
 
1020
1030
  if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
1031
+ MODE_BF = 'r:'
1032
+ MODE_AF = ':utf-8'
1033
+
1021
1034
  @@pattern_get_attrs_map = Regexp.new(GET_ATTRS_MAP)
1022
1035
 
1023
1036
  @@pattern_clean1 = Regexp.new(CLEAN_1)
1024
1037
  @@pattern_clean2 = Regexp.new(CLEAN_2)
1025
1038
  else
1039
+
1040
+ MODE = 'r'
1041
+
1026
1042
  @@pattern_get_attrs_map = Regexp.new(GET_ATTRS_MAP,nil,E_UTF8)
1027
1043
 
1028
1044
  @@pattern_clean1 = Regexp.new(CLEAN_1,nil,E_UTF8)
@@ -1174,21 +1190,21 @@ module Meteor
1174
1190
  @character_encoding = encoding
1175
1191
  #ファイルのオープン
1176
1192
  if RUBY_VERSION >= RUBY_VERSION_1_9_0 then
1177
- if "UTF-8".eql?(encoding) then
1178
- io = File.open(file_path,'r:' << encoding)
1193
+ if ParserFactory::ENC_UTF8.eql?(encoding) then
1194
+ io = File.open(file_path,MODE_BF << encoding)
1179
1195
  else
1180
- io = File.open(file_path,'r:' << encoding << ':utf-8')
1196
+ io = File.open(file_path,MODE_BF << encoding << MODE_AF)
1181
1197
  end
1182
1198
 
1183
1199
  #読込及び格納
1184
1200
  @root.document = io.read
1185
1201
  else
1186
1202
  #読込及び格納
1187
- io = open(file_path,'r')
1203
+ io = open(file_path,MODE)
1188
1204
  @root.document = io.read
1189
1205
  #@root.document = @root.document.kconv(get_encoding(), Kconv.guess(@root.document))
1190
1206
  #enc = Kconv.guess(@root.document)
1191
- enc = get_encoding()
1207
+ enc = get_encoding
1192
1208
  if !Kconv::UTF8.equal?(enc) then
1193
1209
  @root.document = @root.document.kconv(Kconv::UTF8, enc)
1194
1210
  end
@@ -2066,7 +2082,7 @@ module Meteor
2066
2082
  #
2067
2083
  # @param [Meteor::Element] elm 要素
2068
2084
  # @param [String] attr_name 属性名
2069
- # @param [String] attr_value 属性値
2085
+ # @param [String,TrueClass,FalseClass] attr_value 属性値
2070
2086
  #
2071
2087
  def set_attribute_3(elm,attr_name,attr_value)
2072
2088
  if !elm.cx then
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.3.0
4
+ version: 0.9.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - asip