ruco 0.2.0.beta10 → 0.2.0.beta11

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0.beta10
1
+ 0.2.0.beta11
@@ -76,3 +76,23 @@ module OpenURI
76
76
  silence_warnings{ ::OpenSSL::SSL.const_set :VERIFY_PEER, old }
77
77
  end
78
78
  end
79
+
80
+ class Object
81
+ def memoize(*names)
82
+ names.each do |name|
83
+ unmemoized = "__unmemoized_#{name}"
84
+ class_eval %{
85
+ alias :#{unmemoized} :#{name}
86
+ private :#{unmemoized}
87
+ def #{name}(*args)
88
+ cache = (@#{unmemoized} ||= {})
89
+ if cache.has_key?(args)
90
+ cache[args]
91
+ else
92
+ cache[args] = send(:#{unmemoized}, *args).freeze
93
+ end
94
+ end
95
+ }
96
+ end
97
+ end
98
+ end
@@ -72,20 +72,17 @@ module Ruco
72
72
  end
73
73
 
74
74
  def style_for_syntax_element(syntax_element)
75
- @style_for_element ||= {}
76
- @style_for_element[syntax_element] ||= begin
77
- _, style = theme.styles.detect{|name,style| syntax_element.start_with?(name) }
78
- style
79
- end
75
+ _, style = theme.styles.detect{|name,style| syntax_element.start_with?(name) }
76
+ style
80
77
  end
78
+ memoize :style_for_syntax_element
81
79
 
82
80
  def theme
83
- @theme ||= begin
84
- file = download_into_file(@options[:color_theme]) if @options[:color_theme]
85
- file ||= DEFAULT_THEME
86
- Ruco::TMTheme.new(file)
87
- end
81
+ file = download_into_file(@options[:color_theme]) if @options[:color_theme]
82
+ file ||= DEFAULT_THEME
83
+ Ruco::TMTheme.new(file)
88
84
  end
85
+ memoize :theme
89
86
 
90
87
  def download_into_file(url)
91
88
  theme_store = FileStore.new('~/.ruco/cache', :string => true)
data/lib/ruco/screen.rb CHANGED
@@ -55,12 +55,12 @@ module Ruco
55
55
  Curses.addstr(text);
56
56
  end
57
57
 
58
- def draw_view(view, style_mask)
58
+ def draw_view(view, style_map)
59
59
  lines = view.naive_split("\n")
60
- style_mask = style_mask.flatten
60
+ style_map = style_map.flatten
61
61
 
62
62
  lines.each_with_index do |line, line_number|
63
- styles = style_mask[line_number]
63
+ styles = style_map[line_number]
64
64
 
65
65
  # expand line with whitespace to overwrite previous content
66
66
  missing = columns - line.size
data/ruco.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ruco}
8
- s.version = "0.2.0.beta10"
8
+ s.version = "0.2.0.beta11"
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"]
12
- s.date = %q{2011-10-02}
12
+ s.date = %q{2011-10-03}
13
13
  s.default_executable = %q{ruco}
14
14
  s.email = %q{michael@grosser.it}
15
15
  s.executables = ["ruco"]
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: 62196375
4
+ hash: 62196373
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
9
  - 0
10
10
  - beta
11
- - 10
12
- version: 0.2.0.beta10
11
+ - 11
12
+ version: 0.2.0.beta11
13
13
  platform: ruby
14
14
  authors:
15
15
  - Michael Grosser
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-10-02 00:00:00 +02:00
20
+ date: 2011-10-03 00:00:00 +02:00
21
21
  default_executable: ruco
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency