truss_parser 0.1.0 → 0.1.1

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: ab21683914e06a2b107c982c980841853c598f42
4
- data.tar.gz: 996aad0ad7210cc0b0cd92b5d66b3ae15771e3c6
3
+ metadata.gz: 741e1cd26ecbea24962cdfa6a33f3648dd2a8ed0
4
+ data.tar.gz: 6af6e69c443d8fd61ef88fecc728a5ee68514cfb
5
5
  SHA512:
6
- metadata.gz: f345790b4bc5f6a3e1f5b26fbdbcd39635463d3ce07d43c2a635eb9dc9a84d2a93b8106968298eb7589cdf8c6be589553dbd91e3abefa71416ed897ae1529c84
7
- data.tar.gz: 440154587b48fc99ca3a419d9f223f3e9798a0bb28d0ce93feec9a00bd2bacf298121762fb3359da76fd08ac4004496bd584e09697b638f858d8419e19913359
6
+ metadata.gz: a7469ccf2351cebf6115b6089977cfc65e676470902b805549da4345ed09a5d1331585bb38e60d75fde9060b85c37cd6523c118378176f94177e25b05427d729
7
+ data.tar.gz: ff273c22994c7d99029422979a2a76d80b259f9e9c91d1fbd6e96a7821d6fa957e835fd5c127d6c85a5d2884710bc9db493fa702a1ae46df16d89131c7a538f4
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .byebug_history
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- truss_parser (0.1.0)
4
+ truss_parser (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,38 +1,27 @@
1
- # TrussParser
1
+ # Truss 🚀
2
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.
3
+ Welcome to TrussParser! This is a gem that parses and normalizes CSV data according to the specs in `challenge.md`
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
5
 
7
6
  ## Installation
8
7
 
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:
8
+ Assuming you have an environment set up for the Ruby ecosystem:
20
9
 
21
10
  $ gem install truss_parser
22
11
 
23
12
  ## Usage
24
13
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
14
+ - After `gem install`ing the `truss` gem:
15
+ - Run `truss_parser sample.csv` to parse and normalize the `sample.csv` that is shipped along in this gem. Alternatively, you can also run `truss_parser sample-with-broken-utf8.csv` as well. The Truss takes in a CSV file as an argument, and outputs normalized CSV data in `normalized_data.csv`.
16
+ - Example:
28
17
 
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.
18
+ ![Example of gem usage](truss_parser.gif)
30
19
 
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).
20
+ ## Testing
32
21
 
33
- ## Contributing
22
+ - Run `rake spec` to run the RSpec tests.
23
+ - You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
24
 
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
25
 
37
26
  ## License
38
27
 
@@ -40,4 +29,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
40
29
 
41
30
  ## Code of Conduct
42
31
 
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).
32
+ Everyone interacting in the Truss project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/arbonap/truss_parser/blob/master/CODE_OF_CONDUCT.md).
data/exe/truss_parser CHANGED
File without changes
@@ -4,10 +4,12 @@ require 'active_support/time_with_zone'
4
4
 
5
5
  module Parser
6
6
  class Normalization
7
- attr_accessor :csv_file
7
+ attr_accessor :csv_file, :scrubbed_csv, :normalized_data
8
8
 
9
- def initialize(argv)
9
+ def initialize(argv, normalized_data="normalized_data.csv", scrubbed_csv="scrubbed-sample.csv")
10
10
  @csv_file = argv[0]
11
+ @normalized_data = normalized_data
12
+ @scrubbed_csv = scrubbed_csv
11
13
  end
12
14
 
13
15
  def self.ascii
@@ -43,7 +45,7 @@ module Parser
43
45
  end
44
46
 
45
47
  def normalize
46
- CSV.foreach("scrubbed-sample.csv", headers: true, encoding: "utf-8") do |row|
48
+ CSV.foreach("#{scrubbed_csv}", headers: true, encoding: "utf-8") do |row|
47
49
  # convert PST to EST && format timestamps in iso8601
48
50
  update_timezone(row, 'Pacific Time (US & Canada)', 'Eastern Time (US & Canada)')
49
51
 
@@ -63,15 +65,15 @@ module Parser
63
65
 
64
66
  unicode_notes_validation(row['notes'])
65
67
 
66
- CSV.open('normalized_data.csv', 'a') do |csv|
68
+ CSV.open("#{normalized_data}", 'a') do |csv|
67
69
  csv << row.fields
68
70
  end
69
71
  end
70
- File.open('normalized_data.csv').map { |row| puts row }
72
+ File.open("#{normalized_data}").map { |row| puts row if ENV['GEM_ENV'] != 'TEST' }
71
73
  end
