activeyaml 0.1.1 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05b46532e76e8c768208126f531178f16b50f1adaa0adbc09eb1194aaafb7ccc
4
- data.tar.gz: '02019d5c54f428f18683ec8be883d1204f972e765704a6e7e3b43e158492572a'
3
+ metadata.gz: df6ab1743032b2da062676da7582cfdf5728d3cfdde22005f967daf48a4b2e68
4
+ data.tar.gz: dfae3e19537aaa71bb84ec9925a7b02eeff496c2d6a415198b9a26cfd16665c0
5
5
  SHA512:
6
- metadata.gz: fd3b5ce708a296948f33a69098544b857f0e61bfe84136566ef3aa7c197ca874fc47add9934057f51bfe5ae54ee8f99f1845bbbe2a1790f5c1acb3c03a895481
7
- data.tar.gz: ff652618b9b2aeaf9706443735513740d5414e8bd4b7009d170c48815821ea92818bc30636619b7d0d145f289f5eceb939bd0c4030c87142acbb7f69a817cd22
6
+ metadata.gz: 397f642b36da76e16faa2d3d033ae20394da142aa30d664ced8f1af54c9a168f1df83e7969295b9ab812e971406969f077ccd263b9f910801587f260dc7b3562
7
+ data.tar.gz: 3baea001da73ce93fdc6c180d6a47e3ad3bf15357e2424a2503661548fd431960e692da2f21c8b31f0a979512fcf3c525432530c5caf5c114e931bd54890b418
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveYaml
4
+ # base doc
5
+ class BaseObject
6
+ attr_reader :hash
7
+
8
+ def initialize(hash)
9
+ @hash = hash
10
+ end
11
+
12
+ def method_missing(method, *args, &block)
13
+ method_name = method.to_s
14
+ if hash.key?(method_name)
15
+ value = hash[method_name]
16
+ return BaseObject.new(value) if value.is_a?(Hash)
17
+
18
+ value
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ def respond_to_missing?(method, include_private = false)
25
+ @hash.key?(method.to_s) || super
26
+ end
27
+
28
+ def inspect
29
+ hash
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'base_object'
4
+
5
+ module ActiveYaml
6
+ # base mapper
7
+ class MethodMapper
8
+ def method_missing(method, *args, &block)
9
+ method_name = method.to_s
10
+ if yaml_data[method_name]
11
+ value = yaml_data[method_name]
12
+ return value unless value.is_a?(Hash)
13
+
14
+ BaseObject.new(value)
15
+ else
16
+ super
17
+ end
18
+ end
19
+
20
+ def respond_to_missing?(method, include_private = false)
21
+ yaml_data[method.to_s] || super
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'psych'
4
+
5
+ module ActiveYaml
6
+ # base parser
7
+ class Parser
8
+ def self.parse(file_path)
9
+ Psych.safe_load_file(file_path)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveYaml
4
+ VERSION = '0.1.5'
5
+ end
data/lib/active_yaml.rb CHANGED
@@ -1,8 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # main
4
- class ActiveYaml
5
- def self.hello
6
- 'hello'
3
+ require_relative 'active_yaml/parser'
4
+ require_relative 'active_yaml/method_mapper'
5
+
6
+ module ActiveYaml
7
+ # base
8
+ class Base < MethodMapper
9
+ def self.yaml(file_path)
10
+ define_method(:yaml_data) do
11
+ @yaml_data = Parser.parse(file_path)
12
+ end
13
+ end
7
14
  end
8
15
  end
metadata CHANGED
@@ -1,22 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeyaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Leonov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-30 00:00:00.000000000 Z
12
- dependencies: []
13
- description: activeyaml
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: psych
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.1'
27
+ description: framework for convenient and complete work with Yaml files
14
28
  email: leonov7632@gmail.com
15
29
  executables: []
16
30
  extensions: []
17
31
  extra_rdoc_files: []
18
32
  files:
19
33
  - lib/active_yaml.rb
34
+ - lib/active_yaml/base_object.rb
35
+ - lib/active_yaml/method_mapper.rb
36
+ - lib/active_yaml/parser.rb
37
+ - lib/active_yaml/version.rb
20
38
  homepage: https://github.com/leonovk/activeyaml
21
39
  licenses:
22
40
  - MIT
@@ -39,8 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
57
  - !ruby/object:Gem::Version
40
58
  version: '0'
41
59
  requirements: []
42
- rubygems_version: 3.4.22
60
+ rubygems_version: 3.4.10
43
61
  signing_key:
44
62
  specification_version: 4
45
- summary: activeyaml
63
+ summary: yaml object-relational mapping
46
64
  test_files: []