loe-hypodermic 0.1.1 → 0.1.2

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.
@@ -38,15 +38,29 @@ class Hypodermic
38
38
  end
39
39
 
40
40
  def self.xml_from_word(path)
41
- Zip::ZipFile.open(path) { |z| z.read('word/document.xml') }
41
+ Zip::ZipFile.open(path) do |z|
42
+ z.read('word/document.xml')
43
+ end
42
44
  end
43
45
 
44
46
  def self.xml_from_excel(path)
45
- Zip::ZipInputStream::open(path) { |io| while(entry = io.get_next_entry); xml = io.read if entry.name =~ /(xl\/worksheets\/)|(xl\/sharedStrings.xml)/; end; xml }
47
+ Zip::ZipInputStream::open(path) do |io|
48
+ xml = ''
49
+ while(entry = io.get_next_entry)
50
+ xml << io.read if entry.name =~ /(xl\/worksheets)|(sharedStrings.xml)/
51
+ end
52
+ xml
53
+ end
46
54
  end
47
55
 
48
56
  def self.xml_from_powerpoint(path)
49
- Zip::ZipInputStream::open(path) { |io| while(entry = io.get_next_entry); xml = io.read if entry.name =~ /(ppt\/slides\/)|(ppt\/presentation.xml)/; end; xml }
57
+ Zip::ZipInputStream::open(path) do |io|
58
+ xml = ''
59
+ while(entry = io.get_next_entry)
60
+ xml << io.read if entry.name =~ /(ppt\/slides)|(presentation.xml)/
61
+ end
62
+ xml
63
+ end
50
64
  end
51
65
 
52
66
  def self.thumbnail(path)
@@ -1,3 +1,3 @@
1
1
  module Hypodermic
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -35,41 +35,26 @@ describe Hypodermic do
35
35
  end
36
36
 
37
37
  it "should not raise an error if you pass a path" do
38
- lambda { Hypodermic.extract("path") }.should_not raise_error
38
+ lambda { Hypodermic.extract("path.docx",) }.should_not raise_error
39
39
  end
40
40
 
41
41
  it "should not raise an error if you also want a thumbnail" do
42
- lambda { Hypodermic.extract("path", :thumbnail => true) }.should_not raise_error
42
+ lambda { Hypodermic.extract("path.docx", :thumbnail => true) }.should_not raise_error
43
43
  end
44
44
 
45
45
  end
46
46
 
47
- describe ".xml_from_word" do
48
- before(:each) do
49
- stub_word_document
50
- end
51
-
52
- it "should not raise an error, given a path argument" do
53
- lambda { Hypodermic.send(:document_xml, "path") }.should_not raise_error
54
- end
55
-
56
- it "should return the document.xml" do
57
- result = Hypodermic.send(:document_xml, "path")
58
- result.should == File.read(@document_path)
59
- end
60
- end
61
-
62
47
  describe ".document" do
63
48
  before(:each) do
64
49
  stub_word_document
65
50
  end
66
51
 
67
52
  it "should not raise an error" do
68
- lambda { Hypodermic.send(:document, "path") }.should_not raise_error
53
+ lambda { Hypodermic.send(:document, "path.docx") }.should_not raise_error
69
54
  end
70
55
 
71
56
  it "should return the file without tags" do
72
- result = Hypodermic.send(:document, "path")
57
+ result = Hypodermic.send(:document, "path.docx")
73
58
  result.should == File.read(@word_document_path).gsub(/<.*?>/, ' ')
74
59
  end
75
60
  end
@@ -80,13 +65,28 @@ describe Hypodermic do
80
65
  end
81
66
 
82
67
  it "should not raise an error, given the path argument" do
83
- lambda { Hypodermic.send(:thumbnail, "path") }
68
+ lambda { Hypodermic.send(:thumbnail, "path.docx") }
84
69
  end
85
70
 
86
71
  it "should return thumbnail.jpeg" do
87
- result = Hypodermic.send(:thumbnail, "path")
72
+ result = Hypodermic.send(:thumbnail, "path.docx")
88
73
  result.should == File.read(@thumbnail_path)
89
74
  end
90
75
  end
91
76
 
77
+ describe ".xml_from_word" do
78
+ before(:each) do
79
+ stub_word_document
80
+ end
81
+
82
+ it "should not raise an error, given a path argument" do
83
+ lambda { Hypodermic.send(:xml_from_word, "path.docx") }.should_not raise_error
84
+ end
85
+
86
+ it "should return the document.xml" do
87
+ result = Hypodermic.send(:xml_from_word, "path.docx")
88
+ result.should == File.read(@word_document_path)
89
+ end
90
+ end
91
+
92
92
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loe-hypodermic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - W. Andrew Loe III
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2006-06-06 00:00:00 -07:00
12
+ date: 2006-06-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -33,6 +33,33 @@ files:
33
33
  - lib/hypodermic.rb
34
34
  - lib/hypodermic
35
35
  - lib/hypodermic/version.rb
36
+ has_rdoc: false
37
+ homepage: http://github.com/loe/hypodermic
38
+ post_install_message:
39
+ rdoc_options: []
40
+
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.0.1
59
+ signing_key:
60
+ specification_version: 2
61
+ summary: Opens a .docx file and returns a plain text string of the contents and optionally returns the thumbnail.
62
+ test_files:
36
63
  - spec/helper.rb
37
64
  - spec/hypodermic
38
65
  - spec/hypodermic/hypodermic_spec.rb
@@ -120,31 +147,3 @@ files:
120
147
  - spec/hypodermic/foo.xlsx/docProps/thumbnail.jpeg
121
148
  - spec/hypodermic/foo.xlsx/docProps/core.xml
122
149
  - spec/hypodermic/foo.xlsx/docProps/app.xml
123
- has_rdoc: false
124
- homepage: http://github.com/loe/hypodermic
125
- post_install_message:
126
- rdoc_options: []
127
-
128
- require_paths:
129
- - lib
130
- required_ruby_version: !ruby/object:Gem::Requirement
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: "0"
135
- version:
136
- required_rubygems_version: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- version: "0"
141
- version:
142
- requirements: []
143
-
144
- rubyforge_project:
145
- rubygems_version: 1.0.1
146
- signing_key:
147
- specification_version: 2
148
- summary: Opens a .docx file and returns a plain text string of the contents and optionally returns the thumbnail.
149
- test_files: []
150
-