xml_split 0.0.1 → 0.0.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.
data/CHANGELOG ADDED
@@ -0,0 +1,9 @@
1
+ 0.0.2 / 2012-10-02
2
+
3
+ * Enhancements
4
+
5
+ * Provide xml_split binary
6
+
7
+ 0.0.1 / 2012-10-01
8
+
9
+ Initial release!
data/README.md CHANGED
@@ -6,6 +6,12 @@ Uses [sgrep](http://www.cs.helsinki.fi/u/jjaakkol/sgrepman.html) internally.
6
6
 
7
7
  As seen on ["Split XML files with `sgrep`, a classic UNIX utility from 1995"](http://numbers.brighterplanet.com/2012/09/11/split-xml-files-with-unix-utility-sgrep/)
8
8
 
9
+ Similar, but not identical, to [XML-Twig's xml_split](http://search.cpan.org/~mirod/XML-Twig-3.41/tools/xml_split/xml_split).
10
+
11
+ ## Dependencies
12
+
13
+ Currently requires that you have `sgrep` or `sgrep2` in your path.
14
+
9
15
  ## Usage
10
16
 
11
17
  >> require 'xml_split'
@@ -24,6 +30,26 @@ As seen on ["Split XML files with `sgrep`, a classic UNIX utility from 1995"](ht
24
30
  </IntervalReading>
25
31
  [...]
26
32
 
33
+ ## Command-line
34
+
35
+ gem install xml_split
36
+
37
+ This will give you a binary called `xml_split`. You can use it to split XML files into many smaller files:
38
+
39
+ $ xml_split ~/samples/CLF8762E_20120709.xml MyElement CLF8762E/20120709
40
+ [...]
41
+ $ ls CLF8762E
42
+ 20120709_0000000000
43
+ 20120709_0000000001
44
+ 20120709_0000000002
45
+ 20120709_0000000003
46
+ 20120709_0000000004
47
+ 20120709_0000000005
48
+ 20120709_0000000006
49
+ 20120709_0000000007
50
+ 20120709_0000000008
51
+ [...]
52
+
27
53
  ## Copyright
28
54
 
29
55
  Copyright 2012 Brighter Planet, Inc.
data/bin/xml_split CHANGED
@@ -1,3 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'xml_split'
4
+
5
+ if ARGV.length == 3
6
+ input_path, element, output_prefix = ARGV
7
+ x = XmlSplit.new(input_path, element)
8
+ base_output_path = File.expand_path output_prefix
9
+ unless File.directory?(File.dirname(base_output_path))
10
+ $stderr.puts "Creating directory structure #{File.dirname(base_output_path)}"
11
+ require 'fileutils'
12
+ FileUtils.mkdir_p File.dirname(base_output_path)
13
+ end
14
+ x.each_with_index do |part, i|
15
+ File.open("#{base_output_path}_#{'%010d' % i}", 'w') do |f|
16
+ f.write part
17
+ end
18
+ end
19
+ else
20
+ puts "Usage: xml_split INPUTPATH ELEMENT OUTPUTPREFIX"
21
+ end
@@ -1,3 +1,3 @@
1
1
  class XmlSplit
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml_split
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -101,6 +101,7 @@ extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
103
  - .gitignore
104
+ - CHANGELOG
104
105
  - Gemfile
105
106
  - LICENSE.txt
106
107
  - README.md