Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

Commit

Permalink
refactor(hash): use hashrockets for hashes that have keys as values
Browse files Browse the repository at this point in the history
  • Loading branch information
boc committed Mar 2, 2021
1 parent 07167dd commit cbab728
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ AllCops:
NewCops: enable
SuggestExtensions: false

Style/HashSyntax:
UseHashRocketsWithSymbolValues: true

2 changes: 1 addition & 1 deletion features/step_definitions/openhab_rules.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def deploy_rule(filename: '', check_position: :end, check: true)
end

When('I start deploying the rule') do
deploy_rule(check_position: :start)
deploy_rule(:check_position => :start)
end

Given('code in a rules file(:)') do |doc_string|
Expand Down
4 changes: 2 additions & 2 deletions features/support/openhab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def openhab_dir

def openhab_client(command)
karaf_client_path = File.join(openhab_dir, 'runtime/bin/client')
cmd = TTY::Command.new(printer: :null)
cmd = TTY::Command.new(:printer => :null)
cmd.run("#{karaf_client_path} -p habopen #{command}", only_output_on_error: true)
end

Expand Down Expand Up @@ -50,7 +50,7 @@ def clear_gem_path
end

def ensure_openhab_running
cmd = TTY::Command.new(printer: :null)
cmd = TTY::Command.new(:printer => :null)
cmd.run(File.join(openhab_dir, 'runtime/bin/status'), only_output_on_error: true)
end

Expand Down
2 changes: 1 addition & 1 deletion features/support/openhab_rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def self.set_item_state(name, state)
end

def self.item_state(name)
(get "/rest/items/#{name}/state", headers: text, format: :text).chomp
(get "/rest/items/#{name}/state", :headers => text, :format => :text).chomp
end

def self.delete_item(name)
Expand Down
6 changes: 4 additions & 2 deletions lib/openhab/dsl/items/player_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ class PlayerItem

def_item_delegator :@player_item

item_type Java::OrgOpenhabCoreLibraryItems::PlayerItem, play?: :playing?, pause?: :paused?,
rewind?: :rewinding?, fastforward?: :fastforwarding?
item_type Java::OrgOpenhabCoreLibraryItems::PlayerItem, :play? => :playing?,
:pause? => :paused?,
:rewind? => :rewinding?,
:fastforward? => :fastforwarding?

# rubocop: disable Style/Alias
# Disabled because 'alias' does not work with the dynamically defined methods
Expand Down
3 changes: 2 additions & 1 deletion lib/openhab/dsl/rules/guard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def to_s
#
def should_run?(event)
logger.trace("Checking guards #{self}")
check(@only_if, check_type: :only_if, event: event) && check(@not_if, check_type: :not_if, event: event)
check(@only_if, :check_type => :only_if,
:event => event) && check(@not_if, :check_type => :not_if, :event => event)
end

private
Expand Down
8 changes: 4 additions & 4 deletions lib/openhab/dsl/rules/rule_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ class RuleConfig
#
Delay = Struct.new(:duration)

prop_array :run, array_name: :run_queue, wrapper: Run
prop_array :triggered, array_name: :run_queue, wrapper: Trigger
prop_array :delay, array_name: :run_queue, wrapper: Delay
prop_array :otherwise, array_name: :run_queue, wrapper: Otherwise
prop_array :run, :array_name => :run_queue, :wrapper => Run
prop_array :triggered, :array_name => :run_queue, :wrapper => Trigger
prop_array :delay, :array_name => :run_queue, :wrapper => Delay
prop_array :otherwise, :array_name => :run_queue, :wrapper => Otherwise

prop :name
prop :description
Expand Down
2 changes: 1 addition & 1 deletion rakelib/docs.rake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace :docs do
end

desc 'Start Jekyll Documentation Server'
task jeykll: :yard do
task :jeykll => :yard do
sh 'bundle exec jekyll clean'
sh 'bundle exec jekyll server --config docs/_config.yml'
end
Expand Down
4 changes: 2 additions & 2 deletions rakelib/openhab.rake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace :openhab do
CLEAN << @deploy_dir

def command_success?(command)
cmd = TTY::Command.new(printer: :null)
cmd = TTY::Command.new(:printer => :null)
cmd.run!(command).success?
end

Expand All @@ -49,7 +49,7 @@ namespace :openhab do
fail_on_error("#{@karaf_client} 'system:version'")
true
else
cmd = TTY::Command.new(printer: :null)
cmd = TTY::Command.new(:printer => :null)
cmd.run!("#{@karaf_client} 'system:version'").success?
end
end
Expand Down

0 comments on commit cbab728

Please sign in to comment.