ruco 0.2.0.beta7 → 0.2.0.beta8

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.beta7
1
+ 0.2.0.beta8
data/bin/ruco CHANGED
@@ -22,6 +22,7 @@ BANNER
22
22
  opts.on("-c", "--convert-tabs","Convert tabs to spaces") { options[:convert_tabs] = true }
23
23
  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
24
  opts.on("-n", "--no-colors","No colors -- helps performance / broken terminals") { options[:no_colors] = true }
25
+ opts.on("--colors","Force colors -- everything could be black") { options[:colors] = true }
25
26
  opts.on("--debug-cache","Show caching in action") { options[:debug_cache] = true }
26
27
  opts.on("--debug-keys", "Show pressed keys") { options[:debug_keys] = true }
27
28
  opts.on("-v", "--version","Show Version"){
@@ -45,23 +46,37 @@ def log(stuff)
45
46
  File.open('ruco.log','ab'){|f| f.puts stuff }
46
47
  end
47
48
 
48
- # do not use colors if told so or the terminal does not support colors
49
- # so far the only terminal that supports it is xterm-256color
50
- # but just setting ENV['TERM'] to it will crash un-rescue-able
49
+ # do not use colors if the terminal does not support colors
50
+ # so far the only terminal that supports it:
51
+ # - xterm-256color on osx (not ssh)
52
+ # - xterm on ubuntu (not ssh)
53
+ # (setting ENV['TERM'] will sometimes crash un-rescue-able -> test if it works)
51
54
  def activate_256_colors
55
+ require 'ruco/file_store'
52
56
  (
53
- RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ and # and not windows
54
- # and its possible to open xterm-256color
57
+ # not windows
58
+ RbConfig::CONFIG['host_os'] !~ /mswin|mingw/ and
59
+
60
+ # possible to open xterm-256color
61
+ ['xterm', 'xterm-256color'].include?(ENV['TERM']) and
55
62
  Ruco::FileStore.new('~/.ruco/cache').cache('color_possible'){
56
63
  system(%{TERM=xterm-256color ruby -r curses -e 'Curses.noecho' > /dev/null 2>&1})
57
64
  }
58
- ) and ENV['TERM'] = 'xterm-256color' # finally switch terminal
65
+
66
+ # finally switch terminal, so curses knows we want colors
67
+ ) and ENV['TERM'] = 'xterm-256color'
59
68
  end
60
69
 
61
70
  options = parse_options
62
71
 
63
- require 'ruco/file_store'
64
- $ruco_colors = activate_256_colors unless options[:no_colors]
72
+ $ruco_colors = if options[:no_colors]
73
+ false
74
+ elsif options[:colors]
75
+ true
76
+ else
77
+ activate_256_colors
78
+ end
79
+
65
80
  require 'ruco'
66
81
 
67
82
  # draw app and redraw after each keystroke (or paste)
@@ -5,7 +5,7 @@ require "ruco/core_ext/file"
5
5
  module Ruco
6
6
  class FileStore
7
7
  def initialize(folder, options={})
8
- @folder = folder
8
+ @folder = File.expand_path(folder)
9
9
  @options = options
10
10
  end
11
11
 
data/ruco.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruco}
8
- s.version = "0.2.0.beta7"
8
+ s.version = "0.2.0.beta8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
@@ -92,4 +92,10 @@ describe Ruco::FileStore do
92
92
  store.set('xxx','yyy')
93
93
  File.read(store.file('xxx')).should == 'yyy'
94
94
  end
95
+
96
+ it "works without colors" do
97
+ store = Ruco::FileStore.new(@folder)
98
+ store.set('xxx',1)
99
+ store.get('xxx').should == 1
100
+ end
95
101
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruco
3
3
  version: !ruby/object:Gem::Version
4
- hash: 62196365
4
+ hash: 62196371
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
9
  - 0
10
10
  - beta
11
- - 7
12
- version: 0.2.0.beta7
11
+ - 8
12
+ version: 0.2.0.beta8
13
13
  platform: ruby
14
14
  authors:
15
15
  - Michael Grosser