dry-web-roda 0.10.0 → 0.14.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +179 -41
- data/LICENSE +16 -18
- data/README.md +16 -42
- data/{exe → bin}/dry-web-roda +0 -0
- data/dry-web-roda.gemspec +24 -23
- data/lib/dry/web/roda/generators/abstract_project.rb +2 -2
- data/lib/dry/web/roda/generators/inflections.rb +3 -3
- data/lib/dry/web/roda/generators/sub_app.rb +2 -2
- data/lib/dry/web/roda/inflector.rb +9 -0
- data/lib/dry/web/roda/templates/Gemfile +19 -14
- data/lib/dry/web/roda/templates/README.md.tt +8 -5
- data/lib/dry/web/roda/templates/container.rb.tt +2 -0
- data/lib/dry/web/roda/templates/flat_project/boot.rb.tt +2 -0
- data/lib/dry/web/roda/templates/flat_project/web.rb.tt +3 -1
- data/lib/dry/web/roda/templates/monitor.rb.tt +2 -1
- data/lib/dry/web/roda/templates/subapp/container.rb.tt +3 -3
- data/lib/dry/web/roda/templates/subapp/view.rb.tt +17 -0
- data/lib/dry/web/roda/templates/subapp/view_context.rb.tt +8 -0
- data/lib/dry/web/roda/templates/subapp/web.rb.tt +3 -1
- data/lib/dry/web/roda/templates/subapp/welcome.rb.tt +2 -2
- data/lib/dry/web/roda/templates/types.rb +3 -3
- data/lib/dry/web/roda/templates/umbrella_project/boot.rb.tt +2 -0
- data/lib/dry/web/roda/templates/view.rb.tt +15 -0
- data/lib/dry/web/roda/templates/view_context.rb.tt +31 -0
- data/lib/dry/web/roda/templates/welcome.rb.tt +2 -2
- data/lib/dry/web/roda/version.rb +1 -1
- data/lib/roda/plugins/dry_view.rb +6 -3
- metadata +30 -148
- data/.gitignore +0 -37
- data/.rspec +0 -2
- data/.travis.yml +0 -32
- data/CONTRIBUTING.md +0 -29
- data/Gemfile +0 -33
- data/Rakefile +0 -6
- data/lib/dry/web/roda/templates/.gitignore +0 -11
- data/lib/dry/web/roda/templates/.keep +0 -0
- data/lib/dry/web/roda/templates/.rspec +0 -2
- data/lib/dry/web/roda/templates/subapp/view__context.rb.tt +0 -10
- data/lib/dry/web/roda/templates/subapp/view__controller.rb.tt +0 -19
- data/lib/dry/web/roda/templates/view__context.rb.tt +0 -41
- data/lib/dry/web/roda/templates/view__controller.rb.tt +0 -17
- data/script/ci +0 -67
- data/script/setup +0 -47
- data/script/teardown +0 -42
- data/spec/integration/new_app_spec.rb +0 -21
- data/spec/spec_helper.rb +0 -22
- data/spec/support/app.rb +0 -64
- data/spec/support/bundler.rb +0 -113
- data/spec/support/cli.rb +0 -47
- data/spec/support/directories.rb +0 -37
- data/spec/support/env.rb +0 -84
- data/spec/support/files.rb +0 -59
- data/spec/support/project.rb +0 -60
- data/spec/support/requests.rb +0 -5
- data/spec/support/silently.rb +0 -28
- data/spec/unit/generators/inflections_spec.rb +0 -33
data/spec/support/cli.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require "aruba"
|
2
|
-
require "aruba/api"
|
3
|
-
require "pathname"
|
4
|
-
|
5
|
-
module RSpec
|
6
|
-
module Support
|
7
|
-
module Cli
|
8
|
-
def self.included(spec)
|
9
|
-
spec.before do
|
10
|
-
aruba = Pathname.new(Dir.pwd).join('tmp', 'aruba')
|
11
|
-
aruba.rmtree if aruba.exist?
|
12
|
-
|
13
|
-
setup_aruba
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def run_command(cmd, output = nil, exit_status: 0)
|
20
|
-
run_simple "bundle exec #{cmd}", fail_on_error: false
|
21
|
-
|
22
|
-
match_output(output)
|
23
|
-
expect(last_command_started).to have_exit_status(exit_status)
|
24
|
-
end
|
25
|
-
|
26
|
-
def match_output(output)
|
27
|
-
case output
|
28
|
-
when String
|
29
|
-
expect(all_output).to include(output)
|
30
|
-
when Regexp
|
31
|
-
expect(all_output).to match(output)
|
32
|
-
when Array
|
33
|
-
output.each { |o| match_output(o) }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def all_output
|
38
|
-
all_commands.map(&:output).join("\n")
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
RSpec.configure do |config|
|
45
|
-
config.include Aruba::Api, type: :cli
|
46
|
-
config.include RSpec::Support::Cli, type: :cli
|
47
|
-
end
|
data/spec/support/directories.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require "fileutils"
|
2
|
-
|
3
|
-
module RSpec
|
4
|
-
module Support
|
5
|
-
module Directory
|
6
|
-
private
|
7
|
-
|
8
|
-
def with_directory(directory)
|
9
|
-
current = Dir.pwd
|
10
|
-
target = Pathname.new(Dir.pwd).join(directory)
|
11
|
-
|
12
|
-
Dir.chdir(target)
|
13
|
-
yield
|
14
|
-
ensure
|
15
|
-
Dir.chdir(current)
|
16
|
-
end
|
17
|
-
|
18
|
-
def with_tmp_directory
|
19
|
-
dir = Pathname.new("tmp").join("aruba")
|
20
|
-
|
21
|
-
with_directory(dir) do
|
22
|
-
yield
|
23
|
-
end
|
24
|
-
ensure
|
25
|
-
FileUtils.rm_rf(dir)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
RSpec.configure do |config|
|
32
|
-
config.include RSpec::Support::Directory, type: :cli
|
33
|
-
|
34
|
-
config.before :suite do
|
35
|
-
Pathname.new(Dir.pwd).join("tmp").mkpath
|
36
|
-
end
|
37
|
-
end
|
data/spec/support/env.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
require 'thread'
|
3
|
-
|
4
|
-
module RSpec
|
5
|
-
module Support
|
6
|
-
class Env
|
7
|
-
include Singleton
|
8
|
-
|
9
|
-
def self.setup
|
10
|
-
instance.__send__(:setup)
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.reset
|
14
|
-
instance.__send__(:setup)
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.env
|
18
|
-
instance.to_h
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.[](key)
|
22
|
-
instance[key]
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.[]=(key, value)
|
26
|
-
instance[key] = value
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.fetch_from_original(key)
|
30
|
-
instance.__send__(:original).fetch(key)
|
31
|
-
end
|
32
|
-
|
33
|
-
def initialize
|
34
|
-
@original = ENV.to_hash
|
35
|
-
@mutex = Mutex.new
|
36
|
-
setup
|
37
|
-
end
|
38
|
-
|
39
|
-
def [](key)
|
40
|
-
synchronize do
|
41
|
-
env[key]
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def []=(key, value)
|
46
|
-
synchronize do
|
47
|
-
env[key] = value
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def to_h
|
52
|
-
env.dup
|
53
|
-
end
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
attr_reader :original, :env
|
58
|
-
|
59
|
-
def setup
|
60
|
-
synchronize do
|
61
|
-
@env = {}
|
62
|
-
end
|
63
|
-
|
64
|
-
self["GEM_ROOT"] = original["GEM_ROOT"]
|
65
|
-
self["GEM_HOME"] = original["GEM_HOME"]
|
66
|
-
self["GEM_PATH"] = original["GEM_PATH"]
|
67
|
-
end
|
68
|
-
|
69
|
-
def synchronize(&blk)
|
70
|
-
@mutex.synchronize(&blk)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
RSpec.configure do |config|
|
77
|
-
config.before(:suite) do
|
78
|
-
RSpec::Support::Env.setup
|
79
|
-
end
|
80
|
-
|
81
|
-
config.after do
|
82
|
-
RSpec::Support::Env.reset
|
83
|
-
end
|
84
|
-
end
|
data/spec/support/files.rb
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
module RSpec
|
2
|
-
module Support
|
3
|
-
module Files
|
4
|
-
private
|
5
|
-
|
6
|
-
def write(path, *content)
|
7
|
-
Pathname.new(path).dirname.mkpath
|
8
|
-
open(path, ::File::CREAT | ::File::WRONLY, *content)
|
9
|
-
end
|
10
|
-
|
11
|
-
def rewrite(path, *content)
|
12
|
-
open(path, ::File::TRUNC | ::File::WRONLY, *content)
|
13
|
-
end
|
14
|
-
|
15
|
-
def replace(path, target, replacement)
|
16
|
-
content = ::File.readlines(path)
|
17
|
-
content[index(content, path, target)] = "#{replacement}\n"
|
18
|
-
|
19
|
-
rewrite(path, content)
|
20
|
-
end
|
21
|
-
|
22
|
-
def replace_last(path, target, replacement)
|
23
|
-
content = ::File.readlines(path)
|
24
|
-
content[-index(content.reverse, path, target) - 1] = "#{replacement}\n"
|
25
|
-
|
26
|
-
rewrite(path, content)
|
27
|
-
end
|
28
|
-
|
29
|
-
def unshift(path, line)
|
30
|
-
content = ::File.readlines(path)
|
31
|
-
content.unshift("#{line}\n")
|
32
|
-
|
33
|
-
rewrite(path, content)
|
34
|
-
end
|
35
|
-
|
36
|
-
def append(path, contents)
|
37
|
-
content = ::File.readlines(path)
|
38
|
-
content << "#{contents}\n"
|
39
|
-
|
40
|
-
rewrite(path, content)
|
41
|
-
end
|
42
|
-
|
43
|
-
def open(path, mode, *content)
|
44
|
-
::File.open(path, mode) do |file|
|
45
|
-
file.write(Array(content).flatten.join)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def index(content, path, target)
|
50
|
-
content.index { |l| l.include?(target) } or
|
51
|
-
raise ArgumentError.new("Cannot find `#{target}' inside `#{path}'.")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
RSpec.configure do |config|
|
58
|
-
config.include RSpec::Support::Files, type: :cli
|
59
|
-
end
|
data/spec/support/project.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
require "waitutil"
|
2
|
-
require_relative 'env'
|
3
|
-
require_relative 'silently'
|
4
|
-
require_relative 'bundler'
|
5
|
-
require_relative 'directories'
|
6
|
-
|
7
|
-
module RSpec
|
8
|
-
module Support
|
9
|
-
module Project
|
10
|
-
private
|
11
|
-
|
12
|
-
KNOWN_ARGUMENTS = [:arch].freeze
|
13
|
-
|
14
|
-
def with_project(name = "sandbox", **args)
|
15
|
-
with_tmp_directory do
|
16
|
-
create_project name, args
|
17
|
-
|
18
|
-
within_project_directory(name) do
|
19
|
-
setup_gemfile gems: ["'dry-web-roda', path: '#{root}'"], exclude_gems: ['dry-web-roda']
|
20
|
-
bundle_install
|
21
|
-
yield
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def within_project_directory(project)
|
27
|
-
cd(project.to_s) do
|
28
|
-
# Aruba resets ENV and its API to set new env vars is broken.
|
29
|
-
#
|
30
|
-
# We need to manually setup the following env vars:
|
31
|
-
#
|
32
|
-
# ENV["PATH"] is required by Capybara's selenium/poltergeist drivers
|
33
|
-
ENV["PATH"] = RSpec::Support::Env.fetch_from_original("PATH")
|
34
|
-
# Bundler on CI can't find HOME and it fails to run Hanami commands
|
35
|
-
ENV["HOME"] = RSpec::Support::Env.fetch_from_original("HOME")
|
36
|
-
|
37
|
-
yield
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def create_project(name, args)
|
42
|
-
silently "dry-web-roda new #{name} #{_create_project_args(args)}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def _create_project_args(args)
|
46
|
-
return if args.empty?
|
47
|
-
|
48
|
-
flags = args.dup.keep_if { |k, _| KNOWN_ARGUMENTS.include?(k) }
|
49
|
-
|
50
|
-
flags.map { |arg, value|
|
51
|
-
"--#{arg}=#{value}"
|
52
|
-
}.join(" ")
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
RSpec.configure do |config|
|
59
|
-
config.include RSpec::Support::Project, type: :cli
|
60
|
-
end
|
data/spec/support/requests.rb
DELETED
data/spec/support/silently.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
require "tempfile"
|
2
|
-
|
3
|
-
module RSpec
|
4
|
-
module Support
|
5
|
-
def self.silently(cmd, via: :system)
|
6
|
-
out = Tempfile.new("dry-web-roda-out")
|
7
|
-
# RSpec::Support::Env.env
|
8
|
-
result = ::Kernel.__send__(via, cmd, out: out.path, err: out.path)
|
9
|
-
|
10
|
-
return if result
|
11
|
-
|
12
|
-
out.rewind
|
13
|
-
fail "#{cmd} failed:\n#{out.read}" # rubocop:disable Style/SignalException
|
14
|
-
end
|
15
|
-
|
16
|
-
module Silently
|
17
|
-
private
|
18
|
-
|
19
|
-
def silently(*args)
|
20
|
-
Support.silently(*args)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
RSpec.configure do |config|
|
27
|
-
config.include RSpec::Support::Silently, type: :cli
|
28
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require "dry/web/roda/generators/inflections"
|
2
|
-
|
3
|
-
RSpec.describe Dry::Web::Roda::Generators::Inflections do
|
4
|
-
subject(:inflections) { described_class }
|
5
|
-
|
6
|
-
describe ".underscored_name" do
|
7
|
-
it "leaves an already underscored name" do
|
8
|
-
expect(inflections.underscored_name("my_app")).to eq "my_app"
|
9
|
-
end
|
10
|
-
|
11
|
-
it "leaves a name without any sort of delimiters" do
|
12
|
-
expect(inflections.underscored_name("myapp")).to eq "myapp"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "converts a dashed name" do
|
16
|
-
expect(inflections.underscored_name("my-app")).to eq "my_app"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ".camel_cased_name" do
|
21
|
-
it "leaves an already camel cased name" do
|
22
|
-
expect(inflections.camel_cased_name("MyApp")).to eq "MyApp"
|
23
|
-
end
|
24
|
-
|
25
|
-
it "converts a dashed name" do
|
26
|
-
expect(inflections.camel_cased_name("my-app")).to eq "MyApp"
|
27
|
-
end
|
28
|
-
|
29
|
-
it "converts an underscored name" do
|
30
|
-
expect(inflections.camel_cased_name("my_app")).to eq "MyApp"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|