ruco 0.2.23 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9d1f30802a00cd4515ab57e95417416dd32e0aa8
4
- data.tar.gz: 07e2e4b5891cdab09e0f503f7bbb37420fe24689
2
+ SHA256:
3
+ metadata.gz: 906292a945bfa6f268ee461f69e3f9dc698864cc777ca9a6fabc48db2009c427
4
+ data.tar.gz: e2bf50d323b6f807c60fa70006e6b2d153e604929aa6bfff2d13ac2f67794db2
5
5
  SHA512:
6
- metadata.gz: 2f6d53b47b533e328bafc5c3a2fcd7791d28593182aa8571fc9f5d5e4ad56864c3a6b1e3b3f5d9043b9efc190ddd137540a0f882e9d2f14b78c6c7fe54a705e0
7
- data.tar.gz: 15b659678713c3c94c29b95650976e0efef15ea23775b8af418efe2fc7f5faf56e039f0aa5db7a2ff47c8e9c2f681b4beac2fe3f87f0107f298d7e245c811629
6
+ metadata.gz: 1d825c984c209ba1b547136c0a2b1b4618c82d85c05e0b407d78f0967751dcde25f2b22cc27647aa9264d1f8e6818d1f58d865e4b29114c6d09299ea3cc73098
7
+ data.tar.gz: b6ae20158834cccfeef78a9ed48f27d3a950adadd2cd6c0975e4cd80df13b778c2697f3e3f86eb73f9770e3d5243cd8a4f64bd78dde9298c6c2af12c6e7d8f03
data/bin/ruco CHANGED
@@ -1,37 +1,36 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
- require 'rubygems'
4
- gem 'clipboard'
5
2
  require 'curses'
6
3
  require 'optparse'
7
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+
5
+ lib = File.expand_path("../../lib", __FILE__)
6
+ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib) # enable local development
8
7
 
9
8
  def parse_options
10
9
  options = {}
11
10
  parser = OptionParser.new do |opts|
12
- opts.banner = <<BANNER
13
- [Ru]by [Co]mmandline editor
11
+ opts.banner = <<-BANNER.gsub(/^ {6}/, "")
12
+ [Ru]by [Co]mmandline editor
14
13
 
15
- Shortcuts:
16
- Ctrl+w/q Exit
17
- Ctrl+s Save
14
+ Shortcuts:
15
+ Ctrl+w/q Exit
16
+ Ctrl+s Save
18
17
 
19
- Usage:
20
- ruco FILE
18
+ Usage:
19
+ ruco FILE
21
20
 
22
- Options:
23
- BANNER
21
+ Options:
22
+ BANNER
24
23
  opts.on("-c", "--convert-tabs","Convert tabs to spaces") { options[:convert_tabs] = true }
25
- opts.on("-u", "--undo-stack-size SIZE","Maximum size of the undo stack. 0 allows for a complete undo stack.") {|size| options[:undo_stack_size] = size.to_i }
24
+ opts.on("-u", "--undo-stack-size SIZE","Maximum size of the undo stack. 0 allows for a complete undo stack.") { |size| options[:undo_stack_size] = size.to_i }
26
25
  opts.on("-n", "--no-colors","No colors -- helps performance / broken terminals") { options[:no_colors] = true }
27
26
  opts.on("--colors","Force colors -- everything could be black") { options[:colors] = true }
28
27
  opts.on("--debug-cache","Show caching in action") { options[:debug_cache] = true }
29
28
  opts.on("--debug-keys", "Show pressed keys") { options[:debug_keys] = true }
30
- opts.on("-v", "--version","Show Version"){
29
+ opts.on("-v", "--version","Show Version") do
31
30
  require 'ruco/version'
32
31
  puts Ruco::VERSION
33
32
  exit
34
- }
33
+ end
35
34
  opts.on("-h", "--help","Show this.") { puts opts; exit }
36
35
  end
37
36
  parser.parse!
@@ -45,7 +44,7 @@ BANNER
45
44
  end
46
45
 
47
46
  def log(stuff)
48
- File.open('ruco.log','ab'){|f| f.puts stuff }
47
+ File.open('ruco.log','ab') { |f| f.puts stuff }
49
48
  end
50
49
 
51
50
  options = parse_options
@@ -82,7 +81,8 @@ require 'ruco'
82
81
  Dispel::Screen.open(options) do |screen|
83
82
  $ruco_screen = screen
84
83
 
85
- app = Ruco::Application.new(ARGV[0],
84
+ app = Ruco::Application.new(
85
+ ARGV[0],
86
86
  :convert_tabs => options[:convert_tabs],
87
87
  :undo_stack_size => options[:undo_stack_size],
88
88
  :lines => screen.lines, :columns => screen.columns
@@ -6,6 +6,7 @@ module Ruco
6
6
  @file, go_to_line = parse_file_and_line(file)
7
7
  @options = OptionAccessor.new(options)
8
8
 
9
+ change_terminal_title
9
10
  setup_actions
10
11
  setup_keys
11
12
  load_user_config
@@ -121,6 +122,14 @@ module Ruco
121
122
 
122
123
  private
123
124
 
125
+ # http://stackoverflow.com/questions/3232655
126
+ # terminal tab in iterm2 holds 23 characters by default
127
+ def change_terminal_title
128
+ print "\e[22;0;t"
129
+ print "\e]0;#{@file.ellipsize(max: 23)}\007;"
130
+ at_exit { print "\e[23;0;t" }
131
+ end
132
+
124
133
  def setup_actions
125
134
  @actions = {}
126
135
 
data/lib/ruco/editor.rb CHANGED
@@ -14,14 +14,15 @@ module Ruco
14
14
  def initialize(file, options)
15
15
  @file = file
16
16
  @options = options
17
+ handle = (File.exist?(file) ? File.open(file, 'rb') : nil)
17
18
 
18
19
  # check for size (10000 lines * 100 chars should be enough for everybody !?)
19
- if File.exist?(@file) and File.size(@file) > (1024 * 1024)
20
+ if handle&.size.to_i > 1024 * 1024
20
21
  raise "#{@file} is larger than 1MB, did you really want to open that with Ruco?"
21
22
  end
22
23
 
23
- content = (File.exist?(@file) ? File.binary_read(@file) : '')
24
- @options[:language] ||= LanguageSniffer.detect(@file, :content => content).language
24
+ content = handle&.read || ''
25
+ @options[:language] ||= LanguageSniffer.detect(@file, content: content).language
25
26
  content.tabs_to_spaces! if @options[:convert_tabs]
26
27
 
27
28
  # cleanup newline formats
@@ -33,6 +34,9 @@ module Ruco
33
34
  @text_area = EditorArea.new(content, @options)
34
35
  @history = @text_area.history
35
36
  restore_session
37
+
38
+ # git and kubectl wait for the file to be closed, so give them that event
39
+ at_exit { handle&.close }
36
40
  end
37
41
 
38
42
  def find(text)
data/lib/ruco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ruco
2
- VERSION = Version = "0.2.23"
2
+ VERSION = Version = "0.4.0"
3
3
  end
data/lib/ruco.rb CHANGED
@@ -26,9 +26,6 @@ require 'ruco/application'
26
26
 
27
27
  if $ruco_colors
28
28
  begin
29
- # this can fail on ruby 1.8 <-> oniguruma is complicated to install
30
- require 'oniguruma' if RUBY_VERSION < '1.9.0'
31
-
32
29
  # there are some other gems out there like spox-textpow etc, so be picky
33
30
  gem 'plist'
34
31
  require 'plist'
metadata CHANGED
@@ -1,72 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.23
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-22 00:00:00.000000000 Z
11
+ date: 2023-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clipboard
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.9.8
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.8
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: textpow
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: language_sniffer
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: dispel
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.0.7
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.0.7
69
- description:
69
+ description:
70
70
  email: michael@grosser.it
71
71
  executables:
72
72
  - ruco
@@ -117,19 +117,19 @@ require_paths:
117
117
  - lib
118
118
  required_ruby_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
- version: 2.0.0
122
+ version: 2.7.0
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
- - - '>='
125
+ - - ">="
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubyforge_project:
130
- rubygems_version: 2.0.14
131
- signing_key:
129
+ rubygems_version: 3.4.10
130
+ signing_key:
132
131
  specification_version: 4
133
132
  summary: Desktop-style, Intuitive, Commandline Editor in Ruby. 'Better than nano,
134
133
  simpler than vim.'
135
134
  test_files: []
135
+ ...