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 +4 -4
- data/UPGRADE.md +6 -0
- data/lib/quandl/babelfish.rb +1 -0
- data/lib/quandl/babelfish/date_maid.rb +3 -3
- data/lib/quandl/babelfish/version.rb +1 -1
- data/lib/quandl/error/guess_date_format.rb +1 -2
- data/lib/quandl/error/invalid_date.rb +1 -2
- data/lib/quandl/error/standard.rb +27 -0
- data/lib/quandl/error/unknown_date_format.rb +1 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71a8ae07574d1b0763951541acf718b62c27110d
|
4
|
+
data.tar.gz: 1633fd8fc8d6f8a95bb3a08aa14d7e80a6fc9c6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a697bd2faf306f47e042b3d5a9cb765a9b4199a4cd7b38c11eb6fb2ec258323d53959f0886b6185a58a8ffaa53b8edc23cb9840ed16de108a846152012dfbedb
|
7
|
+
data.tar.gz: 6a96e6d3e9ba5151a853fe020c0d0fc9afceafd3b9e93c34299fc17adfe20026603bbcae1f8d9388d2a085237af404539ac30168a3400173986db064ad1a4724
|
data/UPGRADE.md
CHANGED
data/lib/quandl/babelfish.rb
CHANGED
@@ -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
|
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.
|
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
|
|
@@ -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
|
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
|
+
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-
|
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
|