Skip to content

Commit d814c92

Browse files
authored
Merge pull request #46 from andypike/file_specs_bump_gems
File specs bump gems
2 parents dd77495 + a440a44 commit d814c92

26 files changed

+258
-151
lines changed

Diff for: .rubocop.yml

+14-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,23 @@ Style/HashSyntax:
1212
Style/StringLiterals:
1313
EnforcedStyle: double_quotes
1414

15-
Style/AlignParameters:
15+
Layout/AlignParameters:
1616
EnforcedStyle: with_fixed_indentation
1717

18-
Style/MultilineOperationIndentation:
18+
Layout/MultilineOperationIndentation:
1919
EnforcedStyle: indented
2020

21-
Style/MultilineMethodCallIndentation:
21+
Layout/MultilineMethodCallIndentation:
2222
EnforcedStyle: indented
2323

24-
Style/IndentationWidth:
25-
Width: 2
24+
Layout/IndentationWidth:
25+
Width: 2
26+
27+
Metrics/ClassLength:
28+
Max: 110
29+
Exclude:
30+
- 'spec/**/*_spec.rb'
31+
32+
Metrics/BlockLength:
33+
Exclude:
34+
- 'spec/**/*_spec.rb'

Diff for: .travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ language: ruby
22
rvm:
33
- "2.2.2"
44
- "2.3.0"
5+
- "2.5.1"
56
script: bundle exec rspec

Diff for: Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ source "https://rubygems.org"
22

33
gemspec
44

5-
gem "wisper-rspec", :github => "krisleech/wisper-rspec", :ref => "ba039c6f"
5+
gem "wisper-rspec"

Diff for: Gemfile.lock