72
74
 
73
75
  def truncate
74
- File.truncate('normalized_data.csv', 0)
76
+ File.truncate("#{normalized_data}", 0)
75
77
  end
76
78
 
77
79
  def generate_scrubbed_csv(arrays)
@@ -1,3 +1,3 @@
1
1
  module TrussParser
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,7 @@
1
+ 2011-04-01T07:00:00-04:00,"123 4th St, Anywhere, AA",94121,MONKEY ALBERTO,1:23:32.123,1:32:33.123,10565.246,I am the very model of a modern major general
2
+ 2010-12-31T19:00:01-05:00,"This Is Not An Address, BusyTown, BT",94121,MARY 1,1:23:32.123,0:00:00.000,5012.123,I like Emoji! 🍏🍎😍
3
+ 2016-12-31T18:59:59-05:00,"123 Gangnam Style Lives Here, Gangnam Town",31403,ANTICIPATION OF UNICODE FAILURE,1:23:32.123,1:32:33.123,10565.246,I like Math Symbols! ≱≰⨌⊚
4
+ 2011-11-11T06:11:11-05:00,überTown,10001,PROMPT NEGOTIATOR,1:23:32.123,1:32:33.123,10565.246,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
5
+ 2010-05-12T12:48:12-04:00,Høøük¡,01231,SLEEPER SERVICE,1:23:32.123,1:32:33.123,10565.246,2/1/22
6
+ 2012-10-05T18:31:11-04:00,"Test Pattern Town, Test Pattern, TP",00121,株式会社スタジオジブリ,1:23:32.123,1:32:33.123,10565.246,1:11:11.123
7
+ 2004-10-02T04:44:11-04:00,The Moon,00011,HERE WE GO,1:23:32.123,1:32:33.123,10565.246,
@@ -0,0 +1,7 @@
1
+ 2011-04-01T07:00:00-04:00,"123 4th St, Anywhere, AA",94121,MONKEY ALBERTO,1:23:32.123,1:32:33.123,10565.246,I am the very model of a modern major general
2
+ 2010-12-31T19:00:01-05:00,"This Is Not An Address, BusyTown, BT",94121,MARY 1,1:23:32.123,0:00:00.000,5012.123,I like Emoji! 🍏🍎😍
3
+ 2016-12-31T18:59:59-05:00,"123 Gangnam Style Lives Here, Gangnam Town",31403,ANTICIPATION OF UNICODE FAILURE,1:23:32.123,1:32:33.123,10565.246,I like Math Symbols! ≱≰⨌⊚
4
+ 2011-11-11T06:11:11-05:00,überTown,10001,PROMPT NEGOTIATOR,1:23:32.123,1:32:33.123,10565.246,"I’m just gonna say, this is AMAZING. WHAT NEGOTIATIONS."
5
+ 2010-05-12T12:48:12-04:00,Høøük¡,01231,SLEEPER SERVICE,1:23:32.123,1:32:33.123,10565.246,2/1/22
6
+ 2012-10-05T18:31:11-04:00,"Test Pattern Town, Test Pattern, TP",00121,株式会社スタジオジブリ,1:23:32.123,1:32:33.123,10565.246,1:11:11.123
7
+ 2004-10-02T04:44:11-04:00,The Moon,00011,HERE WE GO,1:23:32.123,1:32:33.123,10565.246,
@@ -0,0 +1,8 @@
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
+ 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! 🍏🍎😍
4
+ 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! ≱≰⨌⊚
5
+ 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."
6
+ 5/12/10 4:48:12 PM,Høøük¡,1231,Sleeper Service,1:23:32.123,1:32:33.123,zzsasdfa,2/1/22
7
+ 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
8
+ 10/2/04 8:44:11 AM,The Moon,11,HERE WE GO,1:23:32.123,1:32:33.123,zzsasdfa,
data/truss_parser.gif ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truss_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patricia Arbona
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-11 00:00:00.000000000 Z
11
+ date: 2019-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -133,9 +133,13 @@ files:
133
133
  - lib/truss_parser/cli.rb
134
134
  - lib/truss_parser/parser.rb
135
135
  - lib/truss_parser/version.rb
136
+ - normalized_data.csv
137
+ - normalized_test_data.csv
136
138
  - sample-with-broken-utf8.csv
137
139
  - sample.csv
140
+ - scrubbed-sample.csv
138
141
  - truss_parser.gemspec
142
+ - truss_parser.gif
139
143
  homepage: https://www.github.com/arbonap/truss
140
144
  licenses:
141
145
  - MIT