hakoy 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e927f2f407fa31512d3db7a44f32ad8077d965dd
4
- data.tar.gz: e9aba5c6ead90290ae341ccc5742053e038b7a0f
3
+ metadata.gz: 66093068425641161df6e63fe52508d892ee9459
4
+ data.tar.gz: fd91e5eae9c6b73574ea3d01ac4a509c920f8e4b
5
5
  SHA512:
6
- metadata.gz: f74bc3f20e55b4baa4bacf964658056dfd5fcf6737f284721debe98cdf171bf746815ef3a2827fdc041b9e92de3bf1286115ae827debacd8afacd09fd6834714
7
- data.tar.gz: d4c960548a81b20d75197b8f40e142ea22ae130150fd86d47ef4a4d5c48fc7bf30958fa1993e041f57b1c7979880576c924da01aa1e5474bfe3415b8628aad9b
6
+ metadata.gz: 18e01860c8cf776f4318b66daf891ac552bd11dae05dc73375b7448f77fbe76b61d59769b6937276c4d2a3f66b511d724087ebe9dafa364880b9a048e4b0c025
7
+ data.tar.gz: 3347a8a35c6209485eda48b46542d034b0b1b25c6335207c10f854ad532e33ecfb1dbed14f2eaef42635f6468083801e80abab143e54b93e41668c0f336f8184
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "chronic", "~> 0.10.2"
21
22
  spec.add_development_dependency "bundler", "~> 1.6"
22
23
  spec.add_development_dependency "rake"
23
24
  spec.add_development_dependency "rspec", "~> 2.14.1"
@@ -1,5 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'csv'
3
+ require 'chronic'
3
4
 
4
5
  require_relative "hakoy/version"
5
6
  require_relative "hakoy/ext/hash"
@@ -7,6 +8,7 @@ require_relative "hakoy/ext/array"
7
8
  require_relative "hakoy/append_strategy"
8
9
  require_relative "hakoy/file_iterator"
9
10
  require_relative "hakoy/timestamp_path"
11
+ require_relative "hakoy/timestamp_normalizer"
10
12
  require_relative "hakoy/row_normalizer"
11
13
  require_relative "hakoy/file_appender"
12
14
 
@@ -31,6 +33,9 @@ module Hakoy
31
33
  @row_normalizer = RowNormalizer.new(
32
34
  required_keys: @required_keys_mapping.values, uid_key: @uid_key
33
35
  )
36
+ @timestamp_normalizer = TimestampNormalizer.new(
37
+ key: @timestamp_key
38
+ )
34
39
  end
35
40
 
36
41
  def store(file)
@@ -41,8 +46,9 @@ module Hakoy
41
46
  private
42
47
 
43
48
  def store_row(row_hash)
44
- file_path = build_file_path(row_hash)
45
- normalized_row_hash = normalize_row_hash(row_hash)
49
+ row_hash = normalize_timestamp(row_hash)
50
+ file_path = build_file_path(row_hash)
51
+ normalized_row_hash = normalize_row_hash(row_hash)
46
52
 
47
53
  append_row_to_file(file_path, normalized_row_hash)
48
54
  end
@@ -57,6 +63,10 @@ module Hakoy
57
63
  @row_normalizer.normalize(row_hash)
58
64
  end
59
65
 
66
+ def normalize_timestamp(row_hash)
67
+ @timestamp_normalizer.(row_hash)
68
+ end
69
+
60
70
  def append_row_to_file(file_path, row_hash)
61
71
  @append_strategy.append_row_to_file file_path, row_hash
62
72
  end
@@ -0,0 +1,14 @@
1
+ module Hakoy
2
+ class TimestampNormalizer
3
+ attr_reader :key
4
+
5
+ def initialize(opts)
6
+ @key = opts.fetch(:key)
7
+ end
8
+
9
+ def call(hash)
10
+ hash[key] = Chronic.parse(hash[key]).to_s
11
+ hash
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Hakoy
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -2,5 +2,5 @@ Name,Email,Financial Status,Paid at,Fulfillment Status,Fulfilled at,Accepts Mark
2
2
  #1002,he9lin@gmail.com,authorized,,pending,,yes,USD,19.99,10.00,0.00,29.99,"",0.00,Standard Shipping,2014-05-28 11:49:25 -0400,1,Product D,19.99,"","",true,true,pending,Lin He,1155 W. Newmark ave.,1155 W. Newmark ave.,"",Heyook,Monterey Park,"=""91754""",CA,US,6267314363,Lin He,1155 W. Newmark ave.,1155 W. Newmark ave.,"",Heyook,Monterey Park,"=""91754""",CA,US,6267314363,"","",,(for testing) Bogus Gateway,c240759183.1,0.00,Smart Store,258641987,""
3
3
  #1002,he9lin@gmail.com,"","","","","","","","","","","","","",2014-05-28 11:49:25 -0400,1,Product B,0.00,"","",true,true,pending,"","","","","","","","","","","","","","","","","","","","","","","","","","",Smart Store,"",""
4
4
  #1002,he9lin@gmail.com,"","","","","","","","","","","","","",2014-05-28 11:49:25 -0400,2,Product C,0.00,"","",true,true,pending,"","","","","","","","","","","","","","","","","","","","","","","","","","",Smart Store,"",""
5
- #1001,he9lin@gmail.com,authorized,,pending,,yes,USD,0.00,10.00,0.00,10.00,"",0.00,Standard Shipping,2014-05-26 15:27:46 -0400,1,Product B,0.00,"","",true,true,pending,Lin He,1155 W. Newmark ave.,1155 W. Newmark ave.,"",Heyook,Monterey Park,"=""91754""",CA,US,6267314363,Lin He,1155 W. Newmark ave.,1155 W. Newmark ave.,"",Heyook,Monterey Park,"=""91754""",CA,US,6267314363,"","",,(for testing) Bogus Gateway,c240695859.1,0.00,Smart Store,258460403,""
5
+ #1001,he9lin@gmail.com,authorized,,pending,,yes,USD,0.00,10.00,0.00,10.00,"",0.00,Standard Shipping,2014/05/26 15:27:46 -0400,1,Product B,0.00,"","",true,true,pending,Lin He,1155 W. Newmark ave.,1155 W. Newmark ave.,"",Heyook,Monterey Park,"=""91754""",CA,US,6267314363,Lin He,1155 W. Newmark ave.,1155 W. Newmark ave.,"",Heyook,Monterey Park,"=""91754""",CA,US,6267314363,"","",,(for testing) Bogus Gateway,c240695859.1,0.00,Smart Store,258460403,""
6
6
  #1001,he9lin@gmail.com,"","","","","","","","","","","","","",2014-05-26 15:27:46 -0400,2,Product C,0.00,"","",true,true,pending,"","","","","","","","","","","","","","","","","","","","","","","","","","",Smart Store,"",""
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hakoy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lin He
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-01 00:00:00.000000000 Z
11
+ date: 2014-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chronic
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.2
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -92,6 +106,7 @@ files:
92
106
  - lib/hakoy/file_iterator.rb
93
107
  - lib/hakoy/file_iterator/csv.rb
94
108
  - lib/hakoy/row_normalizer.rb
109
+ - lib/hakoy/timestamp_normalizer.rb
95
110
  - lib/hakoy/timestamp_path.rb
96
111
  - lib/hakoy/version.rb
97
112
  - spec/fixtures/order.json