+80-88
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
GIT
2-
remote: git://github.com/krisleech/wisper-rspec.git
3-
revision: ba039c6f717008cba378253a0ee254fcafdee276
4-
ref: ba039c6f
5-
specs:
6-
wisper-rspec (0.0.2)
7-
81
PATH
92
remote: .
103
specs:
11-
rectify (0.10.0)
4+
rectify (0.12.0)
125
activemodel (>= 4.1.0)
136
activerecord (>= 4.1.0)
147
activesupport (>= 4.1.0)
@@ -18,127 +11,126 @@ PATH
1811
GEM
1912
remote: https://rubygems.org/
2013
specs:
21-
actionpack (4.2.6)
22-
actionview (= 4.2.6)
23-
activesupport (= 4.2.6)
24-
rack (~> 1.6)
25-
rack-test (~> 0.6.2)
26-
rails-dom-testing (~> 1.0, >= 1.0.5)
27-
rails-html-sanitizer (~> 1.0, >= 1.0.2)
28-
actionview (4.2.6)
29-
activesupport (= 4.2.6)
30-
builder (~> 3.1)
31-
erubis (~> 2.7.0)
32-
rails-dom-testing (~> 1.0, >= 1.0.5)
14+
actionpack (5.2.0)
15+
actionview (= 5.2.0)
16+
activesupport (= 5.2.0)
17+
rack (~> 2.0)
18+
rack-test (>= 0.6.3)
19+
rails-dom-testing (~> 2.0)
3320
rails-html-sanitizer (~> 1.0, >= 1.0.2)
34-
activemodel (4.2.6)
35-
activesupport (= 4.2.6)
21+
actionview (5.2.0)
22+
activesupport (= 5.2.0)
3623
builder (~> 3.1)
37-
activerecord (4.2.6)
38-
activemodel (= 4.2.6)
39-
activesupport (= 4.2.6)
40-
arel (~> 6.0)
41-
activesupport (4.2.6)
42-
i18n (~> 0.7)
43-
json (~> 1.7, >= 1.7.7)
24+
erubi (~> 1.4)
25+
rails-dom-testing (~> 2.0)
26+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
27+
activemodel (5.2.0)
28+
activesupport (= 5.2.0)
29+
activerecord (5.2.0)
30+
activemodel (= 5.2.0)
31+
activesupport (= 5.2.0)
32+
arel (>= 9.0)
33+
activesupport (5.2.0)
34+
concurrent-ruby (~> 1.0, >= 1.0.2)
35+
i18n (>= 0.7, < 2)
4436
minitest (~> 5.1)
45-
thread_safe (~> 0.3, >= 0.3.4)
4637
tzinfo (~> 1.1)
47-
arel (6.0.3)
48-
ast (2.2.0)
49-
awesome_print (1.6.1)
38+
arel (9.0.0)
39+
ast (2.4.0)
40+
awesome_print (1.8.0)
5041
axiom-types (0.1.1)
5142
descendants_tracker (~> 0.0.4)
5243
ice_nine (~> 0.11.0)
5344
thread_safe (~> 0.3, >= 0.3.1)
54-
builder (3.2.2)
55-
coderay (1.1.1)
45+
builder (3.2.3)
46+
coderay (1.1.2)
5647
coercible (1.0.0)
5748
descendants_tracker (~> 0.0.1)
49+
concurrent-ruby (1.0.5)
50+
crass (1.0.4)
5851
descendants_tracker (0.0.4)
5952
thread_safe (~> 0.3, >= 0.3.1)
60-
diff-lcs (1.2.5)
53+
diff-lcs (1.3)
6154
equalizer (0.0.11)
62-
erubis (2.7.0)
63-
i18n (0.7.0)
55+
erubi (1.7.1)
56+
i18n (1.0.1)
57+
concurrent-ruby (~> 1.0)
6458
ice_nine (0.11.2)
65-
json (1.8.3)
66-
loofah (2.0.3)
59+
loofah (2.2.2)
60+
crass (~> 1.0.2)
6761
nokogiri (>= 1.5.9)
68-
method_source (0.8.2)
69-
mini_portile2 (2.0.0)
70-
minitest (5.8.4)
71-
nokogiri (1.6.7.2)
72-
mini_portile2 (~> 2.0.0.rc2)
73-
parser (2.3.0.6)
74-
ast (~> 2.2)
62+
method_source (0.9.0)
63+
mini_portile2 (2.3.0)
64+
minitest (5.11.3)
65+
nokogiri (1.8.2)
66+
mini_portile2 (~> 2.3.0)
67+
parallel (1.12.1)
68+
parser (2.5.1.0)
69+
ast (~> 2.4.0)
7570
powerpack (0.1.1)
76-
pry (0.10.3)
71+
pry (0.11.3)
7772
coderay (~> 1.1.0)
78-
method_source (~> 0.8.1)
79-
slop (~> 3.4)
80-
rack (1.6.4)
81-
rack-test (0.6.3)
82-
rack (>= 1.0)
83-
rails-deprecated_sanitizer (1.0.3)
84-
activesupport (>= 4.2.0.alpha)
85-
rails-dom-testing (1.0.7)
86-
activesupport (>= 4.2.0.beta, < 5.0)
87-
nokogiri (~> 1.6.0)
88-
rails-deprecated_sanitizer (>= 1.0.1)
89-
rails-html-sanitizer (1.0.3)
90-
loofah (~> 2.0)
91-
rainbow (2.1.0)
92-
rake (11.1.2)
93-
rspec (3.4.0)
94-
rspec-core (~> 3.4.0)
95-
rspec-expectations (~> 3.4.0)
96-
rspec-mocks (~> 3.4.0)
97-
rspec-collection_matchers (1.1.2)
73+
method_source (~> 0.9.0)
74+
rack (2.0.5)
75+
rack-test (1.0.0)
76+
rack (>= 1.0, < 3)
77+
rails-dom-testing (2.0.3)
78+
activesupport (>= 4.2.0)
79+
nokogiri (>= 1.6)
80+
rails-html-sanitizer (1.0.4)
81+
loofah (~> 2.2, >= 2.2.2)
82+
rainbow (3.0.0)
83+
rake (12.3.1)
84+
rspec (3.7.0)
85+
rspec-core (~> 3.7.0)
86+
rspec-expectations (~> 3.7.0)
87+
rspec-mocks (~> 3.7.0)
88+
rspec-collection_matchers (1.1.3)
9889
rspec-expectations (>= 2.99.0.beta1)
99-
rspec-core (3.4.4)
100-
rspec-support (~> 3.4.0)
101-
rspec-expectations (3.4.0)
90+
rspec-core (3.7.1)
91+
rspec-support (~> 3.7.0)
92+
rspec-expectations (3.7.0)
10293
diff-lcs (>= 1.2.0, < 2.0)
103-
rspec-support (~> 3.4.0)
104-
rspec-mocks (3.4.1)
94+
rspec-support (~> 3.7.0)
95+
rspec-mocks (3.7.0)
10596
diff-lcs (>= 1.2.0, < 2.0)
106-
rspec-support (~> 3.4.0)
107-
rspec-support (3.4.1)
108-
rubocop (0.37.2)
109-
parser (>= 2.3.0.4, < 3.0)
97+
rspec-support (~> 3.7.0)
98+
rspec-support (3.7.1)
99+
rubocop (0.56.0)
100+
parallel (~> 1.10)
101+
parser (>= 2.5)
110102
powerpack (~> 0.1)
111-
rainbow (>= 1.99.1, < 3.0)
103+
rainbow (>= 2.2.2, < 4.0)
112104
ruby-progressbar (~> 1.7)
113-
unicode-display_width (~> 0.3)
114-
ruby-progressbar (1.7.5)
115-
slop (3.6.0)
116-
sqlite3 (1.3.11)
117-
thread_safe (0.3.5)
118-
tzinfo (1.2.2)
105+
unicode-display_width (~> 1.0, >= 1.0.1)
106+
ruby-progressbar (1.9.0)
107+
sqlite3 (1.3.13)
108+
thread_safe (0.3.6)
109+
tzinfo (1.2.5)
119110
thread_safe (~> 0.1)
120-
unicode-display_width (0.3.1)
111+
unicode-display_width (1.3.2)
121112
virtus (1.0.5)
122113
axiom-types (~> 0.1)
123114
coercible (~> 1.0)
124115
descendants_tracker (~> 0.0, >= 0.0.3)
125116
equalizer (~> 0.0, >= 0.0.9)
126-
wisper (1.6.1)
117+
wisper (2.0.0)
118+
wisper-rspec (1.1.0)
127119

