Skip to content

Commit

Permalink
rubocop fixes...this feels sloppy in a way I don't fully understand yet
Browse files Browse the repository at this point in the history
* It's not clear to me at all where we should hide the Application instance...or honestly right now where exactly it is hanging off the main object
  (if that's the right nomenclature).
  • Loading branch information
bradshjg committed Feb 3, 2021
1 parent 452c5c9 commit 70f1a28
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 2 additions & 0 deletions examples/demo/app.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'prubot'

on 'test-event', 'say howdy' do
Expand Down
2 changes: 2 additions & 0 deletions examples/register/app.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'prubot'

on 'test-event', 'say howdy' do
Expand Down
11 changes: 7 additions & 4 deletions lib/prubot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def run!
end

def run?
$0 == 'app.rb' # HACK HACK HACK need to decide how we want to handle this.
$PROGRAM_NAME == 'app.rb' # HACK: HACK HACK need to decide how we want to handle this.
end

def register_event(name, event, action = nil, &block)
Expand All @@ -56,8 +56,10 @@ def setup_routing
end
end

##
# Prubot DSL
module DSL
@@app = Prubot::Application.new
@@app = Prubot::Application.new # rubocop:disable Style/ClassVars

##
# Supports both +on 'event' 'description' do...+ and +on 'action', 'event', 'description' do...+
Expand All @@ -70,12 +72,13 @@ def on(*args, &block)
when 3
@@app.register_event(args[2], args[1], args[0], &block)
else
raise Prubot::Error 'on supports either "on <event> <description> do..." or "on <action> <event> <description> do..."'
raise Prubot::Error 'on supports either "on <event> <description> do..." or '\
'"on <action> <event> <description> do..."'
end
end

at_exit { @@app.run! if @@app.run? }
end
end

extend Prubot::DSL
extend Prubot::DSL # rubocop:disable Style/MixinUsage
3 changes: 1 addition & 2 deletions lib/prubot/dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def call(env)

private

def register_app(request)
def register_app(_request)
[200, { 'Content-Type' => 'text/html' }, ['howdy']]
end

Expand All @@ -35,7 +35,6 @@ def handle_event(request)
generate_response event, action, result
end


def skip_verify?
@config.secret == false
end
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'prubot'

RSpec.configure do |config|
# HACK HACK HACK clean up environment after every test (sigh)
# HACK: HACK HACK clean up environment after every test (sigh)
config.after { ENV.delete_if { |k, _v| k.start_with?('PRUBOT') } }
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.rspec_status'
Expand Down

0 comments on commit 70f1a28

Please sign in to comment.