yarii-content-model 0.1.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1077ab034fdf4c9d1bb0e81e441034573a48fa2c1c1907dfcc23123db48375f2
4
+ data.tar.gz: 61203f7d66445dda0765b88b23c370bd839749f60ae0037d2da8527604527102
5
+ SHA512:
6
+ metadata.gz: 4dacb9420563487b2fbe64ec773c9bddbf6c63f63063b29a3e91ca01b3ce4df10b8773fe59d19a056f938c0b242d6cfcac703fe989a530357436256c23897ade
7
+ data.tar.gz: 6b2f4a08a63c756d68d6b929e237ff38413b1bcaa6dd15045870346458a57b509dbbf703d6b4d330efec497a15928a979914ddb4c70575d9f094dd2c21429b3c
@@ -0,0 +1,69 @@
1
+ require 'active_model'
2
+
3
+ module Yarii
4
+ module Serializers
5
+ # == Active Model YAML Serializer
6
+ module YAML
7
+ extend ActiveSupport::Concern
8
+ include ActiveModel::Serialization
9
+
10
+ included do
11
+ extend ActiveModel::Naming
12
+
13
+ class_attribute :include_root_in_json
14
+ self.include_root_in_json = false
15
+ end
16
+
17
+ module ClassMethods
18
+ def new_from_yaml(yml)
19
+ new.from_yaml(yml)
20
+ end
21
+ end
22
+
23
+ # Same thing as as_json, but returns yaml instead of a hash (unless you include the as_hash:true option)
24
+ def as_yaml(options = {})
25
+ as_hash = options.delete(:as_hash)
26
+ hash = serializable_hash(options)
27
+
28
+ # we don't like DateTime in YML. Needs to be just Time.
29
+ hash.each do |k,v|
30
+ if v.nil?
31
+ # we don't want to save nil values as empty front matter variables
32
+ hash.delete(k)
33
+ elsif v.is_a?(DateTime)
34
+ hash[k] = v.to_time
35
+ end
36
+ end
37
+
38
+ if include_root_in_json
39
+ custom_root = options && options[:root]
40
+ hash = { custom_root || self.class.model_name.element => hash }
41
+ end
42
+
43
+ as_hash ? hash : hash.to_yaml
44
+ end
45
+
46
+ def from_yaml(yaml)
47
+ hash = SafeYAML.load(yaml)
48
+ hash = hash.values.first if include_root_in_json
49
+ self.assign_attributes(hash)
50
+ self
51
+ end
52
+ end
53
+ end
54
+
55
+ module VariableDefinitions
56
+ def variables(*names_arr)
57
+ self.variable_names = names_arr
58
+ names_arr.each do |var_name|
59
+ attr_accessor var_name
60
+ end
61
+ end
62
+ end
63
+
64
+ module FilePathDefinitions
65
+ def folder(path)
66
+ self.folder_path = path
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :yarii_core do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require "yarii-content-model/engine"
2
+ require "content_model_mixins"
3
+
4
+ module YariiContentModel
5
+ end
6
+
7
+ module Yarii
8
+ end
@@ -0,0 +1,4 @@
1
+ module YariiContentModel
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module YariiContentModel
2
+ VERSION = '0.1.1'
3
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yarii-content-model
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Jared White
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-04-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '5.0'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: safe_yaml
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: key_path
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.2'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.2'
61
+ - !ruby/object:Gem::Dependency
62
+ name: git
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '1.3'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.3'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec-rails
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '='
80
+ - !ruby/object:Gem::Version
81
+ version: 3.8.2
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '='
87
+ - !ruby/object:Gem::Version
88
+ version: 3.8.2
89
+ description: Provides an ActiveRecord-like method of loading and saving static content
90
+ files (from Bridgetown, Jekyll, etc.)
91
+ email:
92
+ - jared@jaredwhite.com
93
+ executables: []
94
+ extensions: []
95
+ extra_rdoc_files: []
96
+ files:
97
+ - lib/content_model_mixins.rb
98
+ - lib/tasks/yarii_content_model_tasks.rake
99
+ - lib/yarii-content-model.rb
100
+ - lib/yarii-content-model/engine.rb
101
+ - lib/yarii-content-model/version.rb
102
+ homepage: https://whitefusion.io
103
+ licenses:
104
+ - MIT
105
+ metadata: {}
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: '0'
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubygems_version: 3.0.8
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Provides an ActiveRecord-like method of loading and saving static content
125
+ files (from Bridgetown, Jekyll, etc.)
126
+ test_files: []