Skip to content

Commit

Permalink
Merge 9189a8d into 5d75f59
Browse files Browse the repository at this point in the history
  • Loading branch information
marian13 committed Jan 22, 2023
2 parents 5d75f59 + 9189a8d commit a354cff
Show file tree
Hide file tree
Showing 161 changed files with 8,400 additions and 426 deletions.
16 changes: 13 additions & 3 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,25 @@
| High | 🚧 | `included_once` for `Support::Concern` |
| Medium | 🚧 | Custom YARD type for service instance, service class as return values |
| Medium | 🚧 | Heredoc for error messages |
| Medium | 🚧 | Specs for `be_success`, `be_error`, `be_failure` matchers | |
| Low | 🚧 | [Receive Counts](https://relishapp.com/rspec/rspec-mocks/docs/setting-constraints/receive-counts) for `delegate_to` | |
| Medium | 🚧 | Specs for `be_success`, `be_error`, `be_failure` matchers | |
| Low | 🚧 | [Receive Counts](https://relishapp.com/rspec/rspec-mocks/docs/setting-constraints/receive-counts) for `delegate_to` | |
| Low | 🚧 | Prefer versioning instead of modification plugin | |
| Low | 🚧 | Consider to move `__steps__` and `__callbacks__` to `internals_class` | Benefit? |
| Medium | 🚧 | User friendly `raise` that removes lib backtrace from caller | Should have a `debug` mode. Should work well with examples. Check RSpec `CallerFilter.first_non_rspec_line` |
| High | 🚧 | A plugin that catches `StandardError` and returns `failure` | Should be the lowest in the stack |
| High | 🚧 | `Support::Command` alias | Should be visible to the end user |
| Low | 🚧 | Parallel steps | A killer feature |
| Medium | 🚧 | Add Ruby 3.2 support to Docker and CI | |
| Medium | 🚧 | Add `Ruby 3.2` support to `Docker` and `CI` | |
| Low | 🚧 | `overload do` | |
| Low | 🚧 | Same spec example group organization | |
| Medium | 🚧 | `Support::Arguments` | |
| Low | 🚧 | Null object to Nil object? | |
| High | 🚧 | Do not use Testing Toolkit in the Primitives layer | See [Components Diagram](https://marian13.github.io/static_content/convenient_service/diagrams/components_graph.html) + it should take the minimal amount of efforts to extract and reuse `Utils`, `Suppport` in the different projects |
| Medium | 🚧 | Perfromance testing | [rspec-benchmark](https://github.com/piotrmurach/rspec-benchmark), [Testing object allocations](https://www.honeybadger.io/blog/testing-object-allocations/), [allocation_stats](https://github.com/srawlins/allocation_stats) |
| Medium | 🚧 | Mutant testing | [mutant](https://github.com/mbj/mutant) |
| Low | 🚧 | Add `JRuby` support | [jruby](https://www.jruby.org/) |
| Medium | 🚧 | Add `shoulda-context` to test conditionals when `RSpec` is not loaded | [shoulda-context](https://github.com/thoughtbot/shoulda-context) |
| High | 🚧 | Abstract factory for `CastMethod` | |
| Medium | 🚧 | `delegate_to` - option to specify of how to compare blocks | |

Search for `TODO`s in the codebase for more tasks.
2 changes: 2 additions & 0 deletions convenient_service.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "commonmarker"
spec.add_development_dependency "gem-release"
spec.add_development_dependency "inch"
spec.add_development_dependency "json"
spec.add_development_dependency "paint"
spec.add_development_dependency "progressbar"
spec.add_development_dependency "rake", "~> 12.0"
Expand All @@ -47,6 +48,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "standard"
spec.add_development_dependency "simplecov"
spec.add_development_dependency "simplecov-lcov"
spec.add_development_dependency "webrick"
spec.add_development_dependency "yard"
spec.add_development_dependency "yard-junk"
end
Original file line number Diff line number Diff line change
Expand Up @@ -35,30 +35,7 @@ def initialize(container:)
# @return [Module]
#
def call
get_methods_middlewares_callers || set_methods_middlewares_callers
end

private

##
# @return [Module, nil]
#
def get_methods_middlewares_callers
Utils::Module.get_own_const(klass, module_name)
end

##
# @return [Module]
#
def set_methods_middlewares_callers
klass.const_set(module_name, ::Module.new)
end

##
# @return [Symbol]
#
def module_name
@module_name ||= :MethodsMiddlewaresCallers
Utils::Module.fetch_own_const(klass, :MethodsMiddlewaresCallers) { ::Module.new }
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions lib/convenient_service/dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,12 @@ def require_rspec_extentions
# @api private
#
def require_standard_examples
require "json"
require "progressbar"
require "webrick"

require_relative "examples/standard/cowsay"
require_relative "examples/standard/request_params"
require_relative "examples/standard/gemfile"
end

Expand All @@ -126,7 +129,9 @@ def require_standard_examples
# @api private
#
def require_rails_examples
require "json"
require "progressbar"
require "webrick"

require_relative "examples/rails/gemfile"
end
Expand All @@ -138,7 +143,9 @@ def require_rails_examples
# @api private
#
def require_dry_examples
require "json"
require "progressbar"
require "webrick"

require_relative "examples/dry/gemfile"
end
Expand Down
48 changes: 48 additions & 0 deletions lib/convenient_service/examples/standard/request_params.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# frozen_string_literal: true

require_relative "request_params/constants"
require_relative "request_params/entities"
require_relative "request_params/services"
require_relative "request_params/utils"

##
# @since 0.3.0
#
# @internal
# Usage example:
#
# http_string =
# <<~TEXT
# POST /rules/1000000.json HTTP/1.1
# User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
# Host: code-review.com
# Content-Type: application/json; charset=utf-8
# Content-Length: 134
# Accept-Language: en-us
# Accept-Encoding: gzip, deflate
# Connection: Keep-Alive
#
# {"title":"Avoid error shadowing","description":"Check the official User Docs","tags":["error-shadowing"]}
# TEXT
#
# request = ConvenientService::Examples::Standard::RequestParams::Entities::Request.new(http_string:)
#
# ConvenientService::Examples::Standard::RequestParams.prepare(request)
#
# - https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
# - https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome
# - https://www.tutorialspoint.com/http/http_requests.htm
#
module ConvenientService
module Examples
module Standard
module RequestParams
class << self
def prepare(request)
Services::Prepare[request: request]
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module ConvenientService
module Examples
module Standard
module RequestParams
module Constants
module Tags
EMPTY = ""
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require_relative "entities/logger"
require_relative "entities/request"

require_relative "entities/description"
require_relative "entities/format"
require_relative "entities/id"
require_relative "entities/source"
require_relative "entities/tag"
require_relative "entities/title"
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

module ConvenientService
module Examples
module Standard
module RequestParams
module Entities
class Description
def initialize(value:)
@value = value
end

class << self
def cast(value)
case value
when ::String
new(value: value.to_s)
end
end
end

def ==(other)
return unless other.instance_of?(self.class)

value == other.value
end

def to_s
value
end

protected

attr_reader :value
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

module ConvenientService
module Examples
module Standard
module RequestParams
module Entities
class Format
def initialize(value:)
@value = value
end

class << self
def cast(value)
case value
when ::String
new(value: value.to_s)
end
end
end

def ==(other)
return unless other.instance_of?(self.class)

value == other.value
end

def to_s
value
end

protected

attr_reader :value
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true

module ConvenientService
module Examples
module Standard
module RequestParams
module Entities
##
# TODO: https://ruby-doc.org/3.1.3/stdlibs/yaml/YAML/DBM.html
#
class ID
def initialize(value:)
@value = value
end

class << self
def cast(value)
case value
when ::String, ::Integer
new(value: value.to_s)
end
end
end

def ==(other)
return unless other.instance_of?(self.class)

value == other.value
end

def to_i
value.to_i
end

def to_s
value
end

protected

attr_reader :value
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module ConvenientService
module Examples
module Standard
module RequestParams
module Entities
class Logger
class << self
def log(message, out: $stdout)
out.puts message

message
end
end
end
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

module ConvenientService
module Examples
module Standard
module RequestParams
module Entities
class Request
attr_reader :http_string

def initialize(http_string:)
@http_string = http_string
end

def to_s
http_string
end
end
end
end
end
end
end
Loading

0 comments on commit a354cff

Please sign in to comment.