hexx 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -1
- data/README.rdoc +77 -181
- data/Rakefile +7 -21
- data/lib/hexx/models/base_coercer.rb +36 -0
- data/lib/hexx/models.rb +12 -57
- data/lib/hexx/service/invalid.rb +48 -0
- data/lib/hexx/service/message.rb +57 -0
- data/lib/hexx/service/messages.rb +34 -0
- data/lib/hexx/service/parameters.rb +45 -0
- data/lib/hexx/service/transactions.rb +30 -0
- data/lib/hexx/service/validations.rb +18 -0
- data/lib/hexx/service.rb +21 -0
- data/lib/hexx/version.rb +2 -2
- data/lib/hexx.rb +8 -2
- data/spec/hexx/models_spec.rb +6 -9
- data/spec/hexx/service/invalid_spec.rb +51 -0
- data/spec/hexx/service/message_spec.rb +99 -0
- data/spec/hexx/service_spec.rb +183 -0
- data/spec/{support/initializers → initializers}/coveralls.rb +0 -0
- data/spec/{support/initializers → initializers}/focus.rb +0 -0
- data/spec/{support/initializers → initializers}/garbage_collection.rb +0 -0
- data/spec/{support/initializers → initializers}/i18n.rb +2 -0
- data/spec/{support/initializers → initializers}/random_order.rb +0 -0
- data/spec/{support/initializers → initializers}/rspec.rb +0 -0
- data/spec/spec_helper.rb +3 -5
- metadata +31 -117
- data/CHANGELOG.rdoc +0 -12
- data/bin/hexx +0 -54
- data/lib/generators/base.rb +0 -59
- data/lib/generators/controller/controller.rb +0 -114
- data/lib/generators/controller/templates/controller.erb +0 -10
- data/lib/generators/controller/templates/controller_action.erb +0 -7
- data/lib/generators/controller/templates/controller_action_spec.erb +0 -21
- data/lib/generators/controller/templates/controller_spec.erb +0 -20
- data/lib/generators/controller/templates/responder_controller.erb +0 -40
- data/lib/generators/controller/templates/responder_controller_spec.erb +0 -65
- data/lib/generators/controller/templates/routing_action_spec.erb +0 -13
- data/lib/generators/controller/templates/routing_spec.erb +0 -11
- data/lib/generators/controller/templates/views_errors.erb +0 -3
- data/lib/generators/controller/templates/views_messages.erb +0 -3
- data/lib/generators/dependency/dependency.rb +0 -50
- data/lib/generators/dependency/templates/dependency_setting.erb +0 -4
- data/lib/generators/dependency/templates/dependency_setting_spec.erb +0 -39
- data/lib/generators/dependency/templates/initializer.erb +0 -4
- data/lib/generators/dependency/templates/initializer_setting.erb +0 -4
- data/lib/generators/dependency/templates/module_spec.erb +0 -22
- data/lib/generators/domain/domain.rb +0 -24
- data/lib/generators/domain/templates/spec.erb +0 -84
- data/lib/generators/install/install.rb +0 -133
- data/lib/generators/install/templates/bin/rails.erb +0 -11
- data/lib/generators/install/templates/config/routes.erb +0 -6
- data/lib/generators/install/templates/json_schemas/error.erb +0 -14
- data/lib/generators/install/templates/json_schemas/get_errors.erb +0 -18
- data/lib/generators/install/templates/json_schemas/success.erb +0 -14
- data/lib/generators/install/templates/lib/engine.erb +0 -12
- data/lib/generators/install/templates/lib/lib.erb +0 -10
- data/lib/generators/install/templates/lib/task.erb +0 -60
- data/lib/generators/install/templates/lib/version.erb +0 -4
- data/lib/generators/install/templates/matchers/controllers.erb +0 -14
- data/lib/generators/install/templates/matchers/json_schema.erb +0 -10
- data/lib/generators/install/templates/root/Gemfile.erb +0 -9
- data/lib/generators/install/templates/root/Guardfile.erb +0 -14
- data/lib/generators/install/templates/root/LICENSE.erb +0 -21
- data/lib/generators/install/templates/root/README.erb +0 -68
- data/lib/generators/install/templates/root/Rakefile.erb +0 -45
- data/lib/generators/install/templates/root/coveralls.erb +0 -1
- data/lib/generators/install/templates/root/gemspec.erb +0 -33
- data/lib/generators/install/templates/root/gitignore.erb +0 -28
- data/lib/generators/install/templates/root/rspec.erb +0 -1
- data/lib/generators/install/templates/root/rubocop.erb +0 -65
- data/lib/generators/install/templates/root/travis.erb +0 -3
- data/lib/generators/install/templates/spec/caching.erb +0 -12
- data/lib/generators/install/templates/spec/coveralls.erb +0 -4
- data/lib/generators/install/templates/spec/database_cleaner.erb +0 -28
- data/lib/generators/install/templates/spec/factory_girl_rails.erb +0 -5
- data/lib/generators/install/templates/spec/focus.erb +0 -5
- data/lib/generators/install/templates/spec/garbage_collection.erb +0 -11
- data/lib/generators/install/templates/spec/i18n.erb +0 -1
- data/lib/generators/install/templates/spec/migrations.erb +0 -3
- data/lib/generators/install/templates/spec/rails.erb +0 -6
- data/lib/generators/install/templates/spec/random_order.erb +0 -4
- data/lib/generators/install/templates/spec/rspec.erb +0 -10
- data/lib/generators/install/templates/spec/spec_helper.erb +0 -9
- data/lib/generators/install/templates/spec/timecop.erb +0 -1
- data/lib/generators/request/request.rb +0 -52
- data/lib/generators/request/templates/request_spec.erb +0 -66
- data/lib/generators/use_case/templates/use_case.erb +0 -54
- data/lib/generators/use_case/templates/use_case_spec.erb +0 -74
- data/lib/generators/use_case/use_case.rb +0 -31
- data/lib/hexx/exceptions/not_found_error.rb +0 -18
- data/lib/hexx/exceptions/runtime_error.rb +0 -27
- data/lib/hexx/exceptions/use_case_invalid.rb +0 -18
- data/lib/hexx/message.rb +0 -20
- data/lib/hexx/settings.rb +0 -47
- data/lib/hexx/use_case.rb +0 -256
- data/spec/hexx/exceptions/not_found_error_spec.rb +0 -21
- data/spec/hexx/exceptions/runtime_error_spec.rb +0 -43
- data/spec/hexx/exceptions/use_case_invalid_spec.rb +0 -21
- data/spec/hexx/message_spec.rb +0 -31
- data/spec/hexx/settings_spec.rb +0 -51
- data/spec/hexx/use_case_spec.rb +0 -274
- data/spec/support/exception_matchers.rb +0 -7
@@ -1,50 +0,0 @@
|
|
1
|
-
require_relative "../base"
|
2
|
-
|
3
|
-
module Hexx
|
4
|
-
module Generators
|
5
|
-
|
6
|
-
# Project scaffolder
|
7
|
-
class Dependency < Base
|
8
|
-
|
9
|
-
def self.source_root
|
10
|
-
super __FILE__
|
11
|
-
end
|
12
|
-
|
13
|
-
def add_spec
|
14
|
-
template "module_spec.erb", "spec/lib/#{ gem_name }_spec.rb", skip: true
|
15
|
-
end
|
16
|
-
|
17
|
-
def insert_setting_spec
|
18
|
-
inject_template_into_file(
|
19
|
-
"dependency_setting_spec.erb",
|
20
|
-
"spec/lib/#{ gem_name }_spec.rb",
|
21
|
-
before: "\nend"
|
22
|
-
)
|
23
|
-
end
|
24
|
-
|
25
|
-
def insert_setting
|
26
|
-
inject_template_into_file(
|
27
|
-
"dependency_setting.erb",
|
28
|
-
"lib/#{ gem_name }.rb",
|
29
|
-
before: "\nend"
|
30
|
-
)
|
31
|
-
end
|
32
|
-
|
33
|
-
def add_initializer
|
34
|
-
template(
|
35
|
-
"initializer.erb",
|
36
|
-
"spec/dummy/config/initializers/#{ gem_name }.rb",
|
37
|
-
skip: true
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
def insert_initializer_setting
|
42
|
-
inject_template_into_file(
|
43
|
-
"initializer_setting.erb",
|
44
|
-
"spec/dummy/config/initializers/#{ gem_name }.rb",
|
45
|
-
after: " do |config|"
|
46
|
-
)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# describe ".<%= file_name %>_name" do
|
4
|
-
|
5
|
-
# it "is public" do
|
6
|
-
# expect(subject).to respond_to(:<%= file_name %>_name).with(0).arguments
|
7
|
-
# end
|
8
|
-
# end
|
9
|
-
|
10
|
-
# describe ".<%= file_name %>" do
|
11
|
-
|
12
|
-
# it "is public" do
|
13
|
-
# expect(subject).to respond_to(:<%= file_name %>).with(0).arguments
|
14
|
-
# end
|
15
|
-
# end
|
16
|
-
|
17
|
-
# describe ".<%= file_name %>_name=" do
|
18
|
-
|
19
|
-
# around do |example|
|
20
|
-
# restore = subject.<%= file_name %>_name
|
21
|
-
# subject.<%= file_name %>_name = nil
|
22
|
-
# example.run
|
23
|
-
# subject.<%= file_name %>_name = restore
|
24
|
-
# end
|
25
|
-
|
26
|
-
# it "is public" do
|
27
|
-
# expect(subject).to respond_to(:<%= file_name %>_name=).with(1).argument
|
28
|
-
# end
|
29
|
-
|
30
|
-
# it "sets a <%= file_name %>_name" do
|
31
|
-
# expect { subject.<%= file_name %>_name = "TestClass" }
|
32
|
-
# .to change { subject.<%= file_name %>_name }.from(nil).to "TestClass"
|
33
|
-
# end
|
34
|
-
|
35
|
-
# it "sets a <%= file_name %>" do
|
36
|
-
# expect { subject.<%= file_name %>_name = "TestClass" }
|
37
|
-
# .to change { subject.<%= file_name %> }.from(nil).to TestClass
|
38
|
-
# end
|
39
|
-
# end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe <%= module_name %> do
|
4
|
-
|
5
|
-
before { class TestClass; end }
|
6
|
-
after { Object.send :remove_const, :TestClass }
|
7
|
-
|
8
|
-
subject { <%= module_name %> }
|
9
|
-
|
10
|
-
# describe ".configure" do
|
11
|
-
|
12
|
-
# it "is public" do
|
13
|
-
# expect(subject).to respond_to(:configure).with(0).arguments
|
14
|
-
# end
|
15
|
-
|
16
|
-
# it "sends module to a block" do
|
17
|
-
# subject.configure do |c|
|
18
|
-
# expect(c).to eq subject
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
# end
|
22
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require_relative "../base"
|
2
|
-
|
3
|
-
module Hexx
|
4
|
-
module Generators
|
5
|
-
|
6
|
-
# Use case scaffolder.
|
7
|
-
class Domain < Base
|
8
|
-
|
9
|
-
def self.source_root
|
10
|
-
super __FILE__
|
11
|
-
end
|
12
|
-
|
13
|
-
def add_spec
|
14
|
-
template "spec.erb", "spec/#{ domain_path }/#{ file_name }_spec.rb"
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def domain_path
|
20
|
-
"domain/#{ gem_name }"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
module <%= module_name %>
|
4
|
-
describe "<%= class_name %>" do
|
5
|
-
|
6
|
-
# ==========================================================================
|
7
|
-
# Prepare environment
|
8
|
-
# ==========================================================================
|
9
|
-
|
10
|
-
# before do
|
11
|
-
# # Timecop.travel Time.now - 100
|
12
|
-
# # prepare initial values
|
13
|
-
# # Timecop.return
|
14
|
-
# end
|
15
|
-
|
16
|
-
# before { Timecop.freeze }
|
17
|
-
# after { Timecop.return }
|
18
|
-
|
19
|
-
# ==========================================================================
|
20
|
-
# Prepare variables
|
21
|
-
# ==========================================================================
|
22
|
-
|
23
|
-
# let!(:params) { { something: something } }
|
24
|
-
# let(:listener) { double "listener" }
|
25
|
-
|
26
|
-
# let!(:expected_result) do
|
27
|
-
# OpenStruct.new(
|
28
|
-
# something: something
|
29
|
-
# ).inspect
|
30
|
-
# end
|
31
|
-
|
32
|
-
# ==========================================================================
|
33
|
-
# Run tests
|
34
|
-
# ==========================================================================
|
35
|
-
|
36
|
-
# context "with valid params" do
|
37
|
-
|
38
|
-
# subject(:use_case) { <%= class_name %>.new params }
|
39
|
-
|
40
|
-
# it "returns something" do
|
41
|
-
# expect(use_case.run.inspect).to eq expected_result
|
42
|
-
# end
|
43
|
-
|
44
|
-
# it "notifies listeners" do
|
45
|
-
# use_case.subscribe listener
|
46
|
-
# expect(listener).to receive(:something) do |item|
|
47
|
-
# expect(item.inspect).to eq expected_result
|
48
|
-
# end
|
49
|
-
# use_case.run
|
50
|
-
# end
|
51
|
-
|
52
|
-
# it "changes something" do
|
53
|
-
# expect { use_case.run }
|
54
|
-
# .to change { something }
|
55
|
-
# .from(something)
|
56
|
-
# .to(something)
|
57
|
-
# end
|
58
|
-
# end
|
59
|
-
|
60
|
-
# context "with invalid params" do
|
61
|
-
|
62
|
-
# before { params[:something] = something }
|
63
|
-
# subject(:use_case) { <%= class_name %>.new params }
|
64
|
-
|
65
|
-
# it "returns nil" do
|
66
|
-
# expect(use_case.run).to be_nil
|
67
|
-
# end
|
68
|
-
|
69
|
-
# it "notifies listeners" do
|
70
|
-
# use_case.subscribe listener
|
71
|
-
# expect(listener).to receive(:error) do |message|
|
72
|
-
# expect(message).not_to be_blank
|
73
|
-
# end
|
74
|
-
# use_case.run
|
75
|
-
# end
|
76
|
-
|
77
|
-
# it "doesn't change something" do
|
78
|
-
# expect { use_case.run }
|
79
|
-
# .not_to change { something }
|
80
|
-
# .from something
|
81
|
-
# end
|
82
|
-
# end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,133 +0,0 @@
|
|
1
|
-
require "thor"
|
2
|
-
require "extlib"
|
3
|
-
|
4
|
-
module Hexx
|
5
|
-
module Generators
|
6
|
-
|
7
|
-
# Project scaffolder
|
8
|
-
class Install < Thor::Group
|
9
|
-
include Thor::Actions
|
10
|
-
|
11
|
-
def self.source_root
|
12
|
-
root = File.dirname File.expand_path(__FILE__)
|
13
|
-
@source_root ||= File.join(root, "templates")
|
14
|
-
end
|
15
|
-
|
16
|
-
argument :name
|
17
|
-
|
18
|
-
def remove_app_folder
|
19
|
-
run "rm app -f -r"
|
20
|
-
end
|
21
|
-
|
22
|
-
def update_bin_files
|
23
|
-
template "bin/rails.erb", "bin/rails", force: true
|
24
|
-
end
|
25
|
-
|
26
|
-
def add_config_files
|
27
|
-
run "mkdir config/locales -p -v"
|
28
|
-
template "config/routes.erb", "config/routes.rb", force: true
|
29
|
-
end
|
30
|
-
|
31
|
-
def add_lib_files
|
32
|
-
run "mkdir lib/tasks -p -v"
|
33
|
-
install_from_templates lib_files
|
34
|
-
end
|
35
|
-
|
36
|
-
def add_spec_files
|
37
|
-
run "mkdir spec/requests/json_schemas/shared -p -v"
|
38
|
-
template "spec/spec_helper.erb", "spec/spec_helper.rb", force: true
|
39
|
-
install_from_templates spec_initializers
|
40
|
-
install_from_templates matchers_files
|
41
|
-
install_from_templates json_files
|
42
|
-
end
|
43
|
-
|
44
|
-
def add_root_files
|
45
|
-
run "rm MIT-LICENSE -f -r"
|
46
|
-
install_from_templates settings_files
|
47
|
-
install_from_templates root_files
|
48
|
-
end
|
49
|
-
|
50
|
-
def run_docs
|
51
|
-
run "subl README.rdoc lib/#{ gem_name }.rb #{ gem_name }.gemspec"
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
def install_from_templates(hash)
|
57
|
-
hash.each { |erb, file| template erb, file, force: true }
|
58
|
-
end
|
59
|
-
|
60
|
-
def gem_name
|
61
|
-
@gem_name ||= name.snake_case
|
62
|
-
end
|
63
|
-
|
64
|
-
def module_name
|
65
|
-
@module_name ||= name.camel_case
|
66
|
-
end
|
67
|
-
|
68
|
-
def lib_files
|
69
|
-
@lib_files ||= {
|
70
|
-
"lib/lib.erb" => "lib/#{ gem_name }.rb",
|
71
|
-
"lib/engine.erb" => "lib/#{ gem_name }/engine.rb",
|
72
|
-
"lib/version.erb" => "lib/#{ gem_name }/version.rb",
|
73
|
-
"lib/task" => "lib/tasks/#{ gem_name }_install.rb"
|
74
|
-
}
|
75
|
-
end
|
76
|
-
|
77
|
-
def spec_initializers
|
78
|
-
@spec_initializers ||= initializers.reduce({}) do |hash, name|
|
79
|
-
hash["spec/#{ name }.erb"] = "spec/support/initializers/#{ name }.rb"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def initializers
|
84
|
-
@initializers ||= %w(
|
85
|
-
caching coveralls database_cleaner factory_girl_rails focus
|
86
|
-
garbage_collection i18n migrations rails random_order rspec timecop
|
87
|
-
)
|
88
|
-
end
|
89
|
-
|
90
|
-
def matchers_files
|
91
|
-
@matchers_files ||= begin
|
92
|
-
from, to = "matchers/", "spec/support/matchers/"
|
93
|
-
{
|
94
|
-
"#{ from }controllers.erb" => "#{ to }controllers.rb",
|
95
|
-
"#{ from }json_schema.erb" => "#{ to }json_schema.rb"
|
96
|
-
}
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def settings_files
|
101
|
-
@settings_files ||= {
|
102
|
-
"root/coveralls.erb" => ".coveralls.yml",
|
103
|
-
"root/rspec.erb" => ".rspec",
|
104
|
-
"root/rubocop.erb" => ".rubocop.yml",
|
105
|
-
"root/travis.erb" => ".travis.yml",
|
106
|
-
"root/Rakefile.erb" => "Rakefile",
|
107
|
-
"root/Guardfile.erb" => "Guardfile"
|
108
|
-
}
|
109
|
-
end
|
110
|
-
|
111
|
-
def root_files
|
112
|
-
@root_files ||= {
|
113
|
-
"root/gitignore.erb" => ".gitignore",
|
114
|
-
"root/LICENSE.erb" => "LICENSE.rdoc",
|
115
|
-
"root/README.erb" => "README.rdoc",
|
116
|
-
"root/Gemfile.erb" => "Gemfile",
|
117
|
-
"root/gemspec.erb" => "#{ gem_name }.gemspec"
|
118
|
-
}
|
119
|
-
end
|
120
|
-
|
121
|
-
def json_files
|
122
|
-
@json_files ||= begin
|
123
|
-
from, to = "json_schemas/", "spec/requests/json_schemas/"
|
124
|
-
{
|
125
|
-
"#{ from }get_errors.erb" => "#{ to }get_errors.json",
|
126
|
-
"#{ from }error.erb" => "#{ to }shared/error.json",
|
127
|
-
"#{ from }success.erb" => "#{ to }shared/success.json"
|
128
|
-
}
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
ENGINE_ROOT = File.expand_path "../..", __FILE__
|
4
|
-
ENGINE_PATH = File.expand_path "../../lib/<%= gem_name %>/engine", __FILE__
|
5
|
-
|
6
|
-
# Set up gems listed in the Gemfile.
|
7
|
-
ENV["BUNDLE_GEMFILE"] ||= File.expand_path "../../Gemfile", __FILE__
|
8
|
-
require "bundler/setup" if File.exist? ENV["BUNDLE_GEMFILE"]
|
9
|
-
|
10
|
-
require "rails/all"
|
11
|
-
require "rails/engine/commands"
|
@@ -1,14 +0,0 @@
|
|
1
|
-
// JSON schema for an error message
|
2
|
-
{
|
3
|
-
"$schema": "http://json-schema.org/draft-04/schema#",
|
4
|
-
|
5
|
-
"type": "object",
|
6
|
-
|
7
|
-
"properties": {
|
8
|
-
"type": { "type": "string", "enum": ["error"] },
|
9
|
-
"text": { "type": "string", "minLength": 1 }
|
10
|
-
},
|
11
|
-
|
12
|
-
"additionalProperties": false,
|
13
|
-
"required": ["type", "text"]
|
14
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
// JSON schema for getting an error messages
|
2
|
-
{
|
3
|
-
"$schema": "http://json-schema.org/draft-04/schema#",
|
4
|
-
|
5
|
-
"type": "object",
|
6
|
-
|
7
|
-
"properties": {
|
8
|
-
"messages": {
|
9
|
-
"type": "array",
|
10
|
-
"items": { "$ref": "messages/error.json" },
|
11
|
-
"minimumUnits": 1,
|
12
|
-
"unique": true
|
13
|
-
}
|
14
|
-
},
|
15
|
-
|
16
|
-
"additionalProperties": false,
|
17
|
-
"required": ["messages"]
|
18
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
// JSON schema for an error message
|
2
|
-
{
|
3
|
-
"$schema": "http://json-schema.org/draft-04/schema#",
|
4
|
-
|
5
|
-
"type": "object",
|
6
|
-
|
7
|
-
"properties": {
|
8
|
-
"type": { "type": "string", "enum": ["success", "info"] },
|
9
|
-
"text": { "type": "string", "minLength": 1 }
|
10
|
-
},
|
11
|
-
|
12
|
-
"additionalProperties": false,
|
13
|
-
"required": ["type", "text"]
|
14
|
-
}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
module <%= module_name %>
|
2
|
-
|
3
|
-
# Rails Engine settings
|
4
|
-
class Engine < ::Rails::Engine
|
5
|
-
isolate_namespace <%= module_name %>
|
6
|
-
|
7
|
-
config.generators do |generator|
|
8
|
-
generator.test_framework :rspec, fixture: true, view_specs: true
|
9
|
-
generator.fixture_replacement :factory_girl, dir: "spec/factories"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
namespace :<%= gem_name %> do
|
2
|
-
namespace :install do
|
3
|
-
|
4
|
-
desc "Initializes the <%= gem_name %> gem to rails engine"
|
5
|
-
task default: %w(dependencies migrations routes)
|
6
|
-
|
7
|
-
desc "Installs the <%= gem_name %> gem dependencies"
|
8
|
-
task :dependencies do
|
9
|
-
reenable_railties
|
10
|
-
system "rake #{ app }uuids:install"
|
11
|
-
end
|
12
|
-
|
13
|
-
desc "Copies migrations from the <%= gem_name %> gem to application"
|
14
|
-
task :migrations do
|
15
|
-
reenable_railties
|
16
|
-
Rake::Task["#{ app }<%= gem_name %>:install:migrations"].invoke
|
17
|
-
end
|
18
|
-
|
19
|
-
desc "Mounts the <%= gem_name %> API routes"
|
20
|
-
task :routes do
|
21
|
-
insert_into_file(
|
22
|
-
"config/routes.rb",
|
23
|
-
before: "\nend",
|
24
|
-
line: "\n\n mount <%= module_name %>::Engine => \"/<%= gem_name %>\"",
|
25
|
-
engine: "<%= module_name %>::Engine"
|
26
|
-
) unless engine?
|
27
|
-
end
|
28
|
-
|
29
|
-
def engine?
|
30
|
-
@engine ||= Rake::Task.task_defined?("railties:install:migrations")
|
31
|
-
end
|
32
|
-
|
33
|
-
def app
|
34
|
-
@app ||= engine? ? "" : "app:"
|
35
|
-
end
|
36
|
-
|
37
|
-
def reenable_railties
|
38
|
-
Rake::Task["#{ app }railties:install:migrations"].reenable
|
39
|
-
end
|
40
|
-
|
41
|
-
def insert_into_file(name, before:, line:, engine:)
|
42
|
-
say_with_time "mounting <%= gem_name %>' routes" do
|
43
|
-
text = File.read(name)
|
44
|
-
return if text[engine]
|
45
|
-
File.write name, text.gsub(before, line << before)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def say_with_time(text)
|
50
|
-
start = current_time
|
51
|
-
puts "=== #{ text } #{ "=" * (74 - text.count) }"
|
52
|
-
yield
|
53
|
-
puts " -> #{ (current_time - start).round(4) }s"
|
54
|
-
end
|
55
|
-
|
56
|
-
def current_time
|
57
|
-
Time.new.to_f
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# Common matchers for controller specs
|
2
|
-
|
3
|
-
RSpec::Matchers.define :listen_to do |use_case|
|
4
|
-
match do |listener|
|
5
|
-
expect(use_case).to receive(:subscribe).with(listener, prefix: :on).once
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
RSpec::Matchers.define :run_after_subscriptions do
|
10
|
-
match do |use_case|
|
11
|
-
expect(use_case).to receive(:subscribe).ordered
|
12
|
-
expect(use_case).to receive(:run).once.ordered
|
13
|
-
end
|
14
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# Matchers to check a json schema
|
2
|
-
require "json-schema"
|
3
|
-
|
4
|
-
RSpec::Matchers.define :match_json_schema do |schema|
|
5
|
-
match do |response|
|
6
|
-
schema_directory = "#{Dir.pwd}/spec/requests/json_schemas"
|
7
|
-
schema_path = "#{schema_directory}/#{schema}.json"
|
8
|
-
JSON::Validator.validate! schema_path, response
|
9
|
-
end
|
10
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
guard "zeus" do
|
2
|
-
|
3
|
-
watch(/^app(.+)\.rb$/) do |m|
|
4
|
-
"spec#{m[1]}_spec.rb"
|
5
|
-
end
|
6
|
-
|
7
|
-
watch(%r{^spec/factories/(.+)\.rb$}) { "spec/models" }
|
8
|
-
|
9
|
-
watch(/^spec.+_spec\.rb$/)
|
10
|
-
|
11
|
-
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
12
|
-
|
13
|
-
watch("spec/spec_helper.rb") { "spec" }
|
14
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
= The MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2014 Andrew Kozin, https://github.com/nepalez
|
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.
|
@@ -1,68 +0,0 @@
|
|
1
|
-
= <%= module_name %>
|
2
|
-
|
3
|
-
{<img src="http://img.shields.io/travis/nepalez/<%= gem_name %>.svg?style=flat" alt="Bild Status" />}[https://travis-ci.org/nepalez/<%= gem_name %>]
|
4
|
-
{<img src="http://img.shields.io/codeclimate/github/nepalez/<%= gem_name %>.svg?style=flat" alt="Code Metrics" />}[https://codeclimate.com/github/nepalez/<%= gem_name %>]
|
5
|
-
{<img src="http://img.shields.io/gemnasium/nepalez/<%= gem_name %>.svg?style=flat" alt="Dependency Status" />}[https://gemnasium.com/nepalez/<%= gem_name %>]
|
6
|
-
{<img src="http://img.shields.io/coveralls/nepalez/<%= gem_name %>.svg?style=flat" alt="Coverage Status" />}[https://coveralls.io/r/nepalez/<%= gem_name %>]
|
7
|
-
{<img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License" />}[https://github.com/nepalez/<%= gem_name %>/blob/master/LICENSE.rdoc]
|
8
|
-
|
9
|
-
== About
|
10
|
-
|
11
|
-
Defines models of {TODO}.
|
12
|
-
Contains use cases for managing {TODO} and API for {TODO}
|
13
|
-
via json http requests.
|
14
|
-
|
15
|
-
=== Models
|
16
|
-
|
17
|
-
<tt><%= module_name %>::Something</tt>::
|
18
|
-
TODO: describe a model.
|
19
|
-
|
20
|
-
=== UseCases
|
21
|
-
|
22
|
-
<tt><%= module_name %>::DoSomething</tt>::
|
23
|
-
TODO: describe a use case.
|
24
|
-
|
25
|
-
=== REST API
|
26
|
-
|
27
|
-
See the { API Blueprint }[http://docs.<%= gem_name %>.apiary.io] for details.
|
28
|
-
|
29
|
-
=== Dependencies
|
30
|
-
|
31
|
-
<tt><%= module_name %>.get_something_name</tt>::
|
32
|
-
TODO: describe a dependency.
|
33
|
-
|
34
|
-
== Installation
|
35
|
-
|
36
|
-
Add this line to your application's Gemfile:
|
37
|
-
|
38
|
-
gem "<%= gem_name %>"
|
39
|
-
|
40
|
-
And then execute:
|
41
|
-
|
42
|
-
$ bundle
|
43
|
-
|
44
|
-
Or install it yourself as:
|
45
|
-
|
46
|
-
$ gem install <%= gem_name %>
|
47
|
-
|
48
|
-
Then run from a command line:
|
49
|
-
|
50
|
-
$ rake <%= gem_name %>:install
|
51
|
-
|
52
|
-
== Uninstallation
|
53
|
-
|
54
|
-
Run from a command line:
|
55
|
-
|
56
|
-
$ rake <%= gem_name %>:uninstall
|
57
|
-
|
58
|
-
== Contributing
|
59
|
-
|
60
|
-
1. Fork it ( https://github.com/nepalez/<%= gem_name %>/fork )
|
61
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
62
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
63
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
64
|
-
5. Create a new Pull Request
|
65
|
-
|
66
|
-
== License
|
67
|
-
|
68
|
-
The plugin is distributed under {MIT license}[https://github.com/nepalez/<%= gem_name %>/blob/master/LICENSE.rdoc]
|