kronk 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,11 @@
1
+ === 1.2.3 / 2011-02-20
2
+
3
+ * Bugfixes:
4
+
5
+ * Updated bash completion to display full URLs.
6
+
7
+ * Only URLs (not local file paths) are now written to the completion history.
8
+
1
9
  === 1.2.2 / 2011-02-19
2
10
 
3
11
  * Enhancements:
@@ -11,7 +11,7 @@ require 'yaml'
11
11
  class Kronk
12
12
 
13
13
  # This gem's version.
14
- VERSION = '1.2.2'
14
+ VERSION = '1.2.3'
15
15
 
16
16
 
17
17
  ##
@@ -186,6 +186,8 @@ class Kronk
186
186
  # Returns cmd_opts Hash if none found.
187
187
 
188
188
  def self.merge_options_for_uri uri, cmd_opts={}
189
+ return cmd_opts if config[:no_uri_options]
190
+
189
191
  out_opts = Hash.new.merge cmd_opts
190
192
 
191
193
  config[:uri_options].each do |matcher, options|
@@ -297,15 +299,22 @@ class Kronk
297
299
 
298
300
 
299
301
  ##
300
- # Writes the given URIs to the history file.
302
+ # Returns the Kronk history array of accessed URLs.
301
303
 
302
- def self.save_history *uris
304
+ def self.history
303
305
  path = self.config[:history_file]
306
+ @history ||= File.read(path).split($/) if File.file?(path)
307
+ @history ||= []
308
+ @history
309
+ end
304
310
 
305
- uris.concat File.readlines(path).map{|line| line.strip} if File.file?(path)
306
311
 
307
- File.open path, "w" do |file|
308
- file.write uris.uniq.join($/)
312
+ ##
313
+ # Writes the URL history to the history file.
314
+
315
+ def self.save_history
316
+ File.open self.config[:history_file], "w" do |file|
317
+ file.write self.history.uniq.join($/)
309
318
  end
310
319
  end
311
320
 
@@ -416,6 +425,7 @@ class Kronk
416
425
 
417
426
  at_exit do
418
427
  save_cookie_jar
428
+ save_history
419
429
  end
420
430
 
421
431
  options[:cache_response] = config[:cache_file] if config[:cache_file]
@@ -430,15 +440,12 @@ class Kronk
430
440
  $stdout << "Found #{diff.count} diff(s).\n"
431
441
  end
432
442
 
433
- save_history uri1, uri2
434
443
  exit 1 if diff.count > 0
435
444
 
436
445
  else
437
446
  out = retrieve_data_string uri1, options
438
447
  out = Diff.insert_line_nums out if config[:show_lines]
439
448
  puts out
440
-
441
- save_history uri1
442
449
  end
443
450
 
444
451
  rescue Request::NotFoundError, Response::MissingParser => e
@@ -571,6 +578,11 @@ Parse and run diffs against data from live and cached http responses.
571
578
  end
572
579
 
573
580
 
581
+ opt.on('--no-opts', 'Turn off config URI options') do
582
+ config[:no_uri_options] = true
583
+ end
584
+
585
+
574
586
  opt.on('--parser STR', String,
575
587
  'Override default parser') do |value|
576
588
  options[:parser] = value
@@ -47,15 +47,15 @@ class Kronk
47
47
  # :http_method:: Symbol - the http method to use; defaults to :get
48
48
  # :proxy:: Hash/String - http proxy to use; defaults to nil
49
49
 
50
- def self.retrieve query, options={}
51
- resp =
52
- if IO === query || StringIO === query
53
- retrieve_io query, options
54
- elsif query == :cache || File.file?(query)
55
- retrieve_file query, options
56
- else
57
- retrieve_uri query, options
58
- end
50
+ def self.retrieve uri, options={}
51
+ if IO === uri || StringIO === uri
52
+ resp = retrieve_io uri, options
53
+ elsif uri == :cache || File.file?(uri)
54
+ resp = retrieve_file uri, options
55
+ else
56
+ resp = retrieve_uri uri, options
57
+ Kronk.history << uri
58
+ end
59
59
 
60
60
  begin
61
61
  File.open(options[:cache_response], "wb+") do |file|
@@ -67,7 +67,7 @@ class Kronk
67
67
 
68
68
  resp
69
69
  rescue SocketError, Errno::ENOENT, Errno::ECONNREFUSED
70
- raise NotFoundError, "#{query} could not be found"
70
+ raise NotFoundError, "#{uri} could not be found"
71
71
  end
72
72
 
73
73
 
@@ -229,7 +229,7 @@ class Kronk
229
229
  # path and options.
230
230
 
231
231
  def self.build_uri uri, options={}
232
- suffix = options.delete :uri_suffix
232
+ suffix = options[:uri_suffix]
233
233
 
234
234
  uri = "http://#{uri}" unless uri =~ %r{^(\w+://|/)}
235
235
  uri = "#{uri}#{suffix}" if suffix
@@ -1,22 +1,21 @@
1
1
  #!/bin/bash
2
2
 
3
+ export COMP_WORDBREAKS=${COMP_WORDBREAKS/\:/}
4
+
3
5
  _kronk()
4
6
  {
5
- local cur prev opts kronk_keys
6
- COMPREPLY=()
7
+ local cur kronk_keys
8
+
7
9
  cur="${COMP_WORDS[COMP_CWORD]}"
8
- prev="${COMP_WORDS[COMP_CWORD-1]}"
9
10
 
10
11
  kronk_keys="$HOME/.kronk_history"
11
12
 
12
-
13
13
  if [ -f "$kronk_keys" ]; then
14
- opts=$(cat $kronk_keys)
15
- COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
14
+ COMPREPLY=( $(compgen -W "$(cat $kronk_keys)" -- ${cur}) )
16
15
  return 0
17
16
  fi
18
17
 
19
18
  return 1
20
19
  }
21
20
 
22
- complete -d -X '.[^./]*' -F _kronk kronk
21
+ complete -o default -F _kronk kronk
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kronk
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 2
10
- version: 1.2.2
9
+ - 3
10
+ version: 1.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jeremie Castagna
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-02-21 00:00:00 -08:00
18
+ date: 2011-02-22 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency