quandl_data 1.3.5 → 1.3.6

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: ce1b13bea3abd317b83855932749d9b29836a838
4
- data.tar.gz: dedc1c64c0354e3a1042a7662e8896090b45421a
3
+ metadata.gz: b9dbde1852003bcb9959d2fa89a19cbc9820f96d
4
+ data.tar.gz: bfe0bf490f623cb12ec2cb0fa967e85a5a3dbe5d
5
5
  SHA512:
6
- metadata.gz: ea8568c09b7d551e35add9f272d7d48e7830b1ef2bda7aedbe54e76a4188dea0c939acf7862895e86a13a0b216b7fb757af993c0e5a72c8e45f1b9c155818cac
7
- data.tar.gz: 4199b62dc28313abd1204de393dccdaf1aa4ffafc3512b340a32526d2859882020c096059b3bb0c47e1e90f65f2c74a97a9cd4d863eacd3e23ad052f98364ed5
6
+ metadata.gz: 9d6a9e2268585f1ccf001cd14787d7fdf127822b458b03fa5132989337e0ca4aed5b3cf16e85dac2cfc28b44277e59c9ca67fc11dd84a712036d0791bdf49fa5
7
+ data.tar.gz: 4af620ee17de21560d716cccf78816c308530862065a16cd0cec5847d75b7a554ef1bc8e975ecd5dd047356c8375be199f3677ce968635a089a3d036e20ca78e
data/UPGRADE.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.3.6
2
+
3
+ * Add #guess_csv_delimiter to Data::Format.
4
+
5
+
1
6
  ## 1.3.5
2
7
 
3
8
  * add Validations, #valid? #errors
@@ -17,7 +17,7 @@ module Cleaning
17
17
  def ensure_data_is_cleaned
18
18
  data_array unless cleaned?
19
19
  end
20
-
20
+
21
21
  protected
22
22
 
23
23
  def clean(data)
@@ -29,6 +29,9 @@ module Cleaning
29
29
  data = ensure_data_is_an_array(data)
30
30
  # clean with either format or babelfish
31
31
  known_format?( data ) ? clean_with_format(data) : clean_with_babelfish(data)
32
+ # rescue clean_with_format failure and try with babelfish
33
+ # rescue
34
+ # clean_with_babelfish(data)
32
35
  end
33
36
 
34
37
  def ensure_data_requires_cleaning(data)
@@ -21,11 +21,19 @@ class Format
21
21
  def csv_to_array(data)
22
22
  if data.is_a?(String)
23
23
  data = data.gsub('\n', "\n")
24
- data = CSV.parse( data )
24
+ data = CSV.parse( data, {col_sep: guess_csv_delimiter(data) } )
25
25
  end
26
26
  data
27
27
  end
28
28
 
29
+ def guess_csv_delimiter(data)
30
+ data = data.to_s
31
+ line_end = data.to_s.index("\n")
32
+ first_line = line_end.nil? ? data : data[0..line_end].to_s
33
+ return "\t" unless first_line.index("\t").nil?
34
+ ","
35
+ end
36
+
29
37
  def to_date(data)
30
38
  return data if data_missing_rows?(data)
31
39
  # guess the current date format
@@ -10,20 +10,24 @@ module Validations
10
10
 
11
11
  included do
12
12
  ERROR_TYPES = [
13
- Error::GuessDateFormat, Error::InvalidDate,
13
+ Error::GuessDateFormat, Error::InvalidDate,
14
14
  Error::UnknownDateFormat, Error::DateParseError ]
15
15
  end
16
16
 
17
17
  def valid?
18
- self.errors = []
19
- self.data_array = pristine_data
20
- true
18
+ raise_error_unless_valid!
21
19
  rescue *ERROR_TYPES => error
22
20
  self.errors << error
23
21
  self.data_array = []
24
22
  false
25
23
  end
26
24
 
25
+ def raise_error_unless_valid!
26
+ self.errors = []
27
+ self.data_array = pristine_data
28
+ true
29
+ end
30
+
27
31
  def errors
28
32
  @errors ||= []
29
33
  end
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  class Data
3
- VERSION = "1.3.5"
3
+ VERSION = "1.3.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_data
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-10 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: quandl_operation