truss_parser 0.1.0
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +54 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/challenge.md +36 -0
- data/exe/truss_parser +2 -0
- data/lib/truss_parser/cli.rb +13 -0
- data/lib/truss_parser/parser.rb +154 -0
- data/lib/truss_parser/version.rb +3 -0
- data/lib/truss_parser.rb +2 -0
- data/sample-with-broken-utf8.csv +10 -0
- data/sample.csv +10 -0
- data/truss_parser.gemspec +46 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ab21683914e06a2b107c982c980841853c598f42
|
4
|
+
data.tar.gz: 996aad0ad7210cc0b0cd92b5d66b3ae15771e3c6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f345790b4bc5f6a3e1f5b26fbdbcd39635463d3ce07d43c2a635eb9dc9a84d2a93b8106968298eb7589cdf8c6be589553dbd91e3abefa71416ed897ae1529c84
|
7
|
+
data.tar.gz: 440154587b48fc99ca3a419d9f223f3e9798a0bb28d0ce93feec9a00bd2bacf298121762fb3359da76fd08ac4004496bd584e09697b638f858d8419e19913359
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at arbonap@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
truss_parser (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (5.2.2)
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
+
i18n (>= 0.7, < 2)
|
12
|
+
minitest (~> 5.1)
|
13
|
+
tzinfo (~> 1.1)
|
14
|
+
artii (2.1.2)
|
15
|
+
byebug (11.0.0)
|
16
|
+
concurrent-ruby (1.1.5)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
i18n (1.6.0)
|
19
|
+
concurrent-ruby (~> 1.0)
|
20
|
+
minitest (5.11.3)
|
21
|
+
rake (10.5.0)
|
22
|
+
rspec (3.8.0)
|
23
|
+
rspec-core (~> 3.8.0)
|
24
|
+
rspec-expectations (~> 3.8.0)
|
25
|
+
rspec-mocks (~> 3.8.0)
|
26
|
+
rspec-core (3.8.0)
|
27
|
+
rspec-support (~> 3.8.0)
|
28
|
+
rspec-expectations (3.8.2)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.8.0)
|
31
|
+
rspec-mocks (3.8.0)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.8.0)
|
34
|
+
rspec-support (3.8.0)
|
35
|
+
thor (0.20.0)
|
36
|
+
thread_safe (0.3.6)
|
37
|
+
tzinfo (1.2.5)
|
38
|
+
thread_safe (~> 0.1)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
activesupport
|
45
|
+
artii
|
46
|
+
bundler (~> 1.17)
|
47
|
+
byebug
|
48
|
+
rake (~> 10.0)
|
49
|
+
rspec (~> 3.0)
|
50
|
+
thor (= 0.20.0)
|
51
|
+
truss_parser!
|
52
|
+
|
53
|
+
BUNDLED WITH
|
54
|
+
1.17.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Patricia Arbona
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# TrussParser
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/truss_parser`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'truss_parser'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install truss_parser
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/truss_parser. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Code of Conduct
|
42
|
+
|
43
|
+
Everyone interacting in the TrussParser project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/truss_parser/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "truss_parser"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/challenge.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
Please write a tool that reads a CSV formatted file on `stdin` and
|
2
|
+
emits a normalized CSV formatted file on `stdout`. Normalized, in this
|
3
|
+
case, means:
|
4
|
+
|
5
|
+
* The entire CSV is in the UTF-8 character set.
|
6
|
+
* The Timestamp column should be formatted in ISO-8601 format.
|
7
|
+
* The Timestamp column should be assumed to be in US/Pacific time;
|
8
|
+
please convert it to US/Eastern.
|
9
|
+
* All ZIP codes should be formatted as 5 digits. If there are less
|
10
|
+
than 5 digits, assume 0 as the prefix.
|
11
|
+
* All name columns should be converted to uppercase. There will be
|
12
|
+
non-English names.
|
13
|
+
* The Address column should be passed through as is, except for
|
14
|
+
Unicode validation. Please note there are commas in the Address
|
15
|
+
field; your CSV parsing will need to take that into account. Commas
|
16
|
+
will only be present inside a quoted string.
|
17
|
+
* The columns `FooDuration` and `BarDuration` are in HH:MM:SS.MS
|
18
|
+
format (where MS is milliseconds); please convert them to a floating
|
19
|
+
point seconds format.
|
20
|
+
* The column "TotalDuration" is filled with garbage data. For each
|
21
|
+
row, please replace the value of TotalDuration with the sum of
|
22
|
+
FooDuration and BarDuration.
|
23
|
+
* The column "Notes" is free form text input by end-users; please do
|
24
|
+
not perform any transformations on this column. If there are invalid
|
25
|
+
UTF-8 characters, please replace them with the Unicode Replacement
|
26
|
+
Character.
|
27
|
+
|
28
|
+
You can assume that the input document is in UTF-8 and that any times
|
29
|
+
that are missing timezone information are in US/Pacific. If a
|
30
|
+
character is invalid, please replace it with the Unicode Replacement
|
31
|
+
Character. If that replacement makes data invalid (for example,
|
32
|
+
because it turns a date field into something unparseable), print a
|
33
|
+
warning to `stderr` and drop the row from your output.
|
34
|
+
|
35
|
+
You can assume that the sample data we provide will contain all date
|
36
|
+
and time format variants you will need to handle.
|
data/exe/truss_parser
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "byebug"
|
2
|
+
require_relative "parser"
|
3
|
+
class Cli
|
4
|
+
extend Parser
|
5
|
+
|
6
|
+
puts Parser::Normalization.ascii
|
7
|
+
Parser::Normalization.welcome
|
8
|
+
|
9
|
+
@normalization = Parser::Normalization.new(ARGV)
|
10
|
+
@normalization.truncate if File.open('normalized_data.csv', "a+").present?
|
11
|
+
@normalization.scrub
|
12
|
+
@normalization.normalize
|
13
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require 'csv'
|
2
|
+
require "active_support/all"
|
3
|
+
require 'active_support/time_with_zone'
|
4
|
+
|
5
|
+
module Parser
|
6
|
+
class Normalization
|
7
|
+
attr_accessor :csv_file
|
8
|
+
|
9
|
+
def initialize(argv)
|
10
|
+
@csv_file = argv[0]
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.ascii
|
14
|
+
# the artii gem creates ascii text
|
15
|
+
# this method shells it out
|
16
|
+
`artii Truss Parser`
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.welcome
|
20
|
+
puts 'Hello! Welcome to the Truss Parser that normalizes CSV data.
|
21
|
+
A normalized CSV formatted file will be outputted on `stdout`.
|
22
|
+
You will also see the normalized output as a CSV in `normalized_data.csv`.
|
23
|
+
A warning will be piped to `stderr` if there is any unparseable data,
|
24
|
+
and its correspnding row will be dropped from your output.'
|
25
|
+
end
|
26
|
+
|
27
|
+
def scrub
|
28
|
+
# make sure there is only one argument from STDIN
|
29
|
+
validate_args
|
30
|
+
# read in CSV with broken unicode from STDIN
|
31
|
+
# and scrub the broken bytes
|
32
|
+
cleaned_arrays = cleaned_file
|
33
|
+
# generate a new CSV without broken unicode
|
34
|
+
generate_scrubbed_csv(cleaned_arrays)
|
35
|
+
|
36
|
+
table = CSV.table("scrubbed-sample.csv")
|
37
|
+
|
38
|
+
# drop rows with unparseable DateTimes
|
39
|
+
drop_unparseable_time(table)
|
40
|
+
|
41
|
+
output = table.to_a.reject! { |row| row.blank? }
|
42
|
+
generate_scrubbed_csv(output)
|
43
|
+
end
|
44
|
+
|
45
|
+
def normalize
|
46
|
+
CSV.foreach("scrubbed-sample.csv", headers: true, encoding: "utf-8") do |row|
|
47
|
+
# convert PST to EST && format timestamps in iso8601
|
48
|
+
update_timezone(row, 'Pacific Time (US & Canada)', 'Eastern Time (US & Canada)')
|
49
|
+
|
50
|
+
# any zip codes with less than 5 digits, prepend 0's to them until they are 5 digits long
|
51
|
+
validate_zipcode(row['zip'])
|
52
|
+
# uppercase all names
|
53
|
+
upcase_fullname(row['fullname'])
|
54
|
+
|
55
|
+
# pass address column as is, validate everything is valid unicode
|
56
|
+
# else, replace with Unicode Replacement Character
|
57
|
+
validate_address(row['address'])
|
58
|
+
|
59
|
+
foo_duration_seconds = calculate_duration(row['fooduration'])
|
60
|
+
bar_duration_seconds = calculate_duration(row['barduration'])
|
61
|
+
|
62
|
+
calculate_total_duration(row, foo_duration_seconds, bar_duration_seconds)
|
63
|
+
|
64
|
+
unicode_notes_validation(row['notes'])
|
65
|
+
|
66
|
+
CSV.open('normalized_data.csv', 'a') do |csv|
|
67
|
+
csv << row.fields
|
68
|
+
end
|
69
|
+
end
|
70
|
+
File.open('normalized_data.csv').map { |row| puts row }
|
71
|
+
end
|
72
|
+
|
73
|
+
def truncate
|
74
|
+
File.truncate('normalized_data.csv', 0)
|
75
|
+
end
|
76
|
+
|
77
|
+
def generate_scrubbed_csv(arrays)
|
78
|
+
CSV.open("scrubbed-sample.csv", "w+") do |csv|
|
79
|
+
arrays.map { |ary| csv << ary }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def validate_args
|
84
|
+
if csv_file.split.length != 1
|
85
|
+
STDERR.puts "Warning: We need exactly one argument. Please try again with one command-line argument."
|
86
|
+
exit
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def cleaned_file
|
91
|
+
CSV.parse(File.read("#{csv_file}").scrub)
|
92
|
+
end
|
93
|
+
|
94
|
+
def unicode_notes_validation(notes)
|
95
|
+
notes = '' if notes.nil?
|
96
|
+
notes.encode('UTF-16', :undef => :replace, :invalid => :replace, :replace => '�').encode('UTF-8')
|
97
|
+
end
|
98
|
+
|
99
|
+
def upcase_fullname(fullname)
|
100
|
+
fullname.upcase!
|
101
|
+
end
|
102
|
+
|
103
|
+
def validate_zipcode(zipcode)
|
104
|
+
until zipcode.length == 5 do
|
105
|
+
zipcode.prepend('0')
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def format_timestamp(timestamp)
|
110
|
+
DateTime.strptime(timestamp, '%m/%d/%y %l:%M:%S %p')
|
111
|
+
end
|
112
|
+
|
113
|
+
def update_timezone(row, beginning_tz, result_tz)
|
114
|
+
Time.zone = beginning_tz
|
115
|
+
datetime = format_timestamp(row['timestamp']).in_time_zone(beginning_tz)
|
116
|
+
datetime_est = datetime.in_time_zone(result_tz)
|
117
|
+
formatted_datetime_est = format_datetime(datetime_est)
|
118
|
+
row['timestamp'] = formatted_datetime_est
|
119
|
+
end
|
120
|
+
|
121
|
+
def format_datetime(timestamp)
|
122
|
+
timestamp.iso8601
|
123
|
+
end
|
124
|
+
|
125
|
+
def calculate_total_duration(row, foo_duration_seconds, bar_duration_seconds)
|
126
|
+
row['totalduration'] = foo_duration_seconds + bar_duration_seconds
|
127
|
+
end
|
128
|
+
|
129
|
+
def calculate_duration(row)
|
130
|
+
duration_seconds = Time.strptime(row, '%H:%M:%S.%L').seconds_since_midnight.to_f
|
131
|
+
row = duration_seconds
|
132
|
+
end
|
133
|
+
|
134
|
+
def drop_unparseable_time(table)
|
135
|
+
table.each_with_index do |row, i|
|
136
|
+
begin
|
137
|
+
calculate_duration(row[:fooduration])
|
138
|
+
calculate_duration(row[:barduration])
|
139
|
+
format_timestamp(row[:timestamp])
|
140
|
+
rescue ArgumentError => e
|
141
|
+
STDERR.puts "Warning: Row #{i} will be deleted due to an unparseable Time.
|
142
|
+
The following row of data will be dropped:
|
143
|
+
'#{row}' "
|
144
|
+
end
|
145
|
+
table.by_row![i].delete_if { |_| e.present? }
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def validate_address(address)
|
150
|
+
address = '' if address.nil?
|
151
|
+
address.encode('UTF-16', :invalid => :replace, :replace => '�').encode('UTF-8')
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
data/lib/truss_parser.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Timestamp,Address,ZIP,FullName,FooDuration,BarDuration,TotalDuration,Notes
|
2
|
+
4/1/11 11:00:00 AM,"123 4th St, Anywhere, AA",94121,Monkey Alberto,1:23:32.123,1:32:33.123,zzsasdfa,I am the very model of a modern major general
|
3
|
+
3/12/14 12:00:00 AM,"Somewhere Else, In Another Time, BB",1,Superman übertan,111:23:32.123,1:32:33.123,zzsasdfa,This is some Unicode right h�xxx ü ¡! 😀
|
4
|
+
2/29/16 12:11:11 PM,111 Ste. #123123123,1101,Résumé Ron,31:23:32.123,1:32:33.123,zzsasdfa,🏳️🏴🏳️🏴
|
5
|
+
1/1/11 12:00:01 AM,"This Is Not An Address, BusyTown, BT",94121,Mary 1,1:23:32.123,0:00:00.000,zzsasdfa,I like Emoji! 🍏🍎😍
|
6
|
+
12/31/16 11:59:59 PM,"123 Gangnam Style Lives Here, Gangnam Town",31403,Anticipation of Unicode Failure,1:23:32.123,1:32:33.123,zzsasdfa,I like Math Symbols! ≱≰⨌⊚
|
7
|
+
11/11/11 11:11:11 AM,überTown,10001,Prompt Negotiator,1:23:32.123,1:32:33.123,zzsasdfa,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
|
8
|
+
5/12/10 4:48:12 PM,Høøük¡,1231,Sleeper Service,1:23:32.123,1:32:33.123,zzsasdfa,2/1/22
|
9
|
+
10/5/12 10:31:11 PM,"Test Pattern Town, Test Pattern, TP",121,株式会社スタジオジブリ,1:23:32.123,1:32:33.123,zzsasdfa,1:11:11.123
|
10
|
+
10/2/04 8:44:11 AM,The Moon,11,HERE WE GO,1:23:32.123,1:32:33.123,zzsasdfa,
|
data/sample.csv
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Timestamp,Address,ZIP,FullName,FooDuration,BarDuration,TotalDuration,Notes
|
2
|
+
4/1/11 11:00:00 AM,"123 4th St, Anywhere, AA",94121,Monkey Alberto,1:23:32.123,1:32:33.123,zzsasdfa,I am the very model of a modern major general
|
3
|
+
3/12/14 12:00:00 AM,"Somewhere Else, In Another Time, BB",1,Superman übertan,111:23:32.123,1:32:33.123,zzsasdfa,This is some Unicode right here. ü ¡! 😀
|
4
|
+
2/29/16 12:11:11 PM,111 Ste. #123123123,1101,Résumé Ron,31:23:32.123,1:32:33.123,zzsasdfa,🏳️🏴🏳️🏴
|
5
|
+
1/1/11 12:00:01 AM,"This Is Not An Address, BusyTown, BT",94121,Mary 1,1:23:32.123,0:00:00.000,zzsasdfa,I like Emoji! 🍏🍎😍
|
6
|
+
12/31/16 11:59:59 PM,"123 Gangnam Style Lives Here, Gangnam Town",31403,Anticipation of Unicode Failure,1:23:32.123,1:32:33.123,zzsasdfa,I like Math Symbols! ≱≰⨌⊚
|
7
|
+
11/11/11 11:11:11 AM,überTown,10001,Prompt Negotiator,1:23:32.123,1:32:33.123,zzsasdfa,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
|
8
|
+
5/12/10 4:48:12 PM,Høøük¡,1231,Sleeper Service,1:23:32.123,1:32:33.123,zzsasdfa,2/1/22
|
9
|
+
10/5/12 10:31:11 PM,"Test Pattern Town, Test Pattern, TP",121,株式会社スタジオジブリ,1:23:32.123,1:32:33.123,zzsasdfa,1:11:11.123
|
10
|
+
10/2/04 8:44:11 AM,The Moon,11,HERE WE GO,1:23:32.123,1:32:33.123,zzsasdfa,
|
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "truss_parser/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "truss_parser"
|
8
|
+
spec.version = TrussParser::VERSION
|
9
|
+
spec.authors = ["Patricia Arbona"]
|
10
|
+
spec.email = ["arbonap@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Parse and normalizes CSV files for Truss' take-home Software Engineer Challenge.}
|
13
|
+
spec.description = %q{Ingests, parses, and normalizes CSVs.}
|
14
|
+
spec.homepage = "https://www.github.com/arbonap/truss"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://www.github.com/arbonap/truss"
|
24
|
+
spec.metadata["changelog_uri"] = "https://www.github.com/arbonap/truss/changelog"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 1.17"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
42
|
+
spec.add_development_dependency "activesupport"
|
43
|
+
spec.add_development_dependency "byebug"
|
44
|
+
spec.add_development_dependency "artii"
|
45
|
+
spec.add_development_dependency "thor", "0.20.0"
|
46
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: truss_parser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Patricia Arbona
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-03-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.17'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.17'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: byebug
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: artii
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: thor
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.20.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.20.0
|
111
|
+
description: Ingests, parses, and normalizes CSVs.
|
112
|
+
email:
|
113
|
+
- arbonap@gmail.com
|
114
|
+
executables:
|
115
|
+
- truss_parser
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".travis.yml"
|
122
|
+
- CODE_OF_CONDUCT.md
|
123
|
+
- Gemfile
|
124
|
+
- Gemfile.lock
|
125
|
+
- LICENSE.txt
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/console
|
129
|
+
- bin/setup
|
130
|
+
- challenge.md
|
131
|
+
- exe/truss_parser
|
132
|
+
- lib/truss_parser.rb
|
133
|
+
- lib/truss_parser/cli.rb
|
134
|
+
- lib/truss_parser/parser.rb
|
135
|
+
- lib/truss_parser/version.rb
|
136
|
+
- sample-with-broken-utf8.csv
|
137
|
+
- sample.csv
|
138
|
+
- truss_parser.gemspec
|
139
|
+
homepage: https://www.github.com/arbonap/truss
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata:
|
143
|
+
allowed_push_host: https://rubygems.org
|
144
|
+
homepage_uri: https://www.github.com/arbonap/truss
|
145
|
+
source_code_uri: https://www.github.com/arbonap/truss
|
146
|
+
changelog_uri: https://www.github.com/arbonap/truss/changelog
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.6.14
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: Parse and normalizes CSV files for Truss' take-home Software Engineer Challenge.
|
167
|
+
test_files: []
|