resedit 1.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.
@@ -0,0 +1,73 @@
1
+ require 'resedit/text/format_text'
2
+ require 'resedit/text/format_xml'
3
+ require 'resedit/text/escaper'
4
+
5
+ module Resedit
6
+
7
+ class Text
8
+
9
+ attr_reader :lines, :format
10
+ attr_accessor :userData, :encoding, :escaper, :formatter, :meta
11
+ TYPE_TXT = 'txt'
12
+ TYPE_XML = 'xml'
13
+
14
+ def initialize(format=TYPE_TXT,encoding=nil)
15
+ @encoding = encoding
16
+ format=TYPE_TXT if !format
17
+ setFormat(format)
18
+ @escaper = StdEscaper.new()
19
+ @lines = []
20
+ @meta={}
21
+ end
22
+
23
+ def setFormat(format)
24
+ if format == TYPE_TXT
25
+ @format = format
26
+ @formatter=FormatTxt.new(@encoding)
27
+ elsif format == TYPE_XML
28
+ @format = format
29
+ @formatter=FormatXml.new(@encoding)
30
+ else
31
+ raise "Unsupported format " + format
32
+ end
33
+ end
34
+
35
+ def addLine(line, meta)
36
+ line.encode!("utf-8",@encoding) if @encoding
37
+ line.force_encoding('utf-8')
38
+ @lines += [line]
39
+ @meta[@lines.length-1]=meta
40
+ end
41
+
42
+ def getLine(id)
43
+ line = @lines[id]
44
+ line.encode!(@encoding) if @encoding
45
+ return line
46
+ end
47
+
48
+ def save(filename)
49
+ nl=@lines
50
+ if @escaper
51
+ nl=[]
52
+ @lines.each{|l|
53
+ nl += [@escaper.escape(l)]
54
+ }
55
+ end
56
+ @formatter.saveLines(filename, nl, @meta)
57
+ end
58
+
59
+ def load(filename, count=nil)
60
+ @lines = @formatter.loadLines(filename)
61
+ raise "Wrong lines count: "+filename if count && count!=@lines.length
62
+ if @escaper
63
+ nl=[]
64
+ @lines.each {|l|
65
+ nl += [@escaper.unescape(l)]
66
+ }
67
+ @lines = nl
68
+ end
69
+ end
70
+
71
+ end
72
+
73
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resedit
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.1
5
+ platform: ruby
6
+ authors:
7
+ - bjfn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chunky_png
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.5
27
+ description:
28
+ email:
29
+ executables:
30
+ - resedit
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - lib/resedit/app/app.rb
35
+ - lib/resedit/app/app_command.rb
36
+ - lib/resedit/app/colorizer.rb
37
+ - lib/resedit/app/font_convert.rb
38
+ - lib/resedit/app/io_commands.rb
39
+ - lib/resedit/app/mz_command.rb
40
+ - lib/resedit/app/std_commands.rb
41
+ - lib/resedit/app/text_convert.rb
42
+ - lib/resedit/convert/bitconv.rb
43
+ - lib/resedit/font/font.rb
44
+ - lib/resedit/font/font_char.rb
45
+ - lib/resedit/image/image.rb
46
+ - lib/resedit/image/image_factory.rb
47
+ - lib/resedit/image/png_image.rb
48
+ - lib/resedit/mz/changeable.rb
49
+ - lib/resedit/mz/hexwriter.rb
50
+ - lib/resedit/mz/mz.rb
51
+ - lib/resedit/mz/mz_body.rb
52
+ - lib/resedit/mz/mz_header.rb
53
+ - lib/resedit/mz/mzenv.rb
54
+ - lib/resedit/text/conv_keybru.rb
55
+ - lib/resedit/text/conv_table.rb
56
+ - lib/resedit/text/escaper.rb
57
+ - lib/resedit/text/format_text.rb
58
+ - lib/resedit/text/format_xml.rb
59
+ - lib/resedit/text/huffman.rb
60
+ - lib/resedit/text/text.rb
61
+ - lib/resedit.rb
62
+ - bin/resedit
63
+ homepage:
64
+ licenses: []
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.0.14.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: OG resource proc library!
86
+ test_files: []