Class: Agen::Runner
- Inherits:
-
Object
- Object
- Agen::Runner
- Defined in:
- lib/agen/runner.rb
Constant Summary collapse
- CONFIG_FILE =
"#{Dir.home}/.agen"
- DEFAULT_HISTFILE =
ZshOptions::HISTFILE
- DEFAULT_RCFILE =
ZshOptions::RCFILE
- DEFAULT_NUMBER =
5
Instance Attribute Summary collapse
-
#histfile ⇒ Object
readonly
Returns the value of attribute histfile.
-
#rcfile ⇒ Object
readonly
Returns the value of attribute rcfile.
Instance Method Summary collapse
-
#initialize(histfile: DEFAULT_HISTFILE, rcfile: DEFAULT_RCFILE, number: DEFAULT_NUMBER, auto: false, config_file: CONFIG_FILE) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Constructor Details
#initialize(histfile: DEFAULT_HISTFILE, rcfile: DEFAULT_RCFILE, number: DEFAULT_NUMBER, auto: false, config_file: CONFIG_FILE) ⇒ Runner
Returns a new instance of Runner.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/agen/runner.rb', line 12 def initialize( histfile: DEFAULT_HISTFILE, rcfile: DEFAULT_RCFILE, number: DEFAULT_NUMBER, auto: false, config_file: CONFIG_FILE ) @histfile = histfile @rcfile = rcfile @number = number @auto = auto @config_file = config_file end |
Instance Attribute Details
#histfile ⇒ Object (readonly)
Returns the value of attribute histfile.
10 11 12 |
# File 'lib/agen/runner.rb', line 10 def histfile @histfile end |
#rcfile ⇒ Object (readonly)
Returns the value of attribute rcfile.
10 11 12 |
# File 'lib/agen/runner.rb', line 10 def rcfile @rcfile end |
Instance Method Details
#run ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/agen/runner.rb', line 26 def run commands = Finder.new(histfile).commands(limit: @number) @builder = Builder.new(commands, rcfile) aliases = builder.aliases # TODO: This could be its own class too File.open(rcfile, "a") do |file| puts "Writing new aliases to #{rcfile}:\n\n" aliases.each do |al| if auto write_auto(file, al[:full_alias]) else write_interactive(file, al) end end end end |