activefolder 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_folder/metal/adapters/bare.rb +2 -0
- data/lib/active_folder/metal/errors.rb +1 -0
- data/lib/active_folder/metal/files/text.rb +29 -0
- data/lib/active_folder/model/traits/enumeration.rb +2 -2
- data/lib/active_folder/model/traits/has_belongs.rb +24 -3
- data/lib/active_folder/model/utilities/collection.rb +4 -5
- data/lib/active_folder/model/utilities/{matcher.rb → match.rb} +1 -1
- data/lib/active_folder/model/utilities/symbol.rb +13 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c797caee9bc346c2117c06b66e00541b7526c7a
|
4
|
+
data.tar.gz: 54c7374922603db20c35ac5e6212f5c55d446e60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ead8a1ac4b1b0c938e06432841dcdaf40db5112ccda118f1ee22009ff865a55b5ae45ba9eab2b69000d9fc11a415029114e4d1ca6771a93bb3a91e83d64d8bb1
|
7
|
+
data.tar.gz: 999b3312d5c2484c00c833e7ca14fedd6c332e05cf08f5bff6784fcd5cd31d1cae9187bfcbcf4e3350292346f2d2ffb80283e51459ab5f5de0b5824d95b09058
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ActiveFolder
|
2
|
+
module Metal
|
3
|
+
module Files
|
4
|
+
class Text
|
5
|
+
def initialize(dir:, name:)
|
6
|
+
@dir = dir; @name = name
|
7
|
+
end
|
8
|
+
|
9
|
+
def load
|
10
|
+
client.load(path: path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def save(content)
|
14
|
+
client.save(path: path, data: content.to_s)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def client
|
20
|
+
ActiveFolder.client
|
21
|
+
end
|
22
|
+
|
23
|
+
def path
|
24
|
+
File.join(@dir, @name)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'active_folder/model/utilities/
|
1
|
+
require 'active_folder/model/utilities/match'
|
2
2
|
|
3
3
|
module ActiveFolder
|
4
4
|
module Model
|
5
5
|
module Traits
|
6
6
|
module Enumeration
|
7
|
-
using Utilities::
|
7
|
+
using Utilities::Match
|
8
8
|
|
9
9
|
def find(name)
|
10
10
|
results = all(name)
|
@@ -1,24 +1,45 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
3
|
require 'active_folder/model/utilities/collection'
|
4
|
+
require 'active_folder/model/utilities/symbol'
|
5
|
+
require 'active_folder/metal/files/text'
|
4
6
|
|
5
7
|
module ActiveFolder
|
6
8
|
module Model
|
7
9
|
module Traits
|
8
10
|
module HasBelongs
|
11
|
+
using Utilities::Symbol
|
9
12
|
extend ActiveSupport::Concern
|
10
13
|
|
11
14
|
class_methods do
|
12
15
|
def has_many collection
|
13
16
|
define_method collection do
|
14
|
-
Utilities::Collection.new(self, collection
|
17
|
+
Utilities::Collection.new(self, collection)
|
15
18
|
end
|
16
19
|
end
|
17
20
|
|
18
21
|
def belongs_to element
|
19
22
|
define_method element do
|
20
|
-
|
21
|
-
|
23
|
+
element.to_class.current(self.path)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def has_one element
|
28
|
+
define_method :link_file do |name|
|
29
|
+
params = { dir: path, name: name.to_s }
|
30
|
+
Metal::Files::Text.new(**params)
|
31
|
+
end
|
32
|
+
|
33
|
+
define_method element do
|
34
|
+
begin
|
35
|
+
path = link_file(element).load
|
36
|
+
element.to_class.load(path)
|
37
|
+
rescue Metal::NotFoundError => _
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
define_method "#{element}=" do |value|
|
42
|
+
link_file(element).save(value.path)
|
22
43
|
end
|
23
44
|
end
|
24
45
|
|
@@ -1,20 +1,19 @@
|
|
1
1
|
require 'active_folder/model/traits/collection'
|
2
|
+
require 'active_folder/model/utilities/symbol'
|
2
3
|
|
3
4
|
module ActiveFolder
|
4
5
|
module Model
|
5
6
|
module Utilities
|
6
7
|
class Collection
|
8
|
+
using Utilities::Symbol
|
7
9
|
include Model::Traits::Collection
|
8
10
|
|
9
11
|
def initialize(owner, collection)
|
10
12
|
@owner = owner; @collection = collection
|
11
13
|
end
|
12
14
|
|
13
|
-
def model_class
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
def model_name; @collection end
|
15
|
+
def model_class; @collection.to_class end
|
16
|
+
def model_name; @collection.to_s end
|
18
17
|
def model_base_dir; @owner.path end
|
19
18
|
end
|
20
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activefolder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Thorner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- lib/active_folder/metal/config.rb
|
46
46
|
- lib/active_folder/metal/connections/bare.rb
|
47
47
|
- lib/active_folder/metal/errors.rb
|
48
|
+
- lib/active_folder/metal/files/text.rb
|
48
49
|
- lib/active_folder/metal/files/yaml.rb
|
49
50
|
- lib/active_folder/model/errors.rb
|
50
51
|
- lib/active_folder/model/traits/collection.rb
|
@@ -52,7 +53,8 @@ files:
|
|
52
53
|
- lib/active_folder/model/traits/has_belongs.rb
|
53
54
|
- lib/active_folder/model/traits/persistence.rb
|
54
55
|
- lib/active_folder/model/utilities/collection.rb
|
55
|
-
- lib/active_folder/model/utilities/
|
56
|
+
- lib/active_folder/model/utilities/match.rb
|
57
|
+
- lib/active_folder/model/utilities/symbol.rb
|
56
58
|
homepage: https://github.com/benthorner/active_folder
|
57
59
|
licenses:
|
58
60
|
- GNU GPL v2.0
|