quandl_format 0.0.1 → 0.0.2

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: 0a70e0e436b6880e25c8bfc3643d70b2440bd4d8
4
- data.tar.gz: e1fe743d521464cac0e2202e8c78ad1f2b09858f
3
+ metadata.gz: 88de117fd0aaa74d5aed80b7d34a77200409fa6e
4
+ data.tar.gz: 30fbd84655aedd481be97a672725aa173116bff9
5
5
  SHA512:
6
- metadata.gz: 4429a0b2cbd4c1a99c452182bbb621edb06029ceabdaa7188a3838efa0d4ba288a6ef3ffef3a11dcd20975a1365680285375ab4688b896728acef386924ee915
7
- data.tar.gz: 6c38e3a0d254ee664b5ea5d1c041d5c49a2642ad89ac3f223b727100113884f735233daa88abb66927e38289f7d3a1b7b2a14e1cbb8b82463374eab74ef7903a
6
+ metadata.gz: 9809fccf8d818791f6b000d44918a525836d32c3227f4156bd5f7fe098240e42e7179745ee78ffc411604f8164429760670e9da8e0f02e778d42c9a5e7f23b08
7
+ data.tar.gz: 0fc2a754ce3f08d0fd4b54066ab059623e53e3af8b112255188a42f60a54e3af0cfd00b613851a4d9902a91287129dde92dfe1320012d334bca9efa5210d0545
data/UPGRADE.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.0.2
2
+
3
+ * add support for meta attributes: private, display_url
4
+
5
+
1
6
  ## 0.0.1
2
7
 
3
8
  * init
@@ -3,8 +3,6 @@ module Format
3
3
 
4
4
  class Dump
5
5
 
6
- ATTRIBUTES = [ :source_code, :code, :name, :description, :private, :display_url ]
7
-
8
6
  class << self
9
7
 
10
8
  def nodes(*args)
@@ -24,24 +22,20 @@ class Dump
24
22
  end
25
23
 
26
24
  def to_qdf
27
- [ attributes,
28
- "-\n",
25
+ [
26
+ meta_attributes,
29
27
  column_names,
30
28
  data
31
29
  ].compact.join
32
30
  end
33
31
 
34
- def attributes
35
- attrs = ATTRIBUTES.inject({}) do |memo, name|
36
- name = name.to_s
37
- memo[name] = node.send(name) if node.respond_to?(name) && node.send(name).present?
38
- memo
39
- end
40
- attrs.to_yaml[4..-1]
32
+ def meta_attributes
33
+ node.meta_attributes.stringify_keys.to_yaml[4..-1] + "-\n"
41
34
  end
42
35
 
43
36
  def data
44
- data = node.data.is_a?(Array) ? node.data.collect(&:to_csv).join : node.data
37
+ data = node.data
38
+ data = data.collect(&:to_csv).join if data.is_a?(Array) && data.first.respond_to?(:to_csv)
45
39
  data = data.to_csv if data.respond_to?(:to_csv)
46
40
  data
47
41
  end
@@ -1,7 +1,25 @@
1
1
  class Quandl::Format::Node
2
2
 
3
- ATTRIBUTES = :source_code, :code, :name, :description, :column_names, :data
4
- attr_accessor *ATTRIBUTES
3
+ META_ATTRIBUTES = :source_code, :code, :name, :description, :private, :display_url
4
+ DATA_ATTRIBUTES = :column_names, :data
5
+
6
+ attr_accessor *( META_ATTRIBUTES + DATA_ATTRIBUTES )
7
+
8
+ class << self
9
+
10
+ def attribute_names
11
+ @attribute_names ||= meta_attribute_names + data_attribute_names
12
+ end
13
+
14
+ def meta_attribute_names
15
+ META_ATTRIBUTES
16
+ end
17
+
18
+ def data_attribute_names
19
+ DATA_ATTRIBUTES
20
+ end
21
+
22
+ end
5
23
 
6
24
  def initialize(attrs)
7
25
  assign_attributes(attrs)
@@ -13,14 +31,6 @@ class Quandl::Format::Node
13
31
  end
14
32
  end
15
33
 
16
- def attributes
17
- ATTRIBUTES.inject({}){|m,k| m[k] = self.send(k); m }
18
- end
19
-
20
- def inspect
21
- "<##{self.class.name} #{attributes.to_s} >"
22
- end
23
-
24
34
  def full_code=(value)
25
35
  value = value.split('/')
26
36
  self.source_code = value[0]
@@ -47,5 +57,17 @@ class Quandl::Format::Node
47
57
  def to_qdf
48
58
  Quandl::Format::Dump.node(self)
49
59
  end
60
+
61
+ def meta_attributes
62
+ self.class.meta_attribute_names.inject({}){|m,k| m[k] = self.send(k); m }
63
+ end
64
+
65
+ def attributes
66
+ self.class.attribute_names.inject({}){|m,k| m[k] = self.send(k); m }
67
+ end
68
+
69
+ def inspect
70
+ "<##{self.class.name} #{meta_attributes.to_s} >"
71
+ end
50
72
 
51
73
  end
@@ -1,5 +1,5 @@
1
1
  module Quandl
2
2
  module Format
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -9,6 +9,8 @@ describe Quandl::Format::Node do
9
9
  name: 'Test Dataset Name 2',
10
10
  description: "Here is a description with multiple lines.\n This is the second line.",
11
11
  column_names: ['Date', 'Value', 'High', 'Low'],
12
+ private: false,
13
+ display_url: 'http://test.com/',
12
14
  data: [["2013-11-20", "9.99470588235294", "11.003235294117646", "14.00164705882353"],
13
15
  ["2013-11-19", "10.039388096885814", nil, "14.09718770934256"]],
14
16
  }}
@@ -31,6 +33,8 @@ name: Test Dataset Name 2
31
33
  description: |-
32
34
  Here is a description with multiple lines.
33
35
  This is the second line.
36
+ private: false
37
+ display_url: http://test.com/
34
38
  -
35
39
  Date,Value,High,Low
36
40
  2013-11-20,9.99470588235294,11.003235294117646,14.00164705882353
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quandl_format
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher