clean-architecture 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/.overcommit.yml +41 -0
  4. data/.reek +16 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +57 -0
  7. data/.ruby-version +1 -0
  8. data/CHANGELOG.md +3 -0
  9. data/Gemfile +24 -0
  10. data/Gemfile.lock +160 -0
  11. data/Guardfile +111 -0
  12. data/README.md +17 -0
  13. data/Rakefile +8 -0
  14. data/clean-architecture.gemspec +29 -0
  15. data/generate_require_files.rb +49 -0
  16. data/lib/clean-architecture.rb +3 -0
  17. data/lib/clean_architecture/all.rb +11 -0
  18. data/lib/clean_architecture/entities/all.rb +7 -0
  19. data/lib/clean_architecture/entities/targeted_parameters.rb +20 -0
  20. data/lib/clean_architecture/entities/untargeted_parameters.rb +18 -0
  21. data/lib/clean_architecture/entities/use_case_history_entry.rb +52 -0
  22. data/lib/clean_architecture/interfaces/all.rb +17 -0
  23. data/lib/clean_architecture/interfaces/authorization_check.rb +15 -0
  24. data/lib/clean_architecture/interfaces/authorization_parameters.rb +18 -0
  25. data/lib/clean_architecture/interfaces/base_parameters.rb +23 -0
  26. data/lib/clean_architecture/interfaces/command.rb +23 -0
  27. data/lib/clean_architecture/interfaces/jsonable.rb +15 -0
  28. data/lib/clean_architecture/interfaces/persistence.rb +15 -0
  29. data/lib/clean_architecture/interfaces/strategy.rb +17 -0
  30. data/lib/clean_architecture/interfaces/success_payload.rb +19 -0
  31. data/lib/clean_architecture/interfaces/targeted_parameters.rb +18 -0
  32. data/lib/clean_architecture/interfaces/use_case.rb +23 -0
  33. data/lib/clean_architecture/interfaces/use_case_actor.rb +19 -0
  34. data/lib/clean_architecture/interfaces/use_case_history_entry.rb +39 -0
  35. data/lib/clean_architecture/interfaces/use_case_target.rb +23 -0
  36. data/lib/clean_architecture/queries/all.rb +5 -0
  37. data/lib/clean_architecture/queries/http_success_code.rb +28 -0
  38. data/lib/clean_architecture/serializers/all.rb +6 -0
  39. data/lib/clean_architecture/serializers/html_response_from_result.rb +23 -0
  40. data/lib/clean_architecture/serializers/json_response_from_result.rb +67 -0
  41. data/lib/clean_architecture/strategies/actor_gets_authorized_then_does_work.rb +30 -0
  42. data/lib/clean_architecture/strategies/all.rb +6 -0
  43. data/lib/clean_architecture/strategies/with_audit_trail.rb +40 -0
  44. data/lib/clean_architecture/version.rb +5 -0
  45. metadata +170 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cb6fbe1a9004389c1d14f8cbe72293825ffc8530
