ringu 0.1.0.pre.alpha

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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +173 -0
  5. data/Gemfile +12 -0
  6. data/Gemfile.lock +55 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +115 -0
  9. data/Rakefile +12 -0
  10. data/bin/console +15 -0
  11. data/bin/setup +8 -0
  12. data/example/.ruby-version +1 -0
  13. data/example/Gemfile +37 -0
  14. data/example/Gemfile.lock +176 -0
  15. data/example/README.md +24 -0
  16. data/example/Rakefile +6 -0
  17. data/example/app/controllers/application_controller.rb +2 -0
  18. data/example/app/controllers/characters_controller.rb +12 -0
  19. data/example/app/controllers/concerns/.keep +0 -0
  20. data/example/app/deps/container.rb +6 -0
  21. data/example/app/fetchers/characters_fetcher.rb +13 -0
  22. data/example/app/models/application_record.rb +3 -0
  23. data/example/app/models/concerns/.keep +0 -0
  24. data/example/app/parsers/characters_parser.rb +15 -0
  25. data/example/bin/bundle +114 -0
  26. data/example/bin/rails +4 -0
  27. data/example/bin/rake +4 -0
  28. data/example/bin/setup +33 -0
  29. data/example/config.ru +6 -0
  30. data/example/config/application.rb +40 -0
  31. data/example/config/boot.rb +3 -0
  32. data/example/config/credentials.yml.enc +1 -0
  33. data/example/config/database.yml +25 -0
  34. data/example/config/environment.rb +5 -0
  35. data/example/config/environments/development.rb +58 -0
  36. data/example/config/environments/production.rb +96 -0
  37. data/example/config/environments/test.rb +49 -0
  38. data/example/config/initializers/application_controller_renderer.rb +8 -0
  39. data/example/config/initializers/backtrace_silencers.rb +8 -0
  40. data/example/config/initializers/cors.rb +16 -0
  41. data/example/config/initializers/filter_parameter_logging.rb +6 -0
  42. data/example/config/initializers/inflections.rb +16 -0
  43. data/example/config/initializers/mime_types.rb +4 -0
  44. data/example/config/initializers/wrap_parameters.rb +14 -0
  45. data/example/config/locales/en.yml +33 -0
  46. data/example/config/master.key +1 -0
  47. data/example/config/puma.rb +43 -0
  48. data/example/config/routes.rb +4 -0
  49. data/example/db/schema.rb +15 -0
  50. data/example/db/seeds.rb +7 -0
  51. data/example/lib/tasks/.keep +0 -0
  52. data/example/public/robots.txt +1 -0
  53. data/example/test/controllers/.keep +0 -0
  54. data/example/test/controllers/characters_controller_test.rb +23 -0
  55. data/example/test/fetchers/characters_fetcher_test.rb +31 -0
  56. data/example/test/fixtures/files/.keep +0 -0
  57. data/example/test/integration/.keep +0 -0
  58. data/example/test/models/.keep +0 -0
  59. data/example/test/parsers/characters_parser_test.rb +37 -0
  60. data/example/test/test_helper.rb +15 -0
  61. data/example/vendor/.keep +0 -0
  62. data/lib/ringu.rb +12 -0
  63. data/lib/ringu/container.rb +26 -0
  64. data/lib/ringu/deps.rb +37 -0
  65. data/lib/ringu/injector.rb +43 -0
  66. data/lib/ringu/resolver.rb +31 -0
  67. data/lib/ringu/version.rb +5 -0
  68. data/ringu.gemspec +34 -0
  69. metadata +111 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0e6d9630be7cbff3f1e1316310e6424842e9e8f2a4b4d66bee46c096906563f3
4
+ data.tar.gz: 3e1b892b5eed6394cc9386fca2a792b65d570fbe5c052f3a5f308f6399903176
5
+ SHA512:
6
+ metadata.gz: 2a808520ce3820c1387ae67bb2cc75538b8faa8d27c624d28b92832e78b2f5bcfd8b389160282179d13d608daae0ef73ee602d95339d88ecf5afe307b285aae7
7
+ data.tar.gz: d916b556bfd6941b82d502526b0dada35e6f91e950481ba125f72e50f743b284a80c44b82cb3cd4b2cc6617ac500bd0fee448ad6d2287b3144c6afb7a2ab84bb
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ /example/db/*.sqlite3
14
+ /example/db/*.sqlite3-journal
15
+ /example/db/*.sqlite3-[0-9]*
16
+ /example/log/*
17
+ /example/tmp/*
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,173 @@
1
+ AllCops:
2
+ Exclude:
3
+ - 'example/**/*'
4
+
5
+ Style/StringLiterals:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Style/StringLiteralsInInterpolation:
10
+ Enabled: true
11
+ EnforcedStyle: double_quotes
12
+
13
+ Layout/LineLength:
14
+ Max: 120
15
+
16
+ Layout/BeginEndAlignment:
17
+ Enabled: true
18
+
19
+ Layout/EmptyLinesAroundAttributeAccessor:
20
+ Enabled: true
21
+
22
+ Layout/SpaceAroundMethodCallOperator:
23
+ Enabled: true
24
+ Lint/BinaryOperatorWithIdenticalOperands:
25
+ Enabled: true
26
+
27
+ Lint/ConstantDefinitionInBlock:
28
+ Enabled: true
29
+
30
+ Lint/DeprecatedOpenSSLConstant:
31
+ Enabled: true
32
+
33
+ Lint/DuplicateElsifCondition:
34
+ Enabled: true
35
+
36
+ Lint/DuplicateRequire:
37
+ Enabled: true
38
+
39
+ Lint/DuplicateRescueException:
40
+ Enabled: true
41
+
42
+ Lint/EmptyConditionalBody:
43
+ Enabled: true
44
+
45
+ Lint/EmptyFile:
46
+ Enabled: true
47
+
48
+ Lint/FloatComparison:
49
+ Enabled: true
50
+
51
+ Lint/HashCompareByIdentity:
52
+ Enabled: true
53
+
54
+ Lint/IdentityComparison:
55
+ Enabled: true
56
+
57
+ Lint/MissingSuper:
58
+ Enabled: true
59
+
60
+ Lint/MixedRegexpCaptureTypes:
61
+ Enabled: true
62
+
63
+ Lint/OutOfRangeRegexpRef:
64
+ Enabled: true
65
+
66
+ Lint/RaiseException:
67
+ Enabled: true
68
+
69
+ Lint/RedundantSafeNavigation:
70
+ Enabled: true
71
+
72
+ Lint/SelfAssignment:
73
+ Enabled: true
74
+
75
+ Lint/StructNewOverride:
76
+ Enabled: true
77
+
78
+ Lint/TopLevelReturnWithArgument:
79
+ Enabled: true
80
+
81
+ Lint/TrailingCommaInAttributeDeclaration:
82
+ Enabled: true
83
+
84
+ Lint/UnreachableLoop:
85
+ Enabled: true
86
+
87
+ Lint/UselessMethodDefinition:
88
+ Enabled: true
89
+
90
+ Lint/UselessTimes:
91
+ Enabled: true
92
+
93
+ Style/AccessorGrouping:
94
+ Enabled: true
95
+
96
+ Style/BisectedAttrAccessor:
97
+ Enabled: true
98
+
99
+ Style/CaseLikeIf:
100
+ Enabled: true
101
+
102
+ Style/ClassEqualityComparison:
103
+ Enabled: true
104
+
105
+ Style/CombinableLoops:
106
+ Enabled: true
107
+
108
+ Style/ExplicitBlockArgument:
109
+ Enabled: true
110
+
111
+ Style/ExponentialNotation:
112
+ Enabled: true
113
+
114
+ Style/GlobalStdStream:
115
+ Enabled: true
116
+
117
+ Style/HashAsLastArrayItem:
118
+ Enabled: true
119
+
120
+ Style/HashEachMethods:
121
+ Enabled: true
122
+
123
+ Style/HashLikeCase:
124
+ Enabled: true
125
+
126
+ Style/HashTransformKeys:
127
+ Enabled: true
128
+
129
+ Style/HashTransformValues:
130
+ Enabled: true
131
+
132
+ Style/KeywordParametersOrder:
133
+ Enabled: true
134
+
135
+ Style/OptionalBooleanParameter:
136
+ Enabled: true
137
+
138
+ Style/RedundantAssignment:
139
+ Enabled: true
140
+
141
+ Style/RedundantFetchBlock:
142
+ Enabled: true
143
+
144
+ Style/RedundantFileExtensionInRequire:
145
+ Enabled: true
146
+
147
+ Style/RedundantRegexpCharacterClass:
148
+ Enabled: true
149
+
150
+ Style/RedundantRegexpEscape:
151
+ Enabled: true
152
+
153
+ Style/RedundantSelfAssignment:
154
+ Enabled: true
155
+
156
+ Style/SingleArgumentDig:
157
+ Enabled: true
158
+
159
+ Style/SlicingWithRange:
160
+ Enabled: true
161
+
162
+ Style/SoleNestedConditional:
163
+ Enabled: true
164
+
165
+ Style/StringConcatenation:
166
+ Enabled: true
167
+
168
+ Style/Documentation:
169
+ Enabled: false
170
+
171
+
172
+ Style/ModuleFunction:
173
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in ringu.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 0.80"
data/Gemfile.lock ADDED
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ringu (0.1.0.pre.alpha)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.4.4)
11
+ parallel (1.20.1)
12
+ parser (3.0.1.1)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.0.0)
15
+ rake (13.0.3)
16
+ regexp_parser (2.1.1)
17
+ rexml (3.2.5)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.1)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.2)
31
+ rubocop (0.93.1)
32
+ parallel (~> 1.10)
33
+ parser (>= 2.7.1.5)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ regexp_parser (>= 1.8)
36
+ rexml
37
+ rubocop-ast (>= 0.6.0)
38
+ ruby-progressbar (~> 1.7)
39
+ unicode-display_width (>= 1.4.0, < 2.0)
40
+ rubocop-ast (1.7.0)
41
+ parser (>= 3.0.1.1)
42
+ ruby-progressbar (1.11.0)
43
+ unicode-display_width (1.7.0)
44
+
45
+ PLATFORMS
46
+ arm64-darwin-20
47
+
48
+ DEPENDENCIES
49
+ rake (~> 13.0)
50
+ ringu!
51
+ rspec (~> 3.0)
52
+ rubocop (~> 0.80)
53
+
54
+ BUNDLED WITH
55
+ 2.2.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 TODO: Write your name
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,115 @@
1
+ # Ringu
2
+
3
+ ## IMPORTANT: Not ready for production
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'ringu'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ringu
20
+
21
+ ## Usage
22
+
23
+ ### Create container
24
+
25
+ Create file `container.rb` in `app/deps` directory
26
+
27
+ ```bach
28
+ mkdir app/deps
29
+
30
+ echo 'module Container\n include Ringu::Container\n\n # Deps\n # register :name, class\nend\n' >> app/deps/container.rb
31
+ ```
32
+
33
+ Example [example/app/deps/container.rb](https://github.com/clouw/ringu/blob/master/example/app/deps/container.rb)
34
+
35
+ ### Register your dependencies
36
+
37
+ ```ruby
38
+ module Container
39
+ include Ringu::Container
40
+
41
+ register :characters_fetcher, CharactersFetcher
42
+ register :http_client, Faraday
43
+ end
44
+
45
+ ```
46
+
47
+ ### Inject your dependencies
48
+
49
+ ```ruby
50
+ class CharactersFetcher
51
+ include Container::Inject
52
+
53
+ URL = "https://rickandmortyapi.com/api/character"
54
+
55
+ inject :http_client
56
+ inject :characters_parser, CharactersParser
57
+
58
+ def fetch
59
+ response = http_client.get(URL)
60
+ characters_parser.parse(response.body)
61
+ end
62
+ end
63
+ ```
64
+
65
+ Example [example/app/fetchers/characters_fetcher.rb](http://github.com/clouw/ringu/blob/master/example/app/fetchers/characters_fetcher.rb)
66
+
67
+ Example test [example/test/fetchers/characters_fetcher_test.rb](http://github.com/clouw/ringu/blob/master/example/test/fetchers/characters_fetcher_test.rb)
68
+
69
+ ### Resolve dependency
70
+
71
+ ```ruby
72
+ Container.resolve(:characters_fetcher)
73
+ ```
74
+
75
+ or
76
+
77
+ ```ruby
78
+ class CharactersController < ApplicationController
79
+ include Container::Resolve
80
+
81
+ resolve :characters_fetcher
82
+
83
+ # GET /characters
84
+ def index
85
+ @characters = characters_fetcher.fetch
86
+
87
+ render json: @characters
88
+ end
89
+ end
90
+ ```
91
+
92
+ Example [example/app/fetchers/characters_fetcher.rb](http://github.com/clouw/ringu/blob/master/example/app/controllers/characters_controller.rb)
93
+
94
+ Example test [example/test/fetchers/characters_fetcher_test.rb](http://github.com/clouw/ringu/blob/master/example/test/controllers/characters_controller_test.rb)
95
+
96
+
97
+ ## Example rails project
98
+
99
+ [Rails project](http://github.com/clouw/ringu/blob/master/example)
100
+
101
+
102
+ # TODO
103
+
104
+ - [ ] Add tests
105
+ - [ ] Add docs and more exmaples
106
+ - [ ] Refactor
107
+
108
+
109
+ ## Contributing
110
+
111
+ Bug reports and pull requests are welcome on GitHub at https://github.com/clouw/ringu.
112
+
113
+ ## License
114
+
115
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "ringu"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)