navigable 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aca138d67f81a26946235aefdf41f6a884de776c8be86282ebab418cf6e56a01
4
+ data.tar.gz: f5f7333fd1a531cad78a07d989deaf57be2b0064dc8e9a3a6439c11aad9e8c55
5
+ SHA512:
6
+ metadata.gz: e9560be4d3e344bd30e852a7b95dc0c3b2ae1e277fc1da86a6179148ddcf7888416816732afd6c48e38b9b37c79e32d633b0759b83d23340e6dcaf07260d1d10
7
+ data.tar.gz: bbfd09d0c17a7c45991c8fabe48055c3402f04b78efd723429b1d9d17a55b23de07ad68ed2bfeacedd80196314a6d3db363dde7e7fc594936884b3c54c474a1d
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.vscode/
3
+ /.yardoc
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ .DS_Store
12
+
13
+ # rspec failure tracking
14
+ .rspec_status
15
+
16
+ Gemfile.lock
17
+
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format progress
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ 2.7.1
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.0
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at alan@ridlehoover.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in navigable.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Alan Ridlehoover
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.
@@ -0,0 +1,37 @@
1
+ <img src="assets/navigable.png">
2
+
3
+ # Navigable
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'navigable'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install navigable
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/first-try-software/navigable.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
34
+
35
+ ## Code of Conduct
36
+
37
+ Everyone interacting in the Navigable project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/first-try-software/navigable/blob/main/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
Binary file
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "navigable"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ # frozen-string-literal: true
2
+
3
+ require 'manufacturable'
4
+
5
+ require 'navigable/version'
6
+ require 'navigable/command'
7
+ require 'navigable/dispatcher'
@@ -0,0 +1,35 @@
1
+ # frozen-string-literal: true
2
+
3
+ require 'navigable/observable'
4
+
5
+ module Navigable
6
+ module Command
7
+ TYPE = :__command__
8
+ EXECUTE_NOT_IMPLEMENTED_MESSAGE = 'Class must implement `execute` method.'
9
+
10
+ def self.extended(base)
11
+ base.extend(Manufacturable::Item)
12
+ base.include(Observable)
13
+
14
+ base.instance_eval do
15
+ def corresponds_to(key)
16
+ super(key, TYPE)
17
+ end
18
+ end
19
+
20
+ base.class_eval do
21
+ attr_reader :params, :observers
22
+
23
+ def initialize(params: {}, observers: [])
24
+ @params = params
25
+ @observers = observers
26
+ end
27
+
28
+ def execute
29
+ raise NotImplementedError.new(EXECUTE_NOT_IMPLEMENTED_MESSAGE)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+
@@ -0,0 +1,35 @@
1
+ # frozen-string-literal: true
2
+
3
+ require 'navigable/null_resolver'
4
+ require 'navigable/observer'
5
+ require 'navigable/command'
6
+
7
+ module Navigable
8
+ class Dispatcher
9
+ def self.dispatch(key, params: {}, resolver: NullResolver.new)
10
+ self.new(key, params: params, resolver: resolver).dispatch
11
+ end
12
+
13
+ def dispatch
14
+ command.execute
15
+ resolver.resolve
16
+ end
17
+
18
+ attr_reader :key, :params, :resolver
19
+ private :key, :params, :resolver
20
+
21
+ private
22
+
23
+ def initialize(key, params:, resolver:)
24
+ @key, @params, @resolver = key, params, resolver
25
+ end
26
+
27
+ def observers
28
+ Manufacturable.build_all(Observer::TYPE, key).push(resolver)
29
+ end
30
+
31
+ def command
32
+ Manufacturable.build_one(Command::TYPE, key, params: params, observers: observers)
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,11 @@
1
+ # frozen-string-literal: true
2
+
3
+ require 'navigable/resolver'
4
+
5
+ module Navigable
6
+ class NullResolver
7
+ extend Resolver
8
+
9
+ def resolve; end
10
+ end
11
+ end
@@ -0,0 +1,39 @@
1
+ # frozen-string-literal: true
2
+
3
+ module Navigable
4
+ module Observable
5
+ OBSERVERS_NOT_IMPLEMENTED_MESSAGE = 'Class must implement `observers` method.'
6
+
7
+ def observers
8
+ raise NotImplementedError.new(OBSERVERS_NOT_IMPLEMENTED_MESSAGE)
9
+ end
10
+
11
+ def successfully(*args)
12
+ observers.each { |observer| observer.on_success(*args) }
13
+ end
14
+
15
+ def failed_to_validate(*args)
16
+ observers.each { |observer| observer.on_failure_to_validate(*args) }
17
+ end
18
+
19
+ def failed_to_find(*args)
20
+ observers.each { |observer| observer.on_failure_to_find(*args) }
21
+ end
22
+
23
+ def failed_to_create(*args)
24
+ observers.each { |observer| observer.on_failure_to_create(*args) }
25
+ end
26
+
27
+ def failed_to_update(*args)
28
+ observers.each { |observer| observer.on_failure_to_update(*args) }
29
+ end
30
+
31
+ def failed_to_delete(*args)
32
+ observers.each { |observer| observer.on_failure_to_delete(*args) }
33
+ end
34
+
35
+ def failed(*args)
36
+ observers.each { |observer| observer.on_failure(*args) }
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,22 @@
1
+ # frozen-string-literal: true
2
+
3
+ require 'navigable/observer_interface'
4
+
5
+ module Navigable
6
+ module Observer
7
+ TYPE = :__observer__
8
+
9
+ def self.extended(base)
10
+ base.extend(Manufacturable::Item)
11
+ base.include(ObserverInterface)
12
+ end
13
+
14
+ def observes_all_commands
15
+ corresponds_to_all(TYPE)
16
+ end
17
+
18
+ def observes(key)
19
+ corresponds_to(key, TYPE)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,13 @@
1
+ # frozen-string-literal: true
2
+
3
+ module Navigable
4
+ module ObserverInterface
5
+ def on_success(*args); end
6
+ def on_failure_to_validate(*args); end
7
+ def on_failure_to_find(*args); end
8
+ def on_failure_to_create(*args); end
9
+ def on_failure_to_update(*args); end
10
+ def on_failure_to_delete(*args); end
11
+ def on_failure(*args); end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ # frozen-string-literal: true
2
+
3
+ require 'navigable/observer_interface'
4
+
5
+ module Navigable
6
+ module Resolver
7
+ RESOLVE_NOT_IMPLEMENTED_MESSAGE = 'Class must implement `resolve` method.'
8
+
9
+ def self.extended(base)
10
+ base.include(ObserverInterface)
11
+ base.class_eval do
12
+ def resolve
13
+ raise NotImplementedError.new(RESOLVE_NOT_IMPLEMENTED_MESSAGE)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ # frozen-string-literal: true
2
+
3
+ module Navigable
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,34 @@
1
+ require_relative "lib/navigable/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "navigable"
5
+ spec.version = Navigable::VERSION
6
+ spec.platform = Gem::Platform::RUBY
7
+ spec.authors = ["Alan Ridlehoover", "Fito von Zastrow"]
8
+ spec.email = ["alan@ridlehoover.com", "adolfovon@gmail.com"]
9
+
10
+ spec.summary = %q{Ahoy! Navigable will get you there!}
11
+ spec.description = %q{We hold these truths to be self-evident, that not all objects are created equal, that poorly structured code leads to poorly tested code, and that poorly tested code leads to rigid software and fearful engineers.\n\nWe believe a framework should break free of this tyranny. It should be simple, testable, and fast. It can be opinionated. But, it should leverage SOLID principles to guide us toward well structured, well tested, maleable code that is truly navigable.}
12
+ spec.homepage = "https://github.com/first_try/navigable"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/first_try/navigable"
18
+ spec.metadata["bug_tracker_uri"] = "https://github.com/first_try/navigable/issues"
19
+
20
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib", "assets"]
26
+
27
+ spec.add_dependency "manufacturable", "~> 1.3"
28
+
29
+ spec.add_development_dependency "bundler", "~> 2.0"
30
+ spec.add_development_dependency "rake", "~> 12.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "rspec_junit_formatter", "~>0.4"
33
+ spec.add_development_dependency "simplecov", "~>0.16"
34
+ end
metadata ADDED
@@ -0,0 +1,161 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: navigable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alan Ridlehoover
8
+ - Fito von Zastrow
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2020-08-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: manufacturable
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '2.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '2.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '12.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '12.0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '3.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec_junit_formatter
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.4'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '0.4'
84
+ - !ruby/object:Gem::Dependency
85
+ name: simplecov
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '0.16'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '0.16'
98
+ description: We hold these truths to be self-evident, that not all objects are created
99
+ equal, that poorly structured code leads to poorly tested code, and that poorly
100
+ tested code leads to rigid software and fearful engineers.\n\nWe believe a framework
101
+ should break free of this tyranny. It should be simple, testable, and fast. It can
102
+ be opinionated. But, it should leverage SOLID principles to guide us toward well
103
+ structured, well tested, maleable code that is truly navigable.
104
+ email:
105
+ - alan@ridlehoover.com
106
+ - adolfovon@gmail.com
107
+ executables: []
108
+ extensions: []
109
+ extra_rdoc_files: []
110
+ files:
111
+ - ".gitignore"
112
+ - ".rspec"
113
+ - ".ruby-version"
114
+ - ".travis.yml"
115
+ - CODE_OF_CONDUCT.md
116
+ - Gemfile
117
+ - Gemfile.lock
118
+ - LICENSE.txt
119
+ - README.md
120
+ - Rakefile
121
+ - assets/navigable.png
122
+ - bin/console
123
+ - bin/setup
124
+ - lib/navigable.rb
125
+ - lib/navigable/command.rb
126
+ - lib/navigable/dispatcher.rb
127
+ - lib/navigable/null_resolver.rb
128
+ - lib/navigable/observable.rb
129
+ - lib/navigable/observer.rb
130
+ - lib/navigable/observer_interface.rb
131
+ - lib/navigable/resolver.rb
132
+ - lib/navigable/version.rb
133
+ - navigable.gemspec
134
+ homepage: https://github.com/first_try/navigable
135
+ licenses:
136
+ - MIT
137
+ metadata:
138
+ homepage_uri: https://github.com/first_try/navigable
139
+ source_code_uri: https://github.com/first_try/navigable
140
+ bug_tracker_uri: https://github.com/first_try/navigable/issues
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ - assets
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: 2.7.0
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubygems_version: 3.1.2
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Ahoy! Navigable will get you there!
161
+ test_files: []