4
+ data.tar.gz: 13838c48fd2f72411bd17afe06d7810832f95c41
5
+ SHA512:
6
+ metadata.gz: '084fbabf3a62f60fdc360535cd53e031892dfdcd784a1b8580edd471aa1b11d9e77b814c4ed7db6d52829fb2a854853e1967180ed3fd124fed9843e3000de509'
7
+ data.tar.gz: b35ef32add448162a6595debb3b7ca74b79fb5625fbe8b82a353cd54a9116678111d7391f3047b237e2378f11fb709f1786a4c5c723c9b8e2a8cfe87f5a3352f
@@ -0,0 +1 @@
1
+ coverage
@@ -0,0 +1,41 @@
1
+ # Use this file to configure the Overcommit hooks you wish to use. This will
2
+ # extend the default configuration defined in:
3
+ # https://github.com/brigade/overcommit/blob/master/config/default.yml
4
+ #
5
+ # At the topmost level of this YAML file is a key representing type of hook
6
+ # being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
7
+ # customize each hook, such as whether to only run it on certain files (via
8
+ # `include`), whether to only display output if it fails (via `quiet`), etc.
9
+ #
10
+ # For a complete list of hooks, see:
11
+ # https://github.com/brigade/overcommit/tree/master/lib/overcommit/hook
12
+ #
13
+ # For a complete list of options that you can use to customize hooks, see:
14
+ # https://github.com/brigade/overcommit#configuration
15
+ #
16
+ # Uncomment the following lines to make the configuration take effect.
17
+
18
+ verify_signatures: false
19
+
20
+ PreCommit:
21
+ MasterMerger:
22
+ enabled: true
23
+ command: ['bundle', 'exec', 'master-merger']
24
+ TrailingWhitespace:
25
+ enabled: true
26
+ # RuboCop:
27
+ # enabled: true
28
+ # on_warn: fail # Treat all warnings as failures
29
+ PostCheckout:
30
+ ReadersDigest:
31
+ enabled: true
32
+ on_fail: warn
33
+ command: ['bundle', 'exec', 'readers-digest']
34
+ #StoryKickoff:
35
+ #enabled: true
36
+ #required_executable: './bin/story-kickoff'
37
+ # ALL: # Special hook name that customizes all hooks of this type
38
+ # quiet: true # Change all post-checkout hooks to only display output on failure
39
+ #
40
+ # IndexTags:
41
+ # enabled: true # Generate a tags file with `ctags` each time HEAD changes
data/.reek ADDED
@@ -0,0 +1,16 @@
1
+ ---
2
+ IrresponsibleModule:
3
+ enabled: false
4
+ TooManyStatements:
5
+ enabled: true
6
+ max_statements: 10
7
+ NilCheck:
8
+ enabled: false
9
+ app/controllers:
10
+ NestedIterators:
11
+ max_allowed_nesting: 2
12
+ UnusedPrivateMethod:
13
+ enabled: false
14
+ app/helpers:
15
+ UtilityFunction:
16
+ enabled: false
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --colour
2
+ --require spec_helper
@@ -0,0 +1,57 @@
1
+ ---
2
+ Documentation:
3
+ Enabled: false
4
+ Rails:
5
+ Enabled: true
6
+ AllCops:
7
+ Include:
8
+ - app/**/*.rb
9
+ - lib/**/*.rb
10
+ - spec/**/*.rb
11
+ Exclude:
12
+ - app/assets/**/*
13
+ - bin/**/*
14
+ - client/node_modules/**/*
15
+ - config/**/*
16
+ - coverage/**/*
17
+ - data/**/*
18
+ - db/**/*
19
+ - db_*/**/*
20
+ - dw/**/*
21
+ - log/**/*
22
+ - phrase/**/*
23
+ - public/**/*
24
+ - tmp/**/*
25
+ - vendor/**/*
26
+ TargetRubyVersion: 2.3
27
+ Metrics/LineLength:
28
+ Max: 100
29
+ Layout/MultilineMethodCallIndentation:
30
+ EnforcedStyle: indented
31
+ Style/PercentLiteralDelimiters:
32
+ PreferredDelimiters:
33
+ "%w": "[]"
34
+ RSpec/ExampleLength:
35
+ Enabled: false
36
+ Max: 10
37
+ RSpec/MultipleExpectations:
38
+ Enabled: false
39
+ Max: 10
40
+ RSpec/NestedGroups:
41
+ Enabled: false
42
+ Max: 10
43
+ RSpec/MessageExpectation:
44
+ Enabled: false
45
+ require:
46
+ - rubocop-rspec
47
+ - test_prof/rubocop
48
+ Metrics/BlockLength:
49
+ Enabled: false
50
+ RSpec/MessageSpies:
51
+ Enabled: false
52
+ RSpec/ExpectInHook:
53
+ Enabled: false
54
+ RSpec/AggregateFailures:
55
+ Enabled: true
56
+ Include:
57
+ - spec/**/*.rb
@@ -0,0 +1 @@
1
+ 2.4.2
@@ -0,0 +1,3 @@
1
+ 0.0.1
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in bellroy-money.gemspec
6
+ gemspec
7
+
8
+ group :development, :test do
9
+ gem 'guard-livereload', require: false
10
+ gem 'guard-rspec'
11
+ gem 'pry-byebug'
12
+ gem 'rb-fsevent', require: false
13
+ gem 'rb-readline'
14
+ gem 'reek'
15
+ gem 'rspec'
16
+ gem 'rubocop'
17
+ gem 'rubocop-rspec'
18
+ gem 'stackprof'
19
+ gem 'timecop'
20
+ end
21
+
22
+ group :test do
23
+ gem 'simplecov'
24
+ end
@@ -0,0 +1,160 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ clean-architecture (0.0.1)
5
+ dry-matcher
6
+ dry-monads
7
+ duckface-interfaces
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.0)
13
+ axiom-types (0.1.1)
14
+ descendants_tracker (~> 0.0.4)
15
+ ice_nine (~> 0.11.0)
16
+ thread_safe (~> 0.3, >= 0.3.1)
17
+ byebug (10.0.2)
18
+ codeclimate-engine-rb (0.4.1)
19
+ virtus (~> 1.0)
20
+ coderay (1.1.2)
21
+ coercible (1.0.0)
22
+ descendants_tracker (~> 0.0.1)
23
+ concurrent-ruby (1.0.5)
24
+ descendants_tracker (0.0.4)
25
+ thread_safe (~> 0.3, >= 0.3.1)
26
+ diff-lcs (1.3)
27
+ docile (1.3.1)
28
+ dry-core (0.4.6)
29
+ concurrent-ruby (~> 1.0)
30
+ dry-equalizer (0.2.1)
31
+ dry-matcher (0.7.0)
32
+ dry-monads (0.4.0)
33
+ dry-core (~> 0.3, >= 0.3.3)
34
+ dry-equalizer
35
+ duckface-interfaces (0.0.1)
36
+ em-websocket (0.5.1)
37
+ eventmachine (>= 0.12.9)
38
+ http_parser.rb (~> 0.6.0)
39
+ equalizer (0.0.11)
40
+ eventmachine (1.2.7)
41
+ ffi (1.9.25)
42
+ formatador (0.2.5)
43
+ guard (2.14.2)
44
+ formatador (>= 0.2.4)
45
+ listen (>= 2.7, < 4.0)
46
+ lumberjack (>= 1.0.12, < 2.0)
47
+ nenv (~> 0.1)
48
+ notiffany (~> 0.0)
49
+ pry (>= 0.9.12)
50
+ shellany (~> 0.0)
51
+ thor (>= 0.18.1)
52
+ guard-compat (1.2.1)
53
+ guard-livereload (2.5.2)
54
+ em-websocket (~> 0.5)
55
+ guard (~> 2.8)
56
+ guard-compat (~> 1.0)
57
+ multi_json (~> 1.8)
58
+ guard-rspec (4.7.3)
59
+ guard (~> 2.1)
60
+ guard-compat (~> 1.1)
61
+ rspec (>= 2.99.0, < 4.0)
62
+ http_parser.rb (0.6.0)
63
+ ice_nine (0.11.2)
64
+ jaro_winkler (1.5.1)
65
+ json (2.1.0)
66
+ listen (3.1.5)
67
+ rb-fsevent (~> 0.9, >= 0.9.4)
68
+ rb-inotify (~> 0.9, >= 0.9.7)
69
+ ruby_dep (~> 1.2)
70
+ lumberjack (1.0.13)
71
+ method_source (0.9.0)
72
+ multi_json (1.13.1)
73
+ nenv (0.3.0)
74
+ notiffany (0.1.1)
75
+ nenv (~> 0.1)
76
+ shellany (~> 0.0)
77
+ parallel (1.12.1)
78
+ parser (2.5.1.0)
79
+ ast (~> 2.4.0)
80
+ powerpack (0.1.2)
81
+ pry (0.11.3)
82
+ coderay (~> 1.1.0)
83
+ method_source (~> 0.9.0)
84
+ pry-byebug (3.6.0)
85
+ byebug (~> 10.0)
86
+ pry (~> 0.10)
87
+ rainbow (3.0.0)
88
+ rake (12.3.1)
89
+ rb-fsevent (0.10.3)
90
+ rb-inotify (0.9.10)
91
+ ffi (>= 0.5.0, < 2)
92
+ rb-readline (0.5.5)
93
+ reek (4.8.1)
94
+ codeclimate-engine-rb (~> 0.4.0)
95
+ parser (>= 2.5.0.0, < 2.6)
96
+ rainbow (>= 2.0, < 4.0)
97
+ rspec (3.7.0)
98
+ rspec-core (~> 3.7.0)
99
+ rspec-expectations (~> 3.7.0)
100
+ rspec-mocks (~> 3.7.0)
101
+ rspec-core (3.7.1)
102
+ rspec-support (~> 3.7.0)
103
+ rspec-expectations (3.7.0)
104
+ diff-lcs (>= 1.2.0, < 2.0)
105
+ rspec-support (~> 3.7.0)
106
+ rspec-mocks (3.7.0)
107
+ diff-lcs (>= 1.2.0, < 2.0)
108
+ rspec-support (~> 3.7.0)
109
+ rspec-support (3.7.1)
110
+ rubocop (0.57.2)
111
+ jaro_winkler (~> 1.5.1)
112
+ parallel (~> 1.10)
113
+ parser (>= 2.5)
114
+ powerpack (~> 0.1)
115
+ rainbow (>= 2.2.2, < 4.0)
116
+ ruby-progressbar (~> 1.7)
117
+ unicode-display_width (~> 1.0, >= 1.0.1)
118
+ rubocop-rspec (1.27.0)
119
+ rubocop (>= 0.56.0)
120
+ ruby-progressbar (1.9.0)
121
+ ruby_dep (1.5.0)
122
+ shellany (0.0.1)
123
+ simplecov (0.16.1)
124
+ docile (~> 1.1)
125
+ json (>= 1.8, < 3)
126
+ simplecov-html (~> 0.10.0)
127
+ simplecov-html (0.10.2)
128
+ stackprof (0.2.11)
129
+ thor (0.20.0)
130
+ thread_safe (0.3.6)
131
+ timecop (0.9.1)
132
+ unicode-display_width (1.4.0)
133
+ virtus (1.0.5)
134
+ axiom-types (~> 0.1)
135
+ coercible (~> 1.0)
136
+ descendants_tracker (~> 0.0, >= 0.0.3)
137
+ equalizer (~> 0.0, >= 0.0.9)
138
+
139
+ PLATFORMS
140
+ ruby
141
+
142
+ DEPENDENCIES
143
+ bundler (>= 1.13)
144
+ clean-architecture!
145
+ guard-livereload
146
+ guard-rspec
147
+ pry-byebug
148
+ rake (>= 10.0)
149
+ rb-fsevent
150
+ rb-readline
151
+ reek
152
+ rspec
153
+ rubocop
154
+ rubocop-rspec
155
+ simplecov
156
+ stackprof
157
+ timecop
158
+
159
+ BUNDLED WITH
160
+ 1.16.1
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A sample Guardfile
4
+ # More info at https://github.com/guard/guard#readme
5
+
6
+ ## Uncomment and set this to only include directories you want to watch
7
+ # directories %w(app lib config test spec features) \
8
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
9
+
10
+ ## Note: if you are using the `directories` clause above and you are not
11
+ ## watching the project directory ('.'), then you will want to move
12
+ ## the Guardfile to a watched dir and symlink it back, e.g.
13
+ #
14
+ # $ mkdir config
15
+ # $ mv Guardfile config/
16
+ # $ ln -s config/Guardfile .
17
+ #
18
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
19
+
20
+ guard 'livereload' do
21
+ extensions = {
22
+ css: :css,
23
+ scss: :css,
24
+ sass: :css,
25
+ js: :js,
26
+ coffee: :js,
27
+ html: :html,
28
+ png: :png,
29
+ gif: :gif,
30
+ jpg: :jpg,
31
+ jpeg: :jpeg,
32
+ # less: :less, # uncomment if you want LESS stylesheets done in browser
33
+ }
34
+
35
+ rails_view_exts = %w[erb haml slim]
36
+
37
+ # file types LiveReload may optimize refresh for
38
+ compiled_exts = extensions.values.uniq
39
+ watch(%r{public/.+\.(#{compiled_exts * '|'})})
40
+
41
+ extensions.each do |ext, type|
42
+ watch(%r{
43
+ (?:app|vendor)
44
+ (?:/assets/\w+/(?<path>[^.]+) # path+base without extension
45
+ (?<ext>\.#{ext})) # matching extension (must be first encountered)
46
+ (?:\.\w+|$) # other extensions
47
+ }x) do |m|
48
+ path = m[1]
49
+ "/assets/#{path}.#{type}"
50
+ end
51
+ end
52
+
53
+ # file needing a full reload of the page anyway
54
+ watch(%r{app/views/.+\.(#{rails_view_exts * '|'})$})
55
+ watch(%r{app/helpers/.+\.rb})
56
+ watch(%r{config/locales/.+\.yml})
57
+ end
58
+
59
+ # Note: The cmd option is now required due to the increasing number of ways
60
+ # rspec may be run, below are examples of the most common uses.
61
+ # * bundler: 'bundle exec rspec'
62
+ # * bundler binstubs: 'bin/rspec'
63
+ # * spring: 'bin/rspec' (This will use spring if running and you have
64
+ # installed the spring binstubs per the docs)
65
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
66
+ # * 'just' rspec: 'rspec'
67
+
68
+ guard :rspec, cmd: 'bundle exec rspec' do
69
+ require 'guard/rspec/dsl'
70
+ dsl = Guard::RSpec::Dsl.new(self)
71
+
72
+ # Feel free to open issues for suggestions and improvements
73
+
74
+ # RSpec files
75
+ rspec = dsl.rspec
76
+ watch(rspec.spec_helper) { rspec.spec_dir }
77
+ watch(rspec.spec_support) { rspec.spec_dir }
78
+ watch(rspec.spec_files)
79
+
80
+ # Ruby files
81
+ ruby = dsl.ruby
82
+ dsl.watch_spec_files_for(ruby.lib_files)
83
+
84
+ # Rails files
85
+ rails = dsl.rails(view_extensions: %w[erb haml slim])
86
+ dsl.watch_spec_files_for(rails.app_files)
87
+ dsl.watch_spec_files_for(rails.views)
88
+
89
+ watch(rails.controllers) do |m|
90
+ [
91
+ rspec.spec.call("routing/#{m[1]}_routing"),
92
+ rspec.spec.call("controllers/#{m[1]}_controller"),
93
+ rspec.spec.call("acceptance/#{m[1]}")
94
+ ]
95
+ end
96
+
97
+ # Rails config changes
98
+ watch(rails.spec_helper) { rspec.spec_dir }
99
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
100
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
101
+
102
+ # Capybara features specs
103
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
104
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
105
+
106
+ # Turnip features and steps
107
+ watch(%r{^spec/acceptance/(.+)\.feature$})
108
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
109
+ Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance'
110
+ end
111
+ end
@@ -0,0 +1,17 @@
1
+ # Clean Architecture
2
+
3
+ This gem provides helper interfaces and classes to assist in the construction of application with
4
+ Clean Architecture, as described in [Robert Martin's seminal book](https://www.amazon.com/gp/product/0134494164).
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'clean-architecture'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle install
17
+ $ bundle binstubs clean-architecture