rsmart_toolbox 0.4 → 0.5
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 +4 -4
- checksums.yaml.gz.sig +1 -1
- data.tar.gz.sig +0 -0
- data/README.md +9 -5
- data/bin/transform_CSV_to_HR_XML +31 -9
- data/lib/rsmart_toolbox/etl/grm.rb +2 -2
- data/lib/rsmart_toolbox/version.rb +1 -1
- data/rsmart_toolbox.gemspec +1 -0
- metadata +16 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e7e3f98bbbd519f2f57c8c5a9da33cca0a3de3
|
4
|
+
data.tar.gz: c90a54912dc4d9c536337697a13c028bbdfb8011
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34892dcd8adf786319d6d4261fc291bda5cdeb4903c78ed8fcc74b0de74cc734c192886ce809b2c9a91e40f7916b21941214be55a32c7832787dbccc92a56b05
|
7
|
+
data.tar.gz: 6ec1f8e88e4a45aee20efb607c05169dee3994262093367915abc8a25ca138f850aa043672fa353d2c33a3b90db41ac208043d22e4cfdbfb36fc235831bb2065
|
checksums.yaml.gz.sig
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
kd����Z}�>�f������22�w�tLH ι�
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -8,7 +8,12 @@ Client library and command-line tools to help interact with rSmart's cloud APIs.
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
|
11
|
+
To simply install the gem and provide access to the command line tools:
|
12
|
+
|
13
|
+
$ gem install rsmart_toolbox
|
14
|
+
|
15
|
+
However, if you would like to reuse the our ruby modules in your own ruby program,
|
16
|
+
add this line to your application's Gemfile:
|
12
17
|
|
13
18
|
```ruby
|
14
19
|
gem 'rsmart_toolbox'
|
@@ -18,10 +23,6 @@ And then execute:
|
|
18
23
|
|
19
24
|
$ bundle
|
20
25
|
|
21
|
-
Or install it yourself as:
|
22
|
-
|
23
|
-
$ gem install rsmart_toolbox
|
24
|
-
|
25
26
|
## Usage
|
26
27
|
|
27
28
|
### transform_CSV_to_HR_XML
|
@@ -33,6 +34,9 @@ Usage: transform_CSV_to_HR_XML [options] csv_file
|
|
33
34
|
--separator
|
34
35
|
-q, --quote [quote_character] The character used to quote fields.
|
35
36
|
-e, --email [email_recipients] Email recipient list that will receive job report status.
|
37
|
+
-u, --username [username] The username used to authenticate to the HR REST API.
|
38
|
+
-p, --password [password] The password used to authenticate to the HR REST API.
|
39
|
+
-l, --url [url] The full URL of the HR REST API; e.g. https://localhost/kc-dev/hr-import/hrimport/import
|
36
40
|
-h, --help Display this screen
|
37
41
|
```
|
38
42
|
|
data/bin/transform_CSV_to_HR_XML
CHANGED
@@ -8,7 +8,7 @@ require 'csv'
|
|
8
8
|
require 'net/http'
|
9
9
|
require 'nokogiri'
|
10
10
|
require 'optparse'
|
11
|
-
require '
|
11
|
+
require 'rest_client'
|
12
12
|
require 'tempfile'
|
13
13
|
require 'time'
|
14
14
|
require 'rsmart_toolbox/etl/grm'
|
@@ -17,7 +17,7 @@ ETL = Rsmart::ETL
|
|
17
17
|
GRM = Rsmart::ETL::GRM
|
18
18
|
TextParseError = Rsmart::ETL::TextParseError
|
19
19
|
|
20
|
-
def self.
|
20
|
+
def self.parse_command_line_options(
|
21
21
|
executable, args, opt={ csv_options: { headers: :first_row,
|
22
22
|
header_converters: :symbol,
|
23
23
|
skip_blanks: true,
|
@@ -30,15 +30,24 @@ def self.parse_csv_command_line_options(
|
|
30
30
|
opts.on( '-o [xml_file_output]' ,'--output [xml_file_output]', 'The file in which the the XML data will be writen (defaults to <csv_file>.xml)') do |f|
|
31
31
|
opt[:xml_filename] = f
|
32
32
|
end
|
33
|
-
opts.on( '-s [separator_character]' ,'--separator [separator_character]', 'The character that separates each column of the CSV file.') do |s|
|
33
|
+
opts.on( '-s [separator_character]' ,'--separator [separator_character]', 'The character that separates each column of the CSV file.' ) do |s|
|
34
34
|
opt[:col_sep] = s
|
35
35
|
end
|
36
|
-
opts.on( '-q [quote_character]' ,'--quote [quote_character]', 'The character used to quote fields.') do |q|
|
36
|
+
opts.on( '-q [quote_character]' ,'--quote [quote_character]', 'The character used to quote fields.' ) do |q|
|
37
37
|
opt[:quote_char] = q
|
38
38
|
end
|
39
|
-
opts.on('-e [email_recipients]', '--email [email_recipients]', 'Email recipient list that will receive job report status.') do |e|
|
39
|
+
opts.on( '-e [email_recipients]', '--email [email_recipients]', 'Email recipient list that will receive job report status.' ) do |e|
|
40
40
|
opt[:email_recipients] = e
|
41
41
|
end
|
42
|
+
opts.on( '-u [username]', '--username [username]', 'The username used to authenticate to the HR REST API.' ) do |u|
|
43
|
+
opt[:username] = u
|
44
|
+
end
|
45
|
+
opts.on( '-p [password]', '--password [password]', 'The password used to authenticate to the HR REST API.' ) do |p|
|
46
|
+
opt[:password] = p
|
47
|
+
end
|
48
|
+
opts.on( '-l [url]', '--url [url]', 'The full URL of the HR REST API; e.g. https://localhost/kc-dev/hr-import/hrimport/import' ) do |l|
|
49
|
+
opt[:url] = l
|
50
|
+
end
|
42
51
|
opts.on( '-h', '--help', 'Display this screen' ) do
|
43
52
|
puts opts
|
44
53
|
exit 1
|
@@ -64,10 +73,16 @@ def self.parse_csv_command_line_options(
|
|
64
73
|
opt[:email_recipients] = "no-reply@rsmart.com"
|
65
74
|
end
|
66
75
|
|
76
|
+
if opt[:url]
|
77
|
+
unless opt[:username] && opt[:password]
|
78
|
+
raise ArgumentError, "Username and password are required when POSTing to a URL!"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
67
82
|
return opt
|
68
83
|
end
|
69
84
|
|
70
|
-
opt =
|
85
|
+
opt = parse_command_line_options (File.basename $0), ARGF.argv
|
71
86
|
|
72
87
|
CSV.open(opt[:csv_filename], opt[:csv_options]) do |csv|
|
73
88
|
record_count = csv.readlines.count
|
@@ -261,7 +276,7 @@ CSV.open(opt[:csv_filename], opt[:csv_options]) do |csv|
|
|
261
276
|
end # row
|
262
277
|
end # record
|
263
278
|
end # hrmanifest
|
264
|
-
end #
|
279
|
+
end # xml_file
|
265
280
|
end # csv
|
266
281
|
puts "\nXML file written to #{opt[:xml_filename]}\n\n"
|
267
282
|
|
@@ -280,9 +295,9 @@ Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
280
295
|
doc = Nokogiri::XML File.read opt[:xml_filename]
|
281
296
|
xml_errors = xsd.validate doc
|
282
297
|
if xml_errors.empty?
|
283
|
-
puts "Congratulations! The XML file passes XSD schema validation! w00t
|
298
|
+
puts "Congratulations! The XML file passes XSD schema validation! w00t!\n\n"
|
284
299
|
else
|
285
|
-
puts "
|
300
|
+
puts "Sorry, the XML file does NOT pass XSD schema validation!:"
|
286
301
|
xml_errors.each do |error|
|
287
302
|
puts error.message
|
288
303
|
end
|
@@ -290,3 +305,10 @@ Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
290
305
|
end
|
291
306
|
end # file
|
292
307
|
end
|
308
|
+
|
309
|
+
# POST the XML file to the server if opt[:url]
|
310
|
+
if opt[:url]
|
311
|
+
resource = RestClient::Resource.new( opt[:url], opt[:username], opt[:password] )
|
312
|
+
resource.post file: File.new(opt[:xml_filename], 'rt'), content_type: 'multipart/form-data', multipart: true
|
313
|
+
puts "\n"
|
314
|
+
end
|
@@ -114,7 +114,7 @@ module Rsmart::ETL::GRM
|
|
114
114
|
|
115
115
|
def self.parse_address_type_code(str, opt={})
|
116
116
|
# TODO find real column name
|
117
|
-
opt[:name] = "
|
117
|
+
opt[:name] = "ADDR_TYP_CD" if opt[:name].nil?
|
118
118
|
opt[:length] = 3 if opt[:length].nil?
|
119
119
|
opt[:valid_values] = /^(HM|OTH|WRK)$/i if opt[:valid_values].nil?
|
120
120
|
return Rsmart::ETL::parse_flag str, opt
|
@@ -145,7 +145,7 @@ module Rsmart::ETL::GRM
|
|
145
145
|
|
146
146
|
def self.parse_phone_type(str, opt={})
|
147
147
|
# TODO find real column name
|
148
|
-
opt[:name] = "
|
148
|
+
opt[:name] = "PHONE_TYP_CD" if opt[:name].nil?
|
149
149
|
opt[:length] = 3 if opt[:length].nil?
|
150
150
|
opt[:valid_values] = /^(FAX|HM|MBL|OTH|WRK)$/i if opt[:valid_values].nil?
|
151
151
|
return Rsmart::ETL::parse_flag str, opt
|
data/rsmart_toolbox.gemspec
CHANGED
@@ -37,6 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
|
38
38
|
spec.add_runtime_dependency 'builder', '~> 3.2.2'
|
39
39
|
spec.add_runtime_dependency 'nokogiri', '~> 1.6.3.1'
|
40
|
+
spec.add_runtime_dependency 'rest-client', '~> 1.7.2'
|
40
41
|
|
41
42
|
spec.required_ruby_version = '>= 1.9'
|
42
43
|
spec.add_development_dependency "bundler", "~> 1.6"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsmart_toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.5'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lance Speelmon
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
sKRWzEtHFamxQaIspOja5O4oQKiCbWa90fEuIoCtwyy1rQtL9VKoDTs4vZASXNuc
|
31
31
|
F/lEyekXSjN36uTtlt4LkKLn/k7k5gRbt4+C9Q==
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2014-08-
|
33
|
+
date: 2014-08-17 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: builder
|
@@ -60,6 +60,20 @@ dependencies:
|
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: 1.6.3.1
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rest-client
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.7.2
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 1.7.2
|
63
77
|
- !ruby/object:Gem::Dependency
|
64
78
|
name: bundler
|
65
79
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|