lurker 0.6.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.hound.yml +4 -78
- data/.jshintrc +33 -0
- data/.rspec +1 -2
- data/.rubocop.yml +0 -1
- data/.travis.yml +30 -19
- data/Gemfile +0 -33
- data/README.md +32 -53
- data/Rakefile +3 -3
- data/cucumber.yml +1 -2
- data/features/atom_persistent_within_the_same_type.feature +4 -4
- data/features/controller_nested_schema_scaffolding.feature +7 -10
- data/features/controller_schema_scaffolding.feature +1 -3
- data/features/dereferencing_through_inlining.feature +1 -3
- data/features/html_generation.feature +26 -4
- data/features/minitest.feature +3 -8
- data/features/multidomain_support.feature +6 -10
- data/features/multitype_request_support.feature +1 -3
- data/features/partials.feature +3 -8
- data/features/request_nested_schema_scaffolding.feature +0 -2
- data/features/request_schema_scaffolding.feature +0 -2
- data/features/schema_suffixes.feature +2 -18
- data/features/schema_updating_within_test_suite.feature +2 -6
- data/features/step_definitions/additional_cli_steps.rb +16 -12
- data/features/support/env.rb +50 -10
- data/features/test_endpoint.feature +2 -9
- data/gemfiles/rails_4.gemfile +14 -0
- data/gemfiles/rails_5.gemfile +10 -0
- data/gemfiles/rails_6.gemfile +10 -0
- data/lib/lurker.rb +9 -2
- data/lib/lurker/cli.rb +148 -128
- data/lib/lurker/endpoint.rb +11 -7
- data/lib/lurker/form_builder.rb +22 -31
- data/lib/lurker/json/concerns/validatable.rb +5 -1
- data/lib/lurker/json/parser.rb +1 -1
- data/lib/lurker/json/schema.rb +19 -6
- data/lib/lurker/json/{writter.rb → writer.rb} +2 -2
- data/lib/lurker/presenters/base_presenter.rb +10 -34
- data/lib/lurker/presenters/endpoint_presenter.rb +19 -8
- data/lib/lurker/presenters/schema_presenter.rb +6 -5
- data/lib/lurker/presenters/service_presenter.rb +41 -7
- data/lib/lurker/rendering_controller.rb +14 -7
- data/lib/lurker/service.rb +27 -11
- data/lib/lurker/spec_helper/rspec.rb +0 -4
- data/lib/lurker/spy.rb +3 -1
- data/lib/lurker/templates/documentation.md.tt +1 -0
- data/lib/lurker/templates/javascripts/lurker.js +133 -91
- data/lib/lurker/templates/layouts/_sidemenu.html.erb +2 -2
- data/lib/lurker/templates/layouts/application.html.erb +54 -57
- data/lib/lurker/templates/layouts/print.html.erb +31 -0
- data/lib/lurker/templates/lurker/rendering/_endpoint.html.erb +37 -0
- data/lib/lurker/templates/lurker/rendering/_param_form_element.html.erb +1 -1
- data/lib/lurker/templates/lurker/rendering/_service.html.erb +7 -0
- data/lib/lurker/templates/lurker/rendering/_submit_form.html.erb +77 -73
- data/lib/lurker/templates/lurker/rendering/all.html.erb +5 -0
- data/lib/lurker/templates/lurker/rendering/index.html.erb +1 -10
- data/lib/lurker/templates/lurker/rendering/show.html.erb +1 -37
- data/lib/lurker/templates/public/application.css +6 -2
- data/lib/lurker/templates/public/application.js +13 -13
- data/lib/lurker/templates/stylesheets/application.scss +3 -0
- data/lib/lurker/version.rb +1 -1
- data/lurker.gemspec +31 -33
- data/spec/spec_helper.rb +0 -1
- data/tasks/build.rake +12 -8
- data/tasks/generate.rake +44 -17
- data/templates/Dockerfile +26 -0
- data/templates/generate_stuff.rb +59 -26
- data/templates/lurker_app.rb +27 -48
- data/templates/rails4_ruby26_thread_error_fix.rb +20 -0
- metadata +149 -106
- checksums.yaml.gz.sig +0 -2
- data.tar.gz.sig +0 -3
- data/Appraisals +0 -20
- data/gemfiles/rails_32.gemfile +0 -27
- data/gemfiles/rails_40.gemfile +0 -27
- data/gemfiles/rails_41.gemfile +0 -27
- data/gemfiles/rails_42.gemfile +0 -27
- data/lib/lurker/templates/lurker/rendering/_param_form_legend.html.erb +0 -1
- data/lib/lurker/templates/meta_service.md.erb +0 -20
- data/lib/lurker/validation_error.rb +0 -4
- data/templates/rails32_http_patch_support.rb +0 -125
- metadata.gz.sig +0 -0
data/spec/spec_helper.rb
CHANGED
@@ -15,7 +15,6 @@ end
|
|
15
15
|
Dir[File.expand_path '../support/**/*.rb', __FILE__].each { |file| require file }
|
16
16
|
|
17
17
|
RSpec.configure do |config|
|
18
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
19
18
|
config.run_all_when_everything_filtered = true
|
20
19
|
config.filter_run :focus
|
21
20
|
config.order = 'random'
|
data/tasks/build.rake
CHANGED
@@ -8,13 +8,13 @@ namespace :assets do
|
|
8
8
|
require 'lurker/cli'
|
9
9
|
|
10
10
|
require 'sprockets'
|
11
|
-
require 'sass'
|
11
|
+
require 'sass-rails'
|
12
12
|
|
13
13
|
ROOT = Pathname(File.dirname(__FILE__))
|
14
14
|
LOGGER = Logger.new(STDOUT)
|
15
15
|
BUNDLES = %w( application.css application.js )
|
16
|
-
BUILD_DIR =
|
17
|
-
SOURCE_DIR =
|
16
|
+
BUILD_DIR = Lurker::Cli.assets_root
|
17
|
+
SOURCE_DIR = Lurker::Cli.templates_root
|
18
18
|
|
19
19
|
FileUtils.rm_rf(BUILD_DIR)
|
20
20
|
FileUtils.mkdir_p(BUILD_DIR)
|
@@ -38,8 +38,10 @@ namespace :assets do
|
|
38
38
|
sprockets.append_path(SOURCE_DIR.join('stylesheets').to_s)
|
39
39
|
|
40
40
|
%w[jquery-rails bootstrap-sass remotipart lurker].each do |gem|
|
41
|
-
|
42
|
-
|
41
|
+
bundler_gem = Bundler.rubygems.find_name(gem).first
|
42
|
+
raise "Gem #{gem.inspect} is required in #{ENV.fetch('BUNDLE_GEMFILE', 'Gemfile')}" unless bundler_gem
|
43
|
+
gem_path = Pathname.new(bundler_gem.full_gem_path)
|
44
|
+
%w[javascripts stylesheets fonts].each do |prefix|
|
43
45
|
%w[assets vendor/assets lib/lurker/templates].each do |interfix|
|
44
46
|
path = gem_path.join(interfix, prefix).to_s
|
45
47
|
sprockets.append_path(path) if File.exists? path
|
@@ -47,12 +49,14 @@ namespace :assets do
|
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
+
unless ENV['CI']
|
53
|
+
sprockets.js_compressor = :uglify
|
54
|
+
sprockets.css_compressor = :scss
|
55
|
+
end
|
52
56
|
|
53
57
|
BUNDLES.each do |bundle|
|
54
58
|
assets = sprockets.find_asset(bundle)
|
55
|
-
realname = (assets.
|
59
|
+
realname = (Pathname.new(assets.filename).basename.to_s.split(".").take_while { |s| !s.match /^(js|css|scss)$/ } + [$~.to_s]).join(".").gsub(/\.scss$/, '.css')
|
56
60
|
assets.write_to(BUILD_DIR.join(realname))
|
57
61
|
end
|
58
62
|
end
|
data/tasks/generate.rake
CHANGED
@@ -1,7 +1,15 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
def rails_version
|
2
|
+
if (version = ENV['BUNDLE_GEMFILE'].to_s.match(/rails_([\d\.]+).gemfile/)&.to_a&.last)
|
3
|
+
Gem::Version.new(version)
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
if rails_version
|
8
|
+
EXAMPLE_APP = "tmp/lurker_app_rails_#{rails_version}"
|
9
|
+
TEMPLATE_TASK = rails_version >= Gem::Version.new('5.0') ? 'app:template' : 'rails:template'
|
10
|
+
TASK_RUNNER = rails_version >= Gem::Version.new('5.0') ? 'bin/rails' : 'bin/rake'
|
3
11
|
else
|
4
|
-
raise "
|
12
|
+
raise "Export BUNDLE_GEMFILE=gemfiles/rails_... explicitly"
|
5
13
|
end
|
6
14
|
|
7
15
|
EXAMPLE_PATH = File.expand_path("../../#{EXAMPLE_APP}", __FILE__)
|
@@ -30,30 +38,33 @@ namespace :generate do
|
|
30
38
|
task :app do |t|
|
31
39
|
if needs_generation?
|
32
40
|
sh "bundle exec rails new #{EXAMPLE_APP} -d postgresql -m #{File.expand_path '../../templates/lurker_app.rb', __FILE__} --skip-javascript --skip-git --skip-test-unit --skip-keeps --skip-bundle --quiet"
|
33
|
-
in_lurker_app "bundle config --local local.lurker $PWD/../.." unless ENV['
|
34
|
-
in_lurker_app "bundle
|
35
|
-
|
36
|
-
|
41
|
+
in_lurker_app "bundle config --local local.lurker $PWD/../.." unless ENV['CI']
|
42
|
+
in_lurker_app "bundle config --local set without 'development'"
|
43
|
+
in_lurker_app "bundle install"
|
44
|
+
%w[rake rspec-core spring bundler].each do |gem|
|
45
|
+
in_lurker_app "bundle binstubs #{gem} --force"
|
37
46
|
end
|
38
47
|
end
|
39
48
|
end
|
40
49
|
|
41
50
|
desc "generate a bunch of stuff with generators"
|
42
51
|
task :stuff do
|
43
|
-
in_lurker_app "LOCATION='../../templates/generate_stuff.rb'
|
52
|
+
in_lurker_app "LOCATION='../../templates/generate_stuff.rb' #{TASK_RUNNER} #{TEMPLATE_TASK}"
|
44
53
|
|
45
|
-
|
46
|
-
in_lurker_app
|
47
|
-
|
54
|
+
if ENV['CI']
|
55
|
+
in_lurker_app "#{TASK_RUNNER} RAILS_ENV=test db:setup "
|
56
|
+
else
|
57
|
+
in_lurker_app "#{TASK_RUNNER} db:setup"
|
58
|
+
in_lurker_app "#{TASK_RUNNER} db:import"
|
48
59
|
end
|
49
|
-
in_lurker_app 'bin/rake RAILS_ENV=test db:setup'
|
50
60
|
end
|
51
61
|
end
|
52
62
|
|
53
63
|
def in_lurker_app(command)
|
54
64
|
FileUtils.mkdir_p(EXAMPLE_PATH)
|
55
65
|
Dir.chdir(EXAMPLE_PATH) do
|
56
|
-
Bundler.with_clean_env
|
66
|
+
bundler_method = Bundler.respond_to?(:with_unbundled_env) ? :with_unbundled_env : :with_clean_env
|
67
|
+
Bundler.send(bundler_method) do
|
57
68
|
sh command
|
58
69
|
end
|
59
70
|
end
|
@@ -63,23 +74,39 @@ def needs_generation?
|
|
63
74
|
!File.exists?("#{EXAMPLE_PATH}/Gemfile")
|
64
75
|
end
|
65
76
|
|
77
|
+
def place_github_badge(fname)
|
78
|
+
full_fname = "#{EXAMPLE_PATH}/#{fname}"
|
79
|
+
content = File.read(full_fname).gsub("</header>", <<-EOF
|
80
|
+
</header>
|
81
|
+
<a href='https://github.com/razum2um/lurker'>
|
82
|
+
<img style='position: absolute; top: 0; right: 0; border: 0; z-index: 1000'
|
83
|
+
src="https://camo.githubusercontent.com/365986a132ccd6a44c23a9169022c0b5c890c387/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67"
|
84
|
+
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"
|
85
|
+
alt='Fork me on GitHub'>
|
86
|
+
</a>
|
87
|
+
EOF
|
88
|
+
)
|
89
|
+
File.open(full_fname, 'w') { |f| f.write content }
|
90
|
+
end
|
91
|
+
|
66
92
|
desc 'destroys & recreates new test app'
|
67
|
-
task :regenerate => ["clobber:coverage", "clobber:app", "generate:app", "generate:stuff"]
|
93
|
+
task :regenerate => ["clobber:coverage", "clobber:app", "assets:precompile", "generate:app", "generate:stuff"]
|
68
94
|
|
69
95
|
desc 'run cucumber in a fresh env'
|
70
96
|
task :features => [:regenerate, :cucumber]
|
71
97
|
|
72
98
|
desc 'convert docs for example app, prepages gh-pages, having schemas in /lurker'
|
73
99
|
task :convert_example_docs do
|
100
|
+
in_lurker_app "bin/lurker init_docs"
|
101
|
+
|
74
102
|
if File.exists?(readme = File.expand_path('../../README.md', __FILE__))
|
75
103
|
in_lurker_app "bin/lurker convert -c #{readme}"
|
76
104
|
else
|
77
105
|
in_lurker_app "bin/lurker convert"
|
78
106
|
end
|
79
107
|
|
80
|
-
|
81
|
-
in_lurker_app "bin/lurker convert -f pdf"
|
108
|
+
place_github_badge 'public/lurker/index.html'
|
109
|
+
# in_lurker_app "bin/lurker convert -f pdf"
|
82
110
|
end
|
83
111
|
|
84
112
|
task :build_example_docs => [:features, :convert_example_docs]
|
85
|
-
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# cd tmp/lurker_app_*, run with
|
2
|
+
# docker run -e DATABASE_URL=postgres://user@host.docker.internal/lurker_app_rails_6 -p 3000:3000 lurker"
|
3
|
+
FROM ruby:2.7-alpine as build
|
4
|
+
|
5
|
+
WORKDIR /app
|
6
|
+
|
7
|
+
RUN apk add git postgresql-dev libpq
|
8
|
+
|
9
|
+
COPY Gemfile* ./
|
10
|
+
|
11
|
+
RUN apk add --no-cache --update alpine-sdk make && \
|
12
|
+
bundler config set without 'development test' && \
|
13
|
+
bundler config set path 'vendor/bundle' && \
|
14
|
+
bundler install
|
15
|
+
|
16
|
+
COPY . ./
|
17
|
+
|
18
|
+
EXPOSE 3000
|
19
|
+
|
20
|
+
ENV PATH "$PATH:/app/vendor/bundle/ruby/2.7.0/bin"
|
21
|
+
ENV GEM_HOME "/app/vendor/bundle/ruby/2.7.0"
|
22
|
+
ENV RAILS_ENV "production"
|
23
|
+
ENV RAILS_SERVE_STATIC_FILES "1"
|
24
|
+
ENV RAILS_LOG_TO_STDOUT "1"
|
25
|
+
|
26
|
+
CMD ["bin/rails", "s", "-b", "0.0.0.0"]
|
data/templates/generate_stuff.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# This is secondary testing/demo rails app template (passed to `rake rails:template`)
|
2
|
-
|
3
|
-
if rails_version = ENV['BUNDLE_GEMFILE'].to_s.match(/rails_\d\d/)
|
2
|
+
if rails_version = ENV['BUNDLE_GEMFILE'].to_s.match(/rails_\d+/)
|
4
3
|
base_db_name = "lurker_app_#{rails_version}"
|
5
4
|
else
|
6
5
|
base_db_name = 'lurker_app'
|
7
6
|
end
|
8
7
|
|
9
8
|
file 'config/database.yml', force: true do
|
10
|
-
|
9
|
+
<<~CODE
|
11
10
|
default: &default
|
12
11
|
adapter: postgresql
|
13
12
|
encoding: unicode
|
@@ -25,7 +24,7 @@ end
|
|
25
24
|
|
26
25
|
copy_file "#{File.expand_path '../../bin/lurker', __FILE__}", "bin/lurker"
|
27
26
|
inject_into_file "bin/lurker", before: /require .lurker.$/ do
|
28
|
-
|
27
|
+
<<~CODE
|
29
28
|
if (simplecov_root = ENV['SIMPLECOV_ROOT']) && (simplecov_cmdname = ENV['SIMPLECOV_CMDNAME'])
|
30
29
|
require 'simplecov'
|
31
30
|
SimpleCov.start
|
@@ -50,7 +49,7 @@ remove_file 'app/models/user.rb'
|
|
50
49
|
|
51
50
|
generate 'rspec:install'
|
52
51
|
|
53
|
-
route
|
52
|
+
route <<~ROUTE
|
54
53
|
namespace :api do
|
55
54
|
namespace :v1 do
|
56
55
|
resources :users do
|
@@ -86,7 +85,7 @@ generate 'model User name:string surname:string --no-timestamps --no-test-framew
|
|
86
85
|
generate 'model Repo user:references name:string --no-timestamps --no-test-framework --no-migration'
|
87
86
|
|
88
87
|
file 'config/initializers/serializer.rb', force: true do
|
89
|
-
|
88
|
+
<<~CODE
|
90
89
|
module ExactOrderAsJson
|
91
90
|
# we need EXACT order for json attributes generation (e.g. rails32 sorts it)
|
92
91
|
# see: https://github.com/rails/rails/pull/5678/files
|
@@ -109,10 +108,8 @@ file 'config/initializers/serializer.rb', force: true do
|
|
109
108
|
CODE
|
110
109
|
end
|
111
110
|
|
112
|
-
copy_file "#{File.expand_path '../../templates/rails32_http_patch_support.rb', __FILE__}", "config/initializers/rails32_http_patch_support.rb"
|
113
|
-
|
114
111
|
inject_into_class 'app/models/user.rb', 'User' do
|
115
|
-
|
112
|
+
<<~CODE
|
116
113
|
include ExactOrderAsJson
|
117
114
|
has_many :repos
|
118
115
|
validates :name, presence: true
|
@@ -124,17 +121,17 @@ inject_into_class 'app/models/user.rb', 'User' do
|
|
124
121
|
end
|
125
122
|
|
126
123
|
inject_into_class 'app/models/repo.rb', 'Repo' do
|
127
|
-
|
124
|
+
<<~CODE
|
128
125
|
include ExactOrderAsJson
|
129
126
|
validates :name, presence: true
|
130
127
|
CODE
|
131
128
|
end
|
132
129
|
|
133
130
|
file 'app/controllers/application_controller.rb', 'ApplicationController', force: true do
|
134
|
-
|
131
|
+
<<~CODE
|
135
132
|
class ApplicationController < ActionController::Base
|
136
133
|
protect_from_forgery with: :null_session
|
137
|
-
|
134
|
+
before_action :set_format
|
138
135
|
|
139
136
|
private
|
140
137
|
|
@@ -154,7 +151,7 @@ file 'app/controllers/application_controller.rb', 'ApplicationController', force
|
|
154
151
|
end
|
155
152
|
|
156
153
|
file 'app/controllers/api/v1/users_controller.rb', 'Api::V1::UsersController', force: true do
|
157
|
-
|
154
|
+
<<~CODE
|
158
155
|
class Api::V1::UsersController < ApplicationController
|
159
156
|
def index
|
160
157
|
@users = scoped(User)
|
@@ -174,7 +171,7 @@ file 'app/controllers/api/v1/users_controller.rb', 'Api::V1::UsersController', f
|
|
174
171
|
end
|
175
172
|
|
176
173
|
def update
|
177
|
-
if user.
|
174
|
+
if user.update(user_params)
|
178
175
|
render json: user
|
179
176
|
else
|
180
177
|
render json: { errors: user.errors }, status: :bad_request
|
@@ -209,7 +206,7 @@ file 'app/controllers/api/v1/users_controller.rb', 'Api::V1::UsersController', f
|
|
209
206
|
end
|
210
207
|
|
211
208
|
file 'app/controllers/api/v1/repos_controller.rb', 'Api::V1::ReposController', force: true do
|
212
|
-
|
209
|
+
<<~CODE
|
213
210
|
class Api::V1::ReposController < ApplicationController
|
214
211
|
|
215
212
|
def index
|
@@ -235,7 +232,7 @@ file 'app/controllers/api/v1/repos_controller.rb', 'Api::V1::ReposController', f
|
|
235
232
|
|
236
233
|
def update
|
237
234
|
@repo = repo
|
238
|
-
if @repo.
|
235
|
+
if @repo.update(repo_params)
|
239
236
|
render json: @repo
|
240
237
|
else
|
241
238
|
render json: { errors: @repo.errors }, status: :bad_request
|
@@ -272,13 +269,13 @@ end
|
|
272
269
|
|
273
270
|
[2, 3].each do |version|
|
274
271
|
file "app/controllers/api/v#{version}/users_controller.rb", "Api::V#{version}::UsersController", force: true do
|
275
|
-
|
272
|
+
<<~CODE
|
276
273
|
class Api::V#{version}::UsersController < Api::V1::UsersController; end
|
277
274
|
CODE
|
278
275
|
end
|
279
276
|
|
280
277
|
file "app/controllers/api/v#{version}/repos_controller.rb", "Api::V#{version}::ReposController", force: true do
|
281
|
-
|
278
|
+
<<~CODE
|
282
279
|
class Api::V#{version}::ReposController < Api::V1::ReposController; end
|
283
280
|
CODE
|
284
281
|
end
|
@@ -286,19 +283,19 @@ end
|
|
286
283
|
|
287
284
|
# FIXME: uninitialized constant User (NameError) in last creation line
|
288
285
|
append_to_file 'config/environment.rb' do
|
289
|
-
|
286
|
+
<<~CODE
|
290
287
|
$:.unshift File.expand_path('../../app/models', __FILE__)
|
291
288
|
CODE
|
292
289
|
end
|
293
290
|
|
294
291
|
inject_into_class 'config/application.rb', 'Application' do
|
295
|
-
|
292
|
+
<<~CODE
|
296
293
|
if ENV['DATABASE_URL'].present? # heroku
|
297
294
|
config.middleware.use Lurker::Sandbox
|
298
295
|
end
|
299
296
|
|
300
297
|
require 'rack/cors' # FIXME
|
301
|
-
config.middleware.insert 0,
|
298
|
+
config.middleware.insert 0, Rack::Cors do
|
302
299
|
allow do
|
303
300
|
origins %w[localhost:3000 127.0.0.1:3000 razum2um.github.io lurker-app.herokuapp.com lurker.razum2um.me]
|
304
301
|
resource '*',
|
@@ -314,7 +311,7 @@ inject_into_class 'config/application.rb', 'Application' do
|
|
314
311
|
end
|
315
312
|
|
316
313
|
file 'test/test_helper.rb', force: true do
|
317
|
-
|
314
|
+
<<~CODE
|
318
315
|
ENV['RAILS_ENV'] ||= 'test'
|
319
316
|
require File.expand_path('../../config/environment', __FILE__)
|
320
317
|
require 'rails/test_help'
|
@@ -338,9 +335,16 @@ file 'test/test_helper.rb', force: true do
|
|
338
335
|
end
|
339
336
|
|
340
337
|
file 'spec/support/fixme.rb', force: true do
|
341
|
-
|
338
|
+
<<~CODE
|
342
339
|
require 'simplecov'
|
343
340
|
|
341
|
+
module ActionDispatchTestResponseCompat
|
342
|
+
def success?
|
343
|
+
status == 200
|
344
|
+
end
|
345
|
+
end
|
346
|
+
ActionDispatch::TestResponse.include(ActionDispatchTestResponseCompat)
|
347
|
+
|
344
348
|
if simplecov_root = ENV['SIMPLECOV_ROOT']
|
345
349
|
SimpleCov.root simplecov_root
|
346
350
|
end
|
@@ -362,7 +366,6 @@ file 'spec/support/fixme.rb', force: true do
|
|
362
366
|
|
363
367
|
RSpec.configure do |c|
|
364
368
|
c.infer_spec_type_from_file_location! if c.respond_to?(:infer_spec_type_from_file_location!)
|
365
|
-
c.treat_symbols_as_metadata_keys_with_true_values = true
|
366
369
|
c.backtrace_exclusion_patterns += [
|
367
370
|
/\\/lib\\/lurker/
|
368
371
|
]
|
@@ -385,7 +388,7 @@ file 'spec/support/fixme.rb', force: true do
|
|
385
388
|
end
|
386
389
|
|
387
390
|
file 'lib/tasks/db.rake', force: true do
|
388
|
-
|
391
|
+
<<~CODE
|
389
392
|
namespace :db do
|
390
393
|
desc 'fills in data'
|
391
394
|
task :import => :environment do
|
@@ -398,7 +401,7 @@ file 'lib/tasks/db.rake', force: true do
|
|
398
401
|
end
|
399
402
|
|
400
403
|
file 'db/schema.rb', force: true do
|
401
|
-
|
404
|
+
<<~CODE
|
402
405
|
ActiveRecord::Schema.define do
|
403
406
|
create_table "repos", :force => true do |t|
|
404
407
|
t.integer "user_id"
|
@@ -415,3 +418,33 @@ file 'db/schema.rb', force: true do
|
|
415
418
|
CODE
|
416
419
|
end
|
417
420
|
|
421
|
+
append_to_file 'spec/rails_helper.rb' do
|
422
|
+
<<~CODE
|
423
|
+
Dir[File.expand_path '../support/**/*.rb', __FILE__].each { |file| require file }
|
424
|
+
|
425
|
+
if Gem::Version.new(Rails.version) < Gem::Version.new('5.0.0')
|
426
|
+
require 'rails/forward_compatible_controller_tests'
|
427
|
+
RSpec.configure do |config|
|
428
|
+
config.include Rails::ForwardCompatibleControllerTests, type: :controller
|
429
|
+
config.include Rails::ForwardCompatibleControllerTests, type: :request
|
430
|
+
end
|
431
|
+
end
|
432
|
+
CODE
|
433
|
+
end
|
434
|
+
|
435
|
+
append_to_file '.rspec' do
|
436
|
+
<<~CODE
|
437
|
+
--require rails_helper
|
438
|
+
CODE
|
439
|
+
end
|
440
|
+
|
441
|
+
copy_file "#{File.expand_path '../../templates/Dockerfile', __FILE__}", "Dockerfile"
|
442
|
+
|
443
|
+
# rails-4 requires this
|
444
|
+
file 'app/assets/config/manifest.js', force: true do
|
445
|
+
<<~CODE
|
446
|
+
// empty
|
447
|
+
CODE
|
448
|
+
end
|
449
|
+
|
450
|
+
copy_file "#{File.expand_path '../../templates/rails4_ruby26_thread_error_fix.rb', __FILE__}", "spec/support/rails4_ruby26_thread_error_fix.rb"
|
data/templates/lurker_app.rb
CHANGED
@@ -1,38 +1,37 @@
|
|
1
1
|
# This is initial testing/demo rails app template (passed to `rails new`)
|
2
2
|
|
3
3
|
gem 'rack-cors', require: 'rack/cors'
|
4
|
-
gem 'rspec-rails',
|
5
|
-
gem 'spring-commands-rspec'
|
6
|
-
gem 'database_cleaner'
|
4
|
+
gem 'rspec-rails', group: [:development, :test]
|
5
|
+
gem 'spring-commands-rspec', group: [:development, :test]
|
6
|
+
gem 'database_cleaner', group: [:development, :test]
|
7
7
|
gem 'simplecov', '~> 0.7.1', require: false
|
8
|
-
gem 'kramdown', '~> 1.3'
|
9
|
-
gem 'pdfkit', '~> 0.5'
|
10
|
-
gem 'wkhtmltopdf-binary', '~> 0.9'
|
11
|
-
gem 'execjs'
|
12
|
-
gem 'coderay'
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
gem 'pry-debugger', group: [:development, :test]
|
19
|
-
end
|
20
|
-
gem 'pry-stack_explorer', group: [:development, :test]
|
8
|
+
gem 'kramdown', '~> 1.3', group: [:development, :test]
|
9
|
+
gem 'pdfkit', '~> 0.5', group: [:development, :test]
|
10
|
+
gem 'wkhtmltopdf-binary', '~> 0.9', group: [:development, :test]
|
11
|
+
gem 'execjs', group: [:development, :test]
|
12
|
+
gem 'coderay', group: [:development, :test]
|
13
|
+
|
14
|
+
# only for rails-4
|
15
|
+
version = ENV['BUNDLE_GEMFILE'].to_s.match(/rails_([\d\.]+).gemfile/)&.to_a&.last
|
16
|
+
if version && (Gem::Version.new(version) < Gem::Version.new('5'))
|
17
|
+
gem 'rails-forward_compatible_controller_tests', group: [:development, :test], require: false
|
21
18
|
end
|
22
19
|
|
23
|
-
|
24
|
-
gem '
|
20
|
+
unless ENV['CI']
|
21
|
+
gem 'pry-byebug', group: [:development, :test]
|
22
|
+
end
|
25
23
|
|
26
24
|
append_to_file 'Gemfile' do
|
27
|
-
gem = if ENV['
|
28
|
-
|
25
|
+
gem = if ENV['CI']
|
26
|
+
branch = ENV['TRAVIS_BRANCH'] || %x[git branch --show-current]
|
27
|
+
"gem 'lurker', github: 'razum2um/lurker', branch: '#{branch.strip}'"
|
29
28
|
else
|
30
29
|
origin = `cd ../.. && git config --get remote.origin.url`.scan(/github\.com.(.*).git/).flatten.first.strip rescue 'razum2um/lurker'
|
31
30
|
branch = `cd ../.. && git rev-parse --abbrev-ref HEAD`.strip rescue 'master'
|
32
31
|
"gem 'lurker', github: '#{origin}', branch: '#{branch}'"
|
33
32
|
end
|
34
33
|
|
35
|
-
|
34
|
+
<<~CODE
|
36
35
|
|
37
36
|
# new line above is important, branch is also important
|
38
37
|
# please, dont commit here: "gem 'lurker', path: '../../'"
|
@@ -41,34 +40,14 @@ append_to_file 'Gemfile' do
|
|
41
40
|
CODE
|
42
41
|
end
|
43
42
|
|
44
|
-
file 'config/unicorn.rb' do
|
45
|
-
<<-CODE
|
46
|
-
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
|
47
|
-
timeout 15
|
48
|
-
preload_app true
|
49
|
-
|
50
|
-
before_fork do |server, worker|
|
51
|
-
Signal.trap 'TERM' do
|
52
|
-
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
|
53
|
-
Process.kill 'QUIT', Process.pid
|
54
|
-
end
|
55
|
-
|
56
|
-
defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect!
|
57
|
-
end
|
58
|
-
|
59
|
-
after_fork do |server, worker|
|
60
|
-
Signal.trap 'TERM' do
|
61
|
-
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
|
62
|
-
end
|
63
|
-
|
64
|
-
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
|
65
|
-
end
|
66
|
-
CODE
|
67
|
-
end
|
68
|
-
|
69
43
|
file 'Procfile' do
|
70
|
-
|
71
|
-
web: bundle exec
|
44
|
+
<<~CODE
|
45
|
+
web: bundle exec puma -p $PORT
|
72
46
|
CODE
|
73
47
|
end
|
74
48
|
|
49
|
+
# docker needs with for mri too
|
50
|
+
gsub_file('Gemfile', /gem.*tzinfo-data.*/, 'gem "tzinfo-data"')
|
51
|
+
|
52
|
+
# pg 0.21 with rails-4 has too much warnings
|
53
|
+
gsub_file('Gemfile', "gem 'pg', '~> 0.15'", "gem 'pg', '<= 0.20'")
|