disaster 0.1.0

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: f4034c7e92a41215ebf2e86873400f2ce4f31c2a10903aee56a9d1edd81dedd7
4
+ data.tar.gz: 01c360256c636bce6d9a8977658b1b2fe6ccd49c04e500e0fa8c03dbf332d658
5
+ SHA512:
6
+ metadata.gz: 89074dbc1b0f9ed42cb10ca039b1d5ca637eaee265b257362e36737c34fad364956f44b0a1b955f8cc707b3d858de4684c8259b049c21751f2615897dc56ee8f
7
+ data.tar.gz: 42e52a5acc1b2870fff33464f8592ae1a9c920ac738ba0104418ddd8190dff0dc16a6f4b6b9e60053930d46f8803cdaacab933747852f0f7bea4306e51389520
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-12-02
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at xorgnak@xorgnak.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in disaster.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/Gemfile.lock ADDED
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ disaster (0.1.0)
5
+ pry
6
+ unchanging
7
+ valkey-objects
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ coderay (1.1.3)
13
+ connection_pool (2.5.4)
14
+ json (2.16.0)
15
+ method_source (1.1.0)
16
+ net-http (0.6.0)
17
+ uri
18
+ pry (0.15.2)
19
+ coderay (~> 1.1)
20
+ method_source (~> 1.0)
21
+ rake (13.0.6)
22
+ redis (5.4.1)
23
+ redis-client (>= 0.22.0)
24
+ redis-client (0.25.1)
25
+ connection_pool
26
+ unchanging (0.1.0)
27
+ json
28
+ net-http
29
+ uri
30
+ uri (0.11.0)
31
+ valkey-objects (0.5.1)
32
+ redis
33
+
34
+ PLATFORMS
35
+ x86_64-linux
36
+
37
+ DEPENDENCIES
38
+ disaster!
39
+ rake (~> 13.0)
40
+
41
+ BUNDLED WITH
42
+ 2.3.15
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Erik Olson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # Disaster
2
+ Manage indexed records ith ease.
3
+
4
+ ## Installation
5
+ - bundle: `bundle add disaster`
6
+ - gem: `gem install disaster`
7
+
8
+ ## Usage
9
+ 1. create user
10
+ ```
11
+ Disaster.id.make "User Nickname", { ... Hash of User attributes ... }
12
+ ```
13
+
14
+ 2. add note
15
+ ```
16
+ Disaster["User Nickname"].add tag: ['Site Name', 'Department'], memo: "A note about a site.", img: "base64 image"
17
+ ```
18
+
19
+ 3. map notes
20
+ ```
21
+ Disaster["User Nickname"].map { |note| note }
22
+ ```
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Disaster
4
+ VERSION = "0.1.0"
5
+ end
data/lib/disaster.rb ADDED
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'unchanging'
4
+ require 'valkey/objects'
5
+
6
+ require_relative "disaster/version"
7
+
8
+ module Disaster
9
+ class Error < StandardError; end
10
+ # Your code goes here...
11
+
12
+ def self.get k
13
+ JSON.parse(Unchanging[k]).to_h
14
+ end
15
+
16
+ class U
17
+ include ValkeyObjects
18
+ # cid[user] = cid
19
+ hash_key :cid
20
+ # uid[asset] = user
21
+ hash_key :uid
22
+ # aid[user] = asset
23
+ hash_key :aid
24
+ def initialize
25
+ @id = 'USERS'
26
+ end
27
+ def [] k
28
+ Disaster.get(cid[k])
29
+ end
30
+ def make u, h={}
31
+ if !cid.has_key?(u)
32
+ t = Time.now
33
+ a = []; 10.times { a << rand(16).to_s(16) }
34
+ hh = { id: u, time: t.to_i, data: h }
35
+ cid[u] = Unchanging << JSON.generate(hh)
36
+ uid[a.join("")] = u
37
+ aid[u] = a.join("")
38
+ else
39
+ return false
40
+ end
41
+ end
42
+ end
43
+ ##
44
+ # ID object
45
+ # Disaster.id.make 'User Name', { ... attributes }
46
+ # Disaster.id['User Name'] => { ... user attributes }
47
+ # Disaster.id.aid['User Name'] => "asset ID"
48
+ # Disaster.id.uid["asset ID"] => 'User Name'
49
+ # Disaster.id.cid['User Name'] => "content ID"
50
+ def self.id
51
+ U.new
52
+ end
53
+
54
+ def self.all
55
+ Id.new("ALL")
56
+ end
57
+
58
+ # Disaster["ID"].add { tag: ["tag", ...] || "tag", memo: ["memo line", ...] || "memo string", img: "base 64 image" } => cid
59
+ # Disaster["ID"].map { |h| content Hash }
60
+ # Disaster["ID"].to_h
61
+ def self.[] k
62
+ Disaster.all.tag << k
63
+ Id.new(k)
64
+ end
65
+
66
+ class Id
67
+ include ValkeyObjects
68
+ set :tag
69
+ set :cid
70
+ hash_key :attr
71
+ sorted_set :stat
72
+ def initialize i
73
+ @id = i
74
+ end
75
+
76
+ ##
77
+ # map resounce CIDs
78
+ # @param [Block] cid handler
79
+ def map &b
80
+ cid.to_a.map { |e| b.call(Disaster.get(e)) }
81
+ end
82
+
83
+ ##
84
+ # add data to CID
85
+ # tag: string or array tag
86
+ # memo: string or array note
87
+ # img: base64 image
88
+ # @param [Hash] hash of data
89
+ # @return [String] content ID
90
+ def add h={}
91
+ t = Time.now
92
+ a = []
93
+ a << h[:tag]
94
+ a.flatten!
95
+ a.compact!
96
+ hh = { time: t.to_i, by: @id, tag: a, memo: [h[:memo] || 'tag'].flatten.compact.uniq.join("\n"), img: h[:img].to_s }
97
+ cid = Unchanging << JSON.generate(hh)
98
+ self.cid << cid
99
+ a.each { |e| Disaster.all.tag << e; Disaster[e].cid << cid }
100
+ return cid
101
+ end
102
+
103
+ ##
104
+ # resource to Hash
105
+ # @return [Hash] resource hash
106
+ def to_h
107
+ return {
108
+ tag: tag.members.to_a,
109
+ cid: cid.members.to_a,
110
+ attr: attr.to_h,
111
+ stat: stat.to_h
112
+ }
113
+ end
114
+ end
115
+ end
116
+
117
+
118
+ # Disaster.id.make "ID", { ... ID attributes }
119
+ # Disaster.id["ID"] => { ... ID attributes }
120
+ # Disaster["ID"].add { tag: ["tag", ...] || "tag", memo: ["memo line", ...] || "memo string", img: "base 64 image" } => cid
121
+ # Disaster["ID"].map { |h| content Hash }
122
+ # Disaster["ID"].to_h
data/sig/disaster.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Disaster
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: disaster
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Erik Olson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: unchanging
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: valkey-objects
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - xorgnak@xorgnak.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CHANGELOG.md
63
+ - CODE_OF_CONDUCT.md
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - lib/disaster.rb
70
+ - lib/disaster/version.rb
71
+ - sig/disaster.rbs
72
+ homepage: https://github.com/xorgnak/disaster
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 2.6.0
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.3.15
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: disaster proof interplanitary files.
95
+ test_files: []