xml_file_renamer 0.0.8 → 0.0.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abc8f48c224700cfbbc57548842dcead6441c9e6
4
- data.tar.gz: 008f6de205746b8787b7c3d95b1c291b26e8fe97
3
+ metadata.gz: 5b95c3a28d32904fbd55a1340b978bec5eca03d0
4
+ data.tar.gz: c03e4c4b681b777fbe1592892d4b28a0271e3c00
5
5
  SHA512:
6
- metadata.gz: fa69655120b5d0c40af8c9f5c6f98bef9c9bf77c83f3a4e9103d2859d59ee4a5bd4feabaa635f1193b4e7467dc57517c622b42a7d57bdd6c4086b01ac9bc0a34
7
- data.tar.gz: 57877bfc7039da6962d8c50e7179c7b20b05fd7f0f20c81675e4d1c69013e4444137a6ccc5e819b81af644fbd6b58b57b204de6109b4d90bf306d70c114921fe
6
+ metadata.gz: e34f2046765834dd8c27bf9a14a50a8dcc6cf3f9022a3cd886a4977008425383b4fab20157411145634deb0e04fe3b15cd0201a6476c38d0746eb48510bdfa8b
7
+ data.tar.gz: 0c847ff691649b7332e9c0b309ef19caac70be7faefaf1121728b800dbf2ed05129c8554973654bad7528b4fa4b249bc712ebcf5cc0d15abb0c0c3267d1a834a
data/README.md CHANGED
@@ -13,7 +13,7 @@ This is a Ruby class that allows you to rename your XML files based on content i
13
13
 
14
14
  Columbia Tower.xml, Space Needle.xml, Premiere on Pine.xml
15
15
 
16
- ####Where `"Columbia Tower"` is a text node, that you can locate with a CSS selector:
16
+ ####Where `"Columbia Tower"` is a text node, that you can locate by traversing tag names:
17
17
 
18
18
  'building Contact building_name'
19
19
 
@@ -28,13 +28,13 @@ This is a Ruby class that allows you to rename your XML files based on content i
28
28
 
29
29
  ###Run the command:
30
30
 
31
- $ xml_file_renamer '<source_data>' '<css_selector>'
31
+ $ xml_file_renamer '<source_data>' '<tag_names>' [<case>]
32
32
 
33
33
  ###Examples:
34
34
 
35
35
  Copy example XML files provided by the gem:
36
36
 
37
- $ cp -r `which xml_file_renamer`/../../gems/xml_file_renamer-0.0.7/example_xml_files ~/Documents/example_xml_files
37
+ $ cp -r `which xml_file_renamer`/../../gems/xml_file_renamer-0.0.8/example_xml_files ~/Documents/example_xml_files
38
38
 
39
39
  Run the command on a single file:
40
40
 
@@ -46,7 +46,7 @@ This is a Ruby class that allows you to rename your XML files based on content i
46
46
 
47
47
  **** Origin Directory: /Users/sealocal/Documents/example_xml_files
48
48
  **** Export Directory: /Users/sealocal/Documents/example_xml_files/export_folder
49
- **** CSS selector: building Contact building_name
49
+ **** Tag Names: building Contact building_name
50
50
  **** Source File: example_building_589989.xml
51
51
  **** New File Name: Columbia Center
52
52
 
@@ -58,18 +58,32 @@ This is a Ruby class that allows you to rename your XML files based on content i
58
58
 
59
59
  **** Origin Directory: /Users/sealocal/Documents/example_xml_files
60
60
  **** Export Directory: /Users/sealocal/Documents/example_xml_files/export_folder
61
- **** CSS selector: building Contact building_name
61
+ **** Tag Names: building Contact building_name
62
62
  **** Source File: example_building_589989.xml
63
63
  **** New File Name: Columbia Center
64
64
  **** Source File: example_building_589990.xml
65
65
  **** New File Name: Space Needle
66
66
  **** Source File: example_building_589991.xml
67
- **** New File Name: Premier on Pine
67
+ **** New File Name: Premiere on Pine
68
68
 
69
69
 
70
+ Case Option:
71
+
72
+ Case options will convert the case of the new string:
73
+
74
+ $ xml_file_renamer building.xml 'building Contact building_name' lower_case
75
+
76
+ These are valid options:
77
+
78
+ lower_case #=> 'space needle.xml'
79
+ upper_case #=> 'SPACE NEEDLE.xml'
80
+ title_case #=> 'Space Needle.xml'
81
+ camel_case #=> 'SpaceNeedle.xml'
82
+ snake_case #=> 'space_needle.xml'
83
+
70
84
  ####Notes:
71
85
 
72
- 1. <source_data> must contain an XML tree, with a match for your CSS selector.
86
+ 1. <source_data> must contain an XML tree, with a match for your tag names.
73
87
 
74
88
  2. <source_data> can have ANY file extension. As long as it HAS a file extension,
75
89
  this utility will find your file an rename it.
@@ -4,6 +4,6 @@ require 'xml_file_renamer'
4
4
  xfr = XMLFileRenamer.new(ARGV[0], ARGV[1], ARGV[2])
5
5
  xfr.print_origin_directory
6
6
  xfr.print_export_directory
7
- xfr.print_css_selector
7
+ xfr.print_tag_names
8
8
  xfr.print_case_option
9
9
  xfr.rename
@@ -11,7 +11,7 @@
11
11
  <country>United States</country>
12
12
  </location>
13
13
  <building_name>
14
- Premier on Pine
14
+ Premiere on Pine
15
15
  </building_name>
16
16
  <alt_building_name>
17
17
  815 Pine
@@ -2,13 +2,13 @@ require 'nokogiri'
2
2
  require 'active_support/all'
3
3
 
4
4
  class XMLFileRenamer
5
- attr_reader :source_data, :css_selector, :case_option,
5
+ attr_reader :source_data, :tag_names, :case_option,
6
6
  :xml_document, :origin_directory, :export_directory,
7
7
  :new_file_name, :destination_file_name
8
8
 
9
- def initialize(source_data, css_selector, case_option = nil)
9
+ def initialize(source_data, tag_names, case_option = nil)
10
10
  @source_data = source_data
11
- @css_selector = css_selector
11
+ @tag_names = tag_names
12
12
  @case_option = case_option
13
13
 
14
14
  set_origin_directory
@@ -25,9 +25,9 @@ class XMLFileRenamer
25
25
  export_directory
26
26
  end
27
27
 
28
- def print_css_selector
29
- puts '**** CSS selector: ' + css_selector
30
- css_selector
28
+ def print_tag_names
29
+ puts '**** Tag Names: ' + tag_names
30
+ tag_names
31
31
  end
32
32
 
33
33
  def print_case_option
@@ -53,7 +53,7 @@ class XMLFileRenamer
53
53
  Dir.chdir(source_data) do
54
54
  all_regular_files_in_directory = Dir.glob('*.*')
55
55
  all_regular_files_in_directory.each do |file_name|
56
- xml_file_renamer = XMLFileRenamer.new(file_name, css_selector, case_option)
56
+ xml_file_renamer = XMLFileRenamer.new(file_name, tag_names, case_option)
57
57
  new_files << xml_file_renamer.rename
58
58
  end
59
59
  end
@@ -85,8 +85,8 @@ class XMLFileRenamer
85
85
  end
86
86
 
87
87
  def query_xml_file
88
- xml_query_by_css = xml_document.css(css_selector)
89
- @new_file_name = xml_query_by_css.text.strip
88
+ xml_query_by_tag_names = xml_document.css(tag_names)
89
+ @new_file_name = xml_query_by_tag_names.text.strip
90
90
  end
91
91
 
92
92
  def convert_case
@@ -100,6 +100,8 @@ class XMLFileRenamer
100
100
  @new_file_name.split.join.camelcase
101
101
  elsif case_option == 'snake_case'
102
102
  @new_file_name.titleize.split.join.underscore
103
+ else
104
+ @new_file_name
103
105
  end
104
106
  end
105
107
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xml_file_renamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Taylor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-18 00:00:00.000000000 Z
11
+ date: 2014-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -24,7 +24,8 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.6.1
27
- description: A Ruby class for renaming xml files based on content inside the XML.
27
+ description: A command line executable for renaming XML files to content of an XML
28
+ tag.
28
29
  email: local.mat@gmail.com
29
30
  executables:
30
31
  - xml_file_renamer
@@ -58,9 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
59
  version: '0'
59
60
  requirements: []
60
61
  rubyforge_project:
61
- rubygems_version: 2.2.1
62
+ rubygems_version: 2.2.2
62
63
  signing_key:
63
64
  specification_version: 4
64
- summary: Rename XML files.
65
+ summary: Batch rename XML files - rule the world!
65
66
  test_files: []
66
- has_rdoc: