active_any 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/console +1 -1
- data/lib/active_any/base.rb +34 -2
- data/lib/active_any/relation.rb +1 -1
- data/lib/active_any/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 279b90c6e9b262972d592a694e11c2c4cdf647d3
|
4
|
+
data.tar.gz: 0354d6970255d9a02d01f55cb96f39908f0a36ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 593c783a30b4d63159dde062157b6c3fce66ab9f766c113c30c24eba4b35a7b9b90e75929a99a2ed57f91c7540b83dd9a7cf30ac87962eb5b767cd437b1504f2
|
7
|
+
data.tar.gz: 645c5cbdc4b3458f7df80dbef582d47d90523a0f707362c5110ee973f729c66fd8949731acdba30cab8a07b3e8821bf1608011b1f975d8c0256643fa3b337126
|
data/README.md
CHANGED
data/bin/console
CHANGED
data/lib/active_any/base.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'csv'
|
4
|
+
require 'pathname'
|
5
|
+
|
3
6
|
module ActiveAny
|
4
7
|
class Base
|
5
8
|
include Core
|
@@ -12,7 +15,7 @@ module ActiveAny
|
|
12
15
|
|
13
16
|
class Object < Base
|
14
17
|
def self.inherited(child)
|
15
|
-
child.abstract_class =
|
18
|
+
child.abstract_class = true
|
16
19
|
end
|
17
20
|
|
18
21
|
class << self
|
@@ -26,7 +29,7 @@ module ActiveAny
|
|
26
29
|
|
27
30
|
class Hash < Base
|
28
31
|
def self.inherited(child)
|
29
|
-
child.abstract_class =
|
32
|
+
child.abstract_class = true
|
30
33
|
end
|
31
34
|
|
32
35
|
class << self
|
@@ -45,4 +48,33 @@ module ActiveAny
|
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
51
|
+
|
52
|
+
class CSV < Base
|
53
|
+
def self.inherited(child)
|
54
|
+
child.abstract_class = true
|
55
|
+
end
|
56
|
+
|
57
|
+
class MissingFileError; end
|
58
|
+
|
59
|
+
class << self
|
60
|
+
attr_accessor :file
|
61
|
+
|
62
|
+
def data
|
63
|
+
@data ||= begin
|
64
|
+
raise MissingFileError unless file
|
65
|
+
|
66
|
+
table = ::CSV.table(file)
|
67
|
+
table.headers.each do |header|
|
68
|
+
attribute header
|
69
|
+
end
|
70
|
+
|
71
|
+
table.map { |row| new(row.to_h) }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def adapter
|
76
|
+
@adapter ||= ObjectAdapter.new(self)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
48
80
|
end
|
data/lib/active_any/relation.rb
CHANGED
data/lib/active_any/version.rb
CHANGED