class Object

Public Instance Methods

URI(str) click to toggle source
# File lib/hub/speedy_stdlib.rb, line 30
def URI(str)
  URI.parse(str)
end
announcer() click to toggle source

Aruba unnecessarily creates new Announcer instance on each invocation

Calls superclass method
# File features/support/env.rb, line 149
def announcer
  @announcer ||= super
end
assert_command_run(cmd) click to toggle source
# File features/support/env.rb, line 110
def assert_command_run cmd
  cmd += "\n" unless cmd[-1..-1] == "\n"
  history.should include(cmd)
end
edit_hub_config() { |data| ... } click to toggle source
# File features/support/env.rb, line 115
def edit_hub_config
  config = File.join(ENV['HOME'], '.config/hub')
  FileUtils.mkdir_p File.dirname(config)
  if File.exist? config
    data = YAML.load File.read(config)
  else
    data = {}
  end
  yield data
  File.open(config, 'w') { |cfg| cfg << YAML.dump(data) }
end
empty_commit(message = nil) click to toggle source
# File features/support/env.rb, line 143
def empty_commit(message = nil)
  message ||= 'empty'
  run_silent "git commit --quiet -m '#{message}' --allow-empty"
end
history() click to toggle source
# File features/support/env.rb, line 101
def history
  histfile = File.join(ENV['HOME'], '.history')
  if File.exist? histfile
    File.readlines histfile
  else
    []
  end
end
matches?(body, content_type = "") click to toggle source
# File test/hub_test.rb, line 16
def matches?(body, content_type = "")
  content_type = content_type.split(';').first if content_type.respond_to? :split
  matches_with_dumb_content_type(body, content_type)
end
matches_with_dumb_content_type(body, content_type = "")

strip out the “charset” directive from Content-type value

Alias for: matches?
normalize_hash(hash) click to toggle source

override normalizing hash since it otherwise requires JSON

# File test/hub_test.rb, line 12
def normalize_hash(hash) hash end
run_silent(cmd) click to toggle source
# File features/support/env.rb, line 135
def run_silent cmd
  in_current_dir do
    command = SimpleCommand.run(cmd)
    command.should be_successful_command
    command.output
  end
end
set_shell(shell) click to toggle source
# File features/support/completion.rb, line 98
def set_shell(shell)
  @shell = shell
end
tmux_completion_menu() click to toggle source
# File features/support/completion.rb, line 155
def tmux_completion_menu
  tmux_wait_for_completion
  hash = {}
  tmux_pane_contents.split("\n").grep(/^[^\$].+ -- /).each { |line|
    item, description = line.split(/ +-- +/, 2)
    hash[item] = description
  }
  hash
end
tmux_completion_menu_basic() click to toggle source
# File features/support/completion.rb, line 165
def tmux_completion_menu_basic
  tmux_wait_for_completion
  tmux_pane_contents.split("\n").grep(/^[^\$]/).map {|line|
    line.split(/\s+/)
  }.flatten
end
tmux_kill_pane() click to toggle source
# File features/support/completion.rb, line 127
def tmux_kill_pane
  system(*($tmux + ['kill-pane', '-t', tmux_pane])) if tmux_pane?
end
tmux_pane?() click to toggle source
# File features/support/completion.rb, line 109
def tmux_pane?
  defined?(@tmux_pane) && @tmux_pane
end
tmux_pane_contents() click to toggle source
# File features/support/completion.rb, line 113
def tmux_pane_contents
  system(*($tmux + ['capture-pane', '-t', tmux_pane]))
  %x#{$tmux.join(' ')} show-buffer`.rstrip
end
tmux_send_keys(*keys) click to toggle source
# File features/support/completion.rb, line 118
def tmux_send_keys(*keys)
  system(*($tmux + ['send-keys', '-t', tmux_pane, *keys]))
end
tmux_send_tab() click to toggle source
# File features/support/completion.rb, line 122
def tmux_send_tab
  @last_pane_contents = tmux_pane_contents
  tmux_send_keys('Tab')
end
tmux_wait_for_completion() { || ... } click to toggle source
# File features/support/completion.rb, line 140
def tmux_wait_for_completion
  num_waited = 0
  raise "tmux_send_tab not called first" unless defined? @last_pane_contents
  while tmux_pane_contents == @last_pane_contents
    if num_waited > 300
      if block_given? then return yield
      else
        raise "timeout while waiting for completions to expand"
      end
    end
    sleep 0.01
    num_waited += 1
  end
end
tmux_wait_for_prompt() click to toggle source
# File features/support/completion.rb, line 131
def tmux_wait_for_prompt
  num_waited = 0
  while tmux_pane_contents !~ /\$\Z/
    raise "timeout while waiting for shell prompt" if num_waited > 300
    sleep 0.01
    num_waited += 1
  end
end