quandl_babelfish 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: a53ee0db1ee101721529efaabecca18f5afb20c3
4
- data.tar.gz: 955834a837b73a4154b8fff0510c7c6db6e9f98c
3
+ metadata.gz: 71a8ae07574d1b0763951541acf718b62c27110d
4
+ data.tar.gz: 1633fd8fc8d6f8a95bb3a08aa14d7e80a6fc9c6f
5
5
  SHA512:
6
- metadata.gz: 3a0a066227348ad185b74c653bcd89d2be752b74efb9724757e0d17d2928a9010866d64b078f5ff02143bf9dfc17c3c786bf4d76ade3f7930bcfd3423062baf8
7
- data.tar.gz: fbd1df51422791838162a0e43e562b9d0e9ca272d2af427eceb69d032dbd00d9f46b2f444c5ec5da1754eeef571485f2ddc0efdbc3484d2f5259cb8d1e866036
6
+ metadata.gz: a697bd2faf306f47e042b3d5a9cb765a9b4199a4cd7b38c11eb6fb2ec258323d53959f0886b6185a58a8ffaa53b8edc23cb9840ed16de108a846152012dfbedb
7
+ data.tar.gz: 6a96e6d3e9ba5151a853fe020c0d0fc9afceafd3b9e93c34299fc17adfe20026603bbcae1f8d9388d2a085237af404539ac30168a3400173986db064ad1a4724
data/UPGRADE.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.0.5
2
+
3
+ * improve error messages with line, row, context
4
+ * add Quandl::Error::Standard, all errors inherit from Error::Standard
5
+
6
+
1
7
  ## 0.0.4
2
8
 
3
9
  * remove quandl_data as a dependency
@@ -4,6 +4,7 @@ require "quandl/babelfish/cleaner"
4
4
  require "quandl/babelfish/date_maid"
5
5
  require "quandl/babelfish/number_maid"
6
6
 
7
+ require 'quandl/error/standard'
7
8
  require 'quandl/error/guess_date_format'
8
9
  require 'quandl/error/invalid_date'
9
10
  require 'quandl/error/unknown_date_format'
@@ -25,7 +25,7 @@ module Babelfish
25
25
  #find good example and extract all info from it and apply it to each of the dates in the set
26
26
  good_sample = find_good_date(all_dates)
27
27
 
28
- raise Error::GuessDateFormat.new("Unable to find date format for provide dates") if good_sample.nil?
28
+ raise( Error::GuessDateFormat.new, "Unable to find date format for provided dates" ) if good_sample.nil?
29
29
 
30
30
  date_format, frequency = analyze_date_format(good_sample)
31
31
 
@@ -35,8 +35,8 @@ module Babelfish
35
35
  end
36
36
 
37
37
  iso_dates=[]
38
- all_dates.each do |fuzzy_date|
39
- temp_date = convert(fuzzy_date, date_format) rescue raise(Error::InvalidDate,fuzzy_date)
38
+ all_dates.each_with_index do |fuzzy_date, i|
39
+ temp_date = convert(fuzzy_date, date_format) rescue raise( Error::InvalidDate.new( line: i+1, row: fuzzy_date, context: 'convert' ), "Invalid date '#{fuzzy_date}'" )
40
40
  iso_dates << frequency_transform(temp_date, frequency)
41
41
  end
42
42
 
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Babelfish
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
@@ -1,6 +1,5 @@
1
1
  module Quandl
2
2
  module Error
3
- class GuessDateFormat < StandardError
4
- end
3
+ class GuessDateFormat < Quandl::Error::Standard; end
5
4
  end
6
5
  end
@@ -1,6 +1,5 @@
1
1
  module Quandl
2
2
  module Error
3
- class InvalidDate < StandardError
4
- end
3
+ class InvalidDate < Quandl::Error::Standard; end
5
4
  end
6
5
  end
@@ -0,0 +1,27 @@
1
+ module Quandl
2
+ module Error
3
+ class Standard < StandardError
4
+
5
+ attr_accessor :details
6
+
7
+ def line
8
+ detail :line
9
+ end
10
+ def context
11
+ detail :context
12
+ end
13
+ def problem
14
+ detail :problem
15
+ end
16
+
17
+ def detail(key)
18
+ details.send(key) if details.respond_to?(key)
19
+ end
20
+
21
+ def initialize(opts=nil)
22
+ @details = OpenStruct.new( opts ) if opts && opts.is_a?(Hash)
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -1,6 +1,5 @@
1
1
  module Quandl
2
2
  module Error
3
- class UnknownDateFormat < StandardError
4
- end
3
+ class UnknownDateFormat < Quandl::Error::Standard; end
5
4
  end
6
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_babelfish
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
  - Sergei Ryshkevich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-09 00:00:00.000000000 Z
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -58,6 +58,7 @@ files:
58
58
  - lib/quandl/babelfish/version.rb
59
59
  - lib/quandl/error/guess_date_format.rb
60
60
  - lib/quandl/error/invalid_date.rb
61
+ - lib/quandl/error/standard.rb
61
62
  - lib/quandl/error/unknown_date_format.rb
62
63
  - quandl_babelfish.gemspec
63
64
  - spec/lib/quandl/babelfish/cleaner_spec.rb