uploadconvert 0.0.5 → 0.0.6

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/uploadconvert.rb +21 -1
  2. metadata +2 -2
data/lib/uploadconvert.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'json'
2
2
  require 'docsplit'
3
+ require 'crack'
3
4
 
4
5
  class UploadConvert
5
6
 
@@ -9,6 +10,26 @@ class UploadConvert
9
10
  @text = ""
10
11
  end
11
12
 
13
+ # Sends the document to the appropriate method
14
+ def handleDoc
15
+ if @input.include? "http"
16
+ `wget #{@input}`
17
+ path = @input.split("/")
18
+ @input = path[path.length-1].chomp.strip
19
+ handleDoc
20
+ elsif @input.include? ".pdf"
21
+ pdfTojson
22
+ elsif @input.include? ".xml"
23
+ xmlTojson(File.read(@input))
24
+ end
25
+ end
26
+
27
+ # Convert XML files to JSONs
28
+ def xmlTojson(xmlin)
29
+ xml = Crack::XML.parse(xmlin)
30
+ JSON.pretty_generate(xml)
31
+ end
32
+
12
33
  # Convert PDFs to JSON
13
34
  def pdfTojson
14
35
  # Extract and clean text
@@ -100,4 +121,3 @@ class UploadConvert
100
121
  return @metadata
101
122
  end
102
123
  end
103
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uploadconvert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-16 00:00:00.000000000 Z
12
+ date: 2014-03-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Converts documents to the appropriate format for Transparency Toolkit.
15
15
  email: shidash@shidash.com