textutils 0.9.9 → 0.9.10

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.
@@ -7,6 +7,33 @@ class HashReader
7
7
 
8
8
  include LogUtils::Logging
9
9
 
10
+ def self.from_zip( zip_file, entry_path )
11
+ entry = zip_file.find_entry( entry_path )
12
+
13
+ ## todo/fix: add force encoding to utf-8 ??
14
+ ## check!!!
15
+ ## clean/prepprocess lines
16
+ ## e.g. CR/LF (/r/n) to LF (e.g. /n)
17
+ text = entry.get_input_stream().read()
18
+
19
+ ## NOTE: needs logger ref; only available in instance methods; use global logger for now
20
+ logger = LogUtils::Logger.root
21
+ logger.debug "text.encoding.name (before): #{text.encoding.name}"
22
+ #####
23
+ # NB: ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
24
+ ## NB:
25
+ # for now "hardcoded" to utf8 - what else can we do?
26
+ # - note: force_encoding will NOT change the chars only change the assumed encoding w/o translation
27
+ text = text.force_encoding( Encoding::UTF_8 )
28
+ logger.debug "text.encoding.name (after): #{text.encoding.name}"
29
+
30
+ ## todo:
31
+ # NB: for convenience: convert fancy unicode dashes/hyphens to plain ascii hyphen-minus
32
+ ## text = TextUtils.convert_unicode_dashes_to_plain_ascii( text, path: path )
33
+
34
+ self.from_string( text )
35
+ end
36
+
10
37
  def self.from_file( path )
11
38
  ## nb: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
12
39
  ## - see textutils/utils.rb
@@ -28,6 +28,33 @@ class LineReader
28
28
 
29
29
  include LogUtils::Logging
30
30
 
31
+ def self.from_zip( zip_file, entry_path )
32
+ entry = zip_file.find_entry( entry_path )
33
+
34
+ ## todo/fix: add force encoding to utf-8 ??
35
+ ## check!!!
36
+ ## clean/prepprocess lines
37
+ ## e.g. CR/LF (/r/n) to LF (e.g. /n)
38
+ text = entry.get_input_stream().read()
39
+
40
+ ## NOTE: needs logger ref; only available in instance methods; use global logger for now
41
+ logger = LogUtils::Logger.root
42
+ logger.debug "text.encoding.name (before): #{text.encoding.name}"
43
+ #####
44
+ # NB: ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
45
+ ## NB:
46
+ # for now "hardcoded" to utf8 - what else can we do?
47
+ # - note: force_encoding will NOT change the chars only change the assumed encoding w/o translation
48
+ text = text.force_encoding( Encoding::UTF_8 )
49
+ logger.debug "text.encoding.name (after): #{text.encoding.name}"
50
+
51
+ ## todo:
52
+ # NB: for convenience: convert fancy unicode dashes/hyphens to plain ascii hyphen-minus
53
+ ## text = TextUtils.convert_unicode_dashes_to_plain_ascii( text, path: path )
54
+
55
+ self.from_string( text )
56
+ end
57
+
31
58
  def self.from_file( path )
32
59
  ## nb: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
33
60
  ## - see textutils/utils.rb
@@ -3,7 +3,7 @@ module TextUtils
3
3
 
4
4
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
5
5
  MINOR = 9
6
- PATCH = 9
6
+ PATCH = 10
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: textutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.9
4
+ version: 0.9.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-08 00:00:00.000000000 Z
12
+ date: 2014-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: props
16
- requirement: &79823580 !ruby/object:Gem::Requirement
16
+ requirement: &78561960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *79823580
24
+ version_requirements: *78561960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: logutils
27
- requirement: &79823050 !ruby/object:Gem::Requirement
27
+ requirement: &78561710 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *79823050
35
+ version_requirements: *78561710
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rubyzip
38
- requirement: &79822760 !ruby/object:Gem::Requirement
38
+ requirement: &78561390 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *79822760
46
+ version_requirements: *78561390
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activesupport
49
- requirement: &79822540 !ruby/object:Gem::Requirement
49
+ requirement: &78561100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *79822540
57
+ version_requirements: *78561100
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rdoc
60
- requirement: &79822210 !ruby/object:Gem::Requirement
60
+ requirement: &78560650 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '4.0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *79822210
68
+ version_requirements: *78560650
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: hoe
71
- requirement: &79821880 !ruby/object:Gem::Requirement
71
+ requirement: &78560350 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '3.13'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *79821880
79
+ version_requirements: *78560350
80
80
  description: textutils - Text Filters, Helpers, Readers and More
81
81
  email: ruby-talk@ruby-lang.org
82
82
  executables: []