128120
PLATFORMS
129121
ruby
130122

131123
DEPENDENCIES
132124
actionpack (>= 4.1.0)
133125
awesome_print (~> 1.6)
134-
pry (~> 0.10.3)
126+
pry (~> 0.11.3)
135127
rake
136128
rectify!
137129
rspec (~> 3.4)
138130
rspec-collection_matchers (~> 1.1)
139131
rubocop
140132
sqlite3
141-
wisper-rspec!
133+
wisper-rspec
142134

143135
BUNDLED WITH
144136
1.11.2

Diff for: Rakefile

+15-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,22 @@ require "yaml"
44
require "active_record"
55

66
namespace :db do
7-
db_config = YAML.load(File.open("spec/config/database.yml"))
7+
db_config = YAML.safe_load(File.open("spec/config/database.yml"))
8+
9+
def activerecord_below_5_2?
10+
ActiveRecord.version.release < Gem::Version.new("5.2.0")
11+
end
812

913
desc "Migrate the database"
1014
task :migrate do
1115
ActiveRecord::Base.establish_connection(db_config)
12-
ActiveRecord::Migrator.migrate("spec/db/migrate")
16+
17+
if activerecord_below_5_2?
18+
ActiveRecord::Migrator.migrate("spec/db/migrate")
19+
else
20+
ActiveRecord::MigrationContext.new("spec/db/migrate").migrate
21+
end
22+
1323
Rake::Task["db:schema"].invoke
1424
puts "Database migrated."
1525
end
@@ -36,12 +46,12 @@ namespace :g do
3646
migration_class = name.split("_").map(&:capitalize).join
3747

3848
File.open(path, "w") do |file|
39-
file.write <<-EOF.strip_heredoc
40-
class #{migration_class} < ActiveRecord::Migration
49+
file.write <<-MIGRATION.strip_heredoc
50+
class #{migration_class} < ActiveRecord::Migration[5.2]
4151
def change
4252
end
4353
end
44-
EOF
54+
MIGRATION
4555
end
4656

4757
puts "Migration #{path} created"

Diff for: lib/rectify/build_form_from_model.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def build
1818

1919
private
2020

21-
attr_reader :form_class, :form, :model
21+
attr_reader :form_class, :model
2222

2323
def form
2424
@form ||= form_class.new

Diff for: lib/rectify/command.rb

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,39 @@
11
module Rectify
2+
class EventRecorder
3+
attr_reader :events
4+
5+
def initialize
6+
@events = {}
7+
end
8+
9+
# rubocop:disable Style/MethodMissing
10+
def method_missing(method_name, *args, &_block)
11+
args = args.first if args.size == 1
12+
@events[method_name] = args
13+
end
14+
# rubocop:enable Style/MethodMissing
15+
16+
def respond_to_missing?(_method_name, _include_private = false)
17+
true
18+
end
19+
end
20+
221
class Command
322
include Wisper::Publisher
423

524
def self.call(*args, &block)
25+
event_recorder = EventRecorder.new
26+
627
command = new(*args)
28+
command.subscribe(event_recorder)
729
command.evaluate(&block) if block_given?
830
command.call
31+
32+
event_recorder.events
933
end
1034

1135
def evaluate(&block)
12-
@caller = eval("self", block.binding)
36+
@caller = eval("self", block.binding, __FILE__, __LINE__)
1337
instance_eval(&block)
1438
end
1539

Diff for: lib/rectify/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Rectify
2-
VERSION = "0.10.0".freeze
2+
VERSION = "0.12.0".freeze
33
end

Diff for: readme.md

+23
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,29 @@ When an event is handled, the appropriate block is called in the context of the
609609
controller. Basically, any method call within the block is delegated back to the
610610
controller.
611611

612+
As well as capturing events in a block, the command will also return a hash of the
613+
broadcast events together with any parameters that were passed. For example:
614+
615+
```ruby
616+
events = RegisterAccount.call(form)
617+
618+
events # => { :ok => user }
619+
```
620+
621+
There will be a key for each event broadcast and its value will be the parameters
622+
passed. If there is a single parameter it will be the value. If there are no
623+
parameters or many, the hash value for the event key will be an array of the parameters:
624+
625+
```ruby
626+
events = RegisterAccount.call(form)
627+
628+
events # => {
629+
# :ok => user,
630+
# :messages => ["User registered", "Email sent", "Account ready"],
631+
# :next => []
632+
# }
633+
```
634+
612635
You may occasionally want to expose a value within a handler block to the view.
613636
You do this via the `expose` method within the handler block. If you want to
614637
use `expose` then you must include the `Rectify::ControllerHelpers` module in

0 commit comments

Comments
 (0)