ringu 0.1.0.pre.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.rubocop.yml +173 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +55 -0
- data/LICENSE.txt +21 -0
- data/README.md +115 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/example/.ruby-version +1 -0
- data/example/Gemfile +37 -0
- data/example/Gemfile.lock +176 -0
- data/example/README.md +24 -0
- data/example/Rakefile +6 -0
- data/example/app/controllers/application_controller.rb +2 -0
- data/example/app/controllers/characters_controller.rb +12 -0
- data/example/app/controllers/concerns/.keep +0 -0
- data/example/app/deps/container.rb +6 -0
- data/example/app/fetchers/characters_fetcher.rb +13 -0
- data/example/app/models/application_record.rb +3 -0
- data/example/app/models/concerns/.keep +0 -0
- data/example/app/parsers/characters_parser.rb +15 -0
- data/example/bin/bundle +114 -0
- data/example/bin/rails +4 -0
- data/example/bin/rake +4 -0
- data/example/bin/setup +33 -0
- data/example/config.ru +6 -0
- data/example/config/application.rb +40 -0
- data/example/config/boot.rb +3 -0
- data/example/config/credentials.yml.enc +1 -0
- data/example/config/database.yml +25 -0
- data/example/config/environment.rb +5 -0
- data/example/config/environments/development.rb +58 -0
- data/example/config/environments/production.rb +96 -0
- data/example/config/environments/test.rb +49 -0
- data/example/config/initializers/application_controller_renderer.rb +8 -0
- data/example/config/initializers/backtrace_silencers.rb +8 -0
- data/example/config/initializers/cors.rb +16 -0
- data/example/config/initializers/filter_parameter_logging.rb +6 -0
- data/example/config/initializers/inflections.rb +16 -0
- data/example/config/initializers/mime_types.rb +4 -0
- data/example/config/initializers/wrap_parameters.rb +14 -0
- data/example/config/locales/en.yml +33 -0
- data/example/config/master.key +1 -0
- data/example/config/puma.rb +43 -0
- data/example/config/routes.rb +4 -0
- data/example/db/schema.rb +15 -0
- data/example/db/seeds.rb +7 -0
- data/example/lib/tasks/.keep +0 -0
- data/example/public/robots.txt +1 -0
- data/example/test/controllers/.keep +0 -0
- data/example/test/controllers/characters_controller_test.rb +23 -0
- data/example/test/fetchers/characters_fetcher_test.rb +31 -0
- data/example/test/fixtures/files/.keep +0 -0
- data/example/test/integration/.keep +0 -0
- data/example/test/models/.keep +0 -0
- data/example/test/parsers/characters_parser_test.rb +37 -0
- data/example/test/test_helper.rb +15 -0
- data/example/vendor/.keep +0 -0
- data/lib/ringu.rb +12 -0
- data/lib/ringu/container.rb +26 -0
- data/lib/ringu/deps.rb +37 -0
- data/lib/ringu/injector.rb +43 -0
- data/lib/ringu/resolver.rb +31 -0
- data/lib/ringu/version.rb +5 -0
- data/ringu.gemspec +34 -0
- metadata +111 -0
data/bin/setup
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-3.0.0
|
data/example/Gemfile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
3
|
+
|
4
|
+
ruby '3.0.0'
|
5
|
+
|
6
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails', branch: 'main'
|
7
|
+
gem 'rails', '~> 6.1.4'
|
8
|
+
# Use sqlite3 as the database for Active Record
|
9
|
+
gem 'sqlite3', '~> 1.4'
|
10
|
+
# Use Puma as the app server
|
11
|
+
gem 'puma', '~> 5.0'
|
12
|
+
# Use Active Model has_secure_password
|
13
|
+
# gem 'bcrypt', '~> 3.1.7'
|
14
|
+
|
15
|
+
# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
|
16
|
+
# gem 'rack-cors'
|
17
|
+
|
18
|
+
group :development, :test do
|
19
|
+
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
20
|
+
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
|
21
|
+
end
|
22
|
+
|
23
|
+
group :development do
|
24
|
+
gem 'listen', '~> 3.3'
|
25
|
+
end
|
26
|
+
|
27
|
+
group :test do
|
28
|
+
gem 'mocha', '~> 1.13.0'
|
29
|
+
end
|
30
|
+
|
31
|
+
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
32
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
33
|
+
|
34
|
+
gem 'ringu', path: '../'
|
35
|
+
|
36
|
+
gem 'faraday'
|
37
|
+
|
@@ -0,0 +1,176 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
ringu (0.1.0)
|
5
|
+
dry-container (~> 0.7)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (6.1.4)
|
11
|
+
actionpack (= 6.1.4)
|
12
|
+
activesupport (= 6.1.4)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
actionmailbox (6.1.4)
|
16
|
+
actionpack (= 6.1.4)
|
17
|
+
activejob (= 6.1.4)
|
18
|
+
activerecord (= 6.1.4)
|
19
|
+
activestorage (= 6.1.4)
|
20
|
+
activesupport (= 6.1.4)
|
21
|
+
mail (>= 2.7.1)
|
22
|
+
actionmailer (6.1.4)
|
23
|
+
actionpack (= 6.1.4)
|
24
|
+
actionview (= 6.1.4)
|
25
|
+
activejob (= 6.1.4)
|
26
|
+
activesupport (= 6.1.4)
|
27
|
+
mail (~> 2.5, >= 2.5.4)
|
28
|
+
rails-dom-testing (~> 2.0)
|
29
|
+
actionpack (6.1.4)
|
30
|
+
actionview (= 6.1.4)
|
31
|
+
activesupport (= 6.1.4)
|
32
|
+
rack (~> 2.0, >= 2.0.9)
|
33
|
+
rack-test (>= 0.6.3)
|
34
|
+
rails-dom-testing (~> 2.0)
|
35
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
36
|
+
actiontext (6.1.4)
|
37
|
+
actionpack (= 6.1.4)
|
38
|
+
activerecord (= 6.1.4)
|
39
|
+
activestorage (= 6.1.4)
|
40
|
+
activesupport (= 6.1.4)
|
41
|
+
nokogiri (>= 1.8.5)
|
42
|
+
actionview (6.1.4)
|
43
|
+
activesupport (= 6.1.4)
|
44
|
+
builder (~> 3.1)
|
45
|
+
erubi (~> 1.4)
|
46
|
+
rails-dom-testing (~> 2.0)
|
47
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
48
|
+
activejob (6.1.4)
|
49
|
+
activesupport (= 6.1.4)
|
50
|
+
globalid (>= 0.3.6)
|
51
|
+
activemodel (6.1.4)
|
52
|
+
activesupport (= 6.1.4)
|
53
|
+
activerecord (6.1.4)
|
54
|
+
activemodel (= 6.1.4)
|
55
|
+
activesupport (= 6.1.4)
|
56
|
+
activestorage (6.1.4)
|
57
|
+
actionpack (= 6.1.4)
|
58
|
+
activejob (= 6.1.4)
|
59
|
+
activerecord (= 6.1.4)
|
60
|
+
activesupport (= 6.1.4)
|
61
|
+
marcel (~> 1.0.0)
|
62
|
+
mini_mime (>= 1.1.0)
|
63
|
+
activesupport (6.1.4)
|
64
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
65
|
+
i18n (>= 1.6, < 2)
|
66
|
+
minitest (>= 5.1)
|
67
|
+
tzinfo (~> 2.0)
|
68
|
+
zeitwerk (~> 2.3)
|
69
|
+
builder (3.2.4)
|
70
|
+
byebug (11.1.3)
|
71
|
+
concurrent-ruby (1.1.9)
|
72
|
+
crass (1.0.6)
|
73
|
+
dry-configurable (0.12.1)
|
74
|
+
concurrent-ruby (~> 1.0)
|
75
|
+
dry-core (~> 0.5, >= 0.5.0)
|
76
|
+
dry-container (0.8.0)
|
77
|
+
concurrent-ruby (~> 1.0)
|
78
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
79
|
+
dry-core (0.6.0)
|
80
|
+
concurrent-ruby (~> 1.0)
|
81
|
+
erubi (1.10.0)
|
82
|
+
faraday (0.17.4)
|
83
|
+
multipart-post (>= 1.2, < 3)
|
84
|
+
ffi (1.15.3)
|
85
|
+
globalid (0.4.2)
|
86
|
+
activesupport (>= 4.2.0)
|
87
|
+
i18n (1.8.10)
|
88
|
+
concurrent-ruby (~> 1.0)
|
89
|
+
listen (3.5.1)
|
90
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
91
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
92
|
+
loofah (2.10.0)
|
93
|
+
crass (~> 1.0.2)
|
94
|
+
nokogiri (>= 1.5.9)
|
95
|
+
mail (2.7.1)
|
96
|
+
mini_mime (>= 0.1.1)
|
97
|
+
marcel (1.0.1)
|
98
|
+
method_source (1.0.0)
|
99
|
+
mini_mime (1.1.0)
|
100
|
+
minitest (5.14.4)
|
101
|
+
mocha (1.13.0)
|
102
|
+
multipart-post (2.1.1)
|
103
|
+
nio4r (2.5.7)
|
104
|
+
nokogiri (1.11.7-arm64-darwin)
|
105
|
+
racc (~> 1.4)
|
106
|
+
puma (5.3.2)
|
107
|
+
nio4r (~> 2.0)
|
108
|
+
racc (1.5.2)
|
109
|
+
rack (2.2.3)
|
110
|
+
rack-test (1.1.0)
|
111
|
+
rack (>= 1.0, < 3)
|
112
|
+
rails (6.1.4)
|
113
|
+
actioncable (= 6.1.4)
|
114
|
+
actionmailbox (= 6.1.4)
|
115
|
+
actionmailer (= 6.1.4)
|
116
|
+
actionpack (= 6.1.4)
|
117
|
+
actiontext (= 6.1.4)
|
118
|
+
actionview (= 6.1.4)
|
119
|
+
activejob (= 6.1.4)
|
120
|
+
activemodel (= 6.1.4)
|
121
|
+
activerecord (= 6.1.4)
|
122
|
+
activestorage (= 6.1.4)
|
123
|
+
activesupport (= 6.1.4)
|
124
|
+
bundler (>= 1.15.0)
|
125
|
+
railties (= 6.1.4)
|
126
|
+
sprockets-rails (>= 2.0.0)
|
127
|
+
rails-dom-testing (2.0.3)
|
128
|
+
activesupport (>= 4.2.0)
|
129
|
+
nokogiri (>= 1.6)
|
130
|
+
rails-html-sanitizer (1.3.0)
|
131
|
+
loofah (~> 2.3)
|
132
|
+
railties (6.1.4)
|
133
|
+
actionpack (= 6.1.4)
|
134
|
+
activesupport (= 6.1.4)
|
135
|
+
method_source
|
136
|
+
rake (>= 0.13)
|
137
|
+
thor (~> 1.0)
|
138
|
+
rake (13.0.3)
|
139
|
+
rb-fsevent (0.11.0)
|
140
|
+
rb-inotify (0.10.1)
|
141
|
+
ffi (~> 1.0)
|
142
|
+
sprockets (4.0.2)
|
143
|
+
concurrent-ruby (~> 1.0)
|
144
|
+
rack (> 1, < 3)
|
145
|
+
sprockets-rails (3.2.2)
|
146
|
+
actionpack (>= 4.0)
|
147
|
+
activesupport (>= 4.0)
|
148
|
+
sprockets (>= 3.0.0)
|
149
|
+
sqlite3 (1.4.2)
|
150
|
+
thor (1.1.0)
|
151
|
+
tzinfo (2.0.4)
|
152
|
+
concurrent-ruby (~> 1.0)
|
153
|
+
websocket-driver (0.7.5)
|
154
|
+
websocket-extensions (>= 0.1.0)
|
155
|
+
websocket-extensions (0.1.5)
|
156
|
+
zeitwerk (2.4.2)
|
157
|
+
|
158
|
+
PLATFORMS
|
159
|
+
arm64-darwin-20
|
160
|
+
|
161
|
+
DEPENDENCIES
|
162
|
+
byebug
|
163
|
+
faraday
|
164
|
+
listen (~> 3.3)
|
165
|
+
mocha (~> 1.13.0)
|
166
|
+
puma (~> 5.0)
|
167
|
+
rails (~> 6.1.4)
|
168
|
+
ringu!
|
169
|
+
sqlite3 (~> 1.4)
|
170
|
+
tzinfo-data
|
171
|
+
|
172
|
+
RUBY VERSION
|
173
|
+
ruby 3.0.0p0
|
174
|
+
|
175
|
+
BUNDLED WITH
|
176
|
+
2.2.3
|
data/example/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
data/example/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CharactersFetcher
|
2
|
+
include Container::Inject
|
3
|
+
|
4
|
+
URL = "https://rickandmortyapi.com/api/character"
|
5
|
+
|
6
|
+
inject :http_client
|
7
|
+
inject :characters_parser, CharactersParser
|
8
|
+
|
9
|
+
def fetch
|
10
|
+
response = http_client.get(URL)
|
11
|
+
characters_parser.parse(response.body)
|
12
|
+
end
|
13
|
+
end
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CharactersParser
|
2
|
+
def parse(data)
|
3
|
+
resoponse = JSON.parse(data, symbolize_keys: true)
|
4
|
+
|
5
|
+
return [] if resoponse['results'].blank?
|
6
|
+
|
7
|
+
resoponse['results'].map do |item|
|
8
|
+
{
|
9
|
+
id: item['id'],
|
10
|
+
name: item['name'],
|
11
|
+
image: item['image'],
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/example/bin/bundle
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../../Gemfile", __FILE__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_version
|
64
|
+
@bundler_version ||=
|
65
|
+
env_var_version || cli_arg_version ||
|
66
|
+
lockfile_version
|
67
|
+
end
|
68
|
+
|
69
|
+
def bundler_requirement
|
70
|
+
return "#{Gem::Requirement.default}.a" unless bundler_version
|
71
|
+
|
72
|
+
bundler_gem_version = Gem::Version.new(bundler_version)
|
73
|
+
|
74
|
+
requirement = bundler_gem_version.approximate_recommendation
|
75
|
+
|
76
|
+
return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
|
77
|
+
|
78
|
+
requirement += ".a" if bundler_gem_version.prerelease?
|
79
|
+
|
80
|
+
requirement
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_bundler!
|
84
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
85
|
+
|
86
|
+
activate_bundler
|
87
|
+
end
|
88
|
+
|
89
|
+
def activate_bundler
|
90
|
+
gem_error = activation_error_handling do
|
91
|
+
gem "bundler", bundler_requirement
|
92
|
+
end
|
93
|
+
return if gem_error.nil?
|
94
|
+
require_error = activation_error_handling do
|
95
|
+
require "bundler/version"
|
96
|
+
end
|
97
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
98
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
99
|
+
exit 42
|
100
|
+
end
|
101
|
+
|
102
|
+
def activation_error_handling
|
103
|
+
yield
|
104
|
+
nil
|
105
|
+
rescue StandardError, LoadError => e
|
106
|
+
e
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
m.load_bundler!
|
111
|
+
|
112
|
+
if m.invoked_as_script?
|
113
|
+
load Gem.bin_path("bundler", "bundle")
|
114
|
+
end
|
data/example/bin/rails
ADDED