jota 0.9.0 → 0.9.1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ee214349016008f404c9966b9f83e418d1eeb88a
4
+ data.tar.gz: 76b0575c605a2dee7bf57a639d59009512db8845
5
+ SHA512:
6
+ metadata.gz: 798f6e9dde5ce32311e83c6429f285b07b73310821116f023a9fb304e3f168f54d220d7f8798f451c0d3d5edb33ade9d16012d8e9a4958ae12840919853e7a78
7
+ data.tar.gz: 05123f07dd8269d10c32a0715f36fe1cdf7b3a561526c34462a03197182bd9e3cc02cfc80f9337742458d3a526c083edbc0aa8e13751b7259aa6a2bbf83e5132
data/INSTALL CHANGED
@@ -1,20 +1,23 @@
1
1
 
2
- Jota is a written in the Ruby programming language and uses GTK+ Widgets.
2
+ Jota is a written in the Ruby programming language and uses GTK+
3
+ Widgets.
3
4
 
4
- Before you can install Jota you must install the Ruby programming language
5
- and the GTK+ widget set.
5
+ Before you can install Jota you must install the Ruby programming
6
+ language and the GTK+ widget set.
6
7
 
7
8
  You need:
8
9
 
9
10
  - The Ruby language: compiler, runtime, libraries
10
- - Gem: The Ruby package manager. Sometimes included in the Ruby package
11
- - Build tools (optional): If you want to install the GTK+ bindings with Ruby's
12
- package manager 'gem', you need the so called build tools, like
13
- C-compiler, linker, make-tools, and so on. The build tools are needed,
14
- because the system dependent parts of the GTK+ gem are compiled during
15
- installation.
16
- - GTK+: The graphics library and widget set, known from Gnome and Gimp
17
- - GTK+ Bindings for Ruby: A library so that you can access GTK+ from Ruby
11
+
12
+ - Build tools (optional): If you want to install the GTK+ bindings
13
+ with Ruby's package manager 'gem', you need the so called build
14
+ tools, like C-compiler, linker, make-tools, and so on. The build
15
+ tools are needed, because the system dependent parts of the GTK+
16
+ gem are compiled during installation.
17
+ - GTK+: The graphics library and widget set, known from Gnome and
18
+ Gimp
19
+ - GTK+ Bindings for Ruby: A library so that you can access GTK+ from
20
+ Ruby
18
21
  - Jota: Finally Jota itself. This is also a Ruby gem.
19
22
 
20
23
 
@@ -23,61 +26,34 @@ INSTALLING
23
26
 
24
27
  For the most common operating systems the steps are as follows:
25
28
 
26
- Ubuntu/Debian Linux
27
- -------------------
28
- (Tested with Ubuntu 11.04 and Debian 6.0 (squeeze))
29
+ Mint/Ubuntu/Debian Linux
30
+ ------------------------
31
+ (Tested with Mint 17, Ubuntu 14.04 LTS and Debian 7 (wheezy))
29
32
 
30
- Install Ruby + Gems:
31
- apt-get install ruby rubygems
33
+ Install Ruby + GTK+:
34
+ apt-get install ruby ruby-gtk2
32
35
 
33
- Install GTK+ + Ruby bindings:
34
- apt-get install libgtk2-ruby # (recommended)
35
- or
36
- apt-get install build-essential
37
- gem install gtk2
38
-
39
36
  Install Jota:
40
- gem install jota # (recommended)
41
- or
42
- Download a jota-VER.gem from http://rubygems.org/gems/jota. VER stand
43
- for the version you are looking for.
44
- gem install jota-VER.gem
37
+ gem install jota
45
38
 
46
39
  Call Jota:
47
- or
48
- /var/lib/gems/1.8/bin/jota
49
- or
50
- Append the line
51
- PATH="$PATH:/var/lib/gems/1.8/bin"
52
- to $HOME/.bashrc (or consult your shell's manpage for the correct file
53
- and/or syntax)
54
-
55
- Then you can invoke Jota by calling jota
56
-
57
- (Please see https://launchpad.net/bugs/145267 for details, why invoking
58
- a gem is not straight forward on Ubuntu)
40
+ jota
59
41
 
60
42
 
61
43
  Fedora Linux
62
44
  ------------
63
- (Tested with Fedora 14)
45
+ (Tested with Fedora 21)
64
46
 
65
- Install Ruby + Gems:
66
- yum install ruby rubygems
47
+ Install Ruby + GTK+:
48
+ yum install ruby ruby-gtk2
67
49
 
68
- Install GTK+ + Ruby bindings:
69
- yum install ruby-gtk2 # (recommended)
70
- or
71
- yum groupinstall "Development Tools" "Legacy Software Development"
72
- yum install gtk2-devel
73
- gem install gtk2
50
+ You need to install the curses (text-mode) library seperately:
51
+ yum groups install 'Development Tools'
52
+ yum install ruby-devel ncurses-devel
53
+ gem install curses
74
54
 
75
55
  Install Jota:
76
- gem install jota # (recommended)
77
- or
78
- Download a jota-VER.gem from http://rubygems.org/gems/jota. VER stand
79
- for the version you are looking for.
80
- gem install jota-VER.gem
56
+ gem install jota
81
57
 
82
58
  Call Jota:
83
59
  jota
@@ -85,23 +61,23 @@ Call Jota:
85
61
 
86
62
  OpenSUSE Linux
87
63
  --------------
88
- (Tested with OpenSUSE 11.4)
64
+ (Tested with OpenSUSE 13.2)
89
65
 
90
- Install Ruby + Gems:
91
- zypper install ruby rubygems
66
+ Install Ruby:
67
+ zypper install ruby ruby-devel
92
68
 
93
69
  Install GTK+ + Ruby bindings:
94
70
  zypper install -t pattern devel_C_C++
95
- (There is no prebuild ruby-gtk package, therefore we need this
71
+ (There is no prebuild ruby-gtk package, therefore we need this
96
72
  cumbersome way to install the Ruby bindings for GTK+.)
97
73
  gem install gtk2
98
74
 
75
+ You need to install the curses (text-mode) library seperately:
76
+ gem install curses
77
+
99
78
  Install Jota:
100
- gem install jota # (recommended)
101
- or
102
- Download a jota-VER.gem from http://rubygems.org/gems/jota. VER stand
103
- for the version you are looking for.
104
- gem install jota-VER.gem
79
+ gem install jota
80
+ ln -s `gem contents jota|grep bin/jota` /usr/local/bin/
105
81
 
106
82
  Call Jota:
107
83
  jota
@@ -109,23 +85,16 @@ Call Jota:
109
85
 
110
86
  FreeBSD
111
87
  -------
112
- (Tested with FreeBSD 8.2)
113
-
114
- Install Ruby + Gems:
115
- cd /usr/ports/lang/ruby18; make install # (Select OK)
116
- cd /usr/ports/devel/ruby-gems; make install
88
+ (Tested with FreeBSD 10.1)
117
89
 
118
- Install GTK+ + Ruby bindings:
119
- cd /usr/ports/x11-toolkits/ruby-gem2; make install # (recommended)
120
- or
121
- gem install gtk2
90
+ Install Ruby + GTK+:
91
+ pkg install ruby rubygem-gtk2
122
92
 
123
93
  Install Jota:
124
- gem install jota # (recommended)
125
- or
126
- Download a jota-VER.gem from http://rubygems.org/gems/jota. VER stand
127
- for the version you are looking for.
128
- gem install jota-VER.gem
94
+ gem install jota
95
+
96
+ You need to install the curses (text-mode) library seperately:
97
+ gem install curses
129
98
 
130
99
  Call Jota:
131
100
  jota
@@ -133,44 +102,43 @@ Call Jota:
133
102
 
134
103
  Windows
135
104
  -------
136
- (Tested with Windows XP)
105
+ (Tested with Windows 7)
137
106
 
138
107
  Install Ruby + Gems:
139
108
  Goto http://rubyinstaller.org
140
- Download the latest 1.8.x version (at least 1.8.7)
141
- Install
142
- Install into default folder (like c:\Ruby187)
143
- Check box: Add Ruby executable to your PATH
144
- Check box: Associate .rb and .rbw files with this Ruby installation
109
+ Download the latest 2.0.x version, 32 bit
110
+ (the 64 bit versions and rubies prior to 2.0 don't have a
111
+ precompiled gtk2 gem, and 2.1.x not yet)
112
+ Install
113
+ Install into default folder (like C:\Ruby200)
114
+ Check: Add Ruby executable to your PATH
115
+ Check: Associate .rb and .rbw files with this Ruby installation
145
116
 
146
117
  Install GTK+ + Ruby bindings:
147
- Execute (1): gem install gtk2
118
+ Execute (1,3): gem install gtk2
148
119
 
149
120
  Install Jota:
150
- Execute (1): gem install jota # (recommended)
151
- or
152
- Download a jota-VER.gem from http://rubygems.org/gems/jota. VER stands
153
- for the version you are looking for.
154
- Execute (1): gem install jota-VER.gem
121
+ Execute (1,3): gem install jota
155
122
 
156
123
  Call Jota:
157
124
  Execute(1): jota
158
125
  or
159
- Create a shortcut and point it to
160
- "C:\Ruby187\bin\rubyw C:\Ruby187\bin\jota" (2)
161
-
162
- When you call jota with rubyw instead of ruby, you won't get a command
163
- window hanging around.
126
+ Create a shortcut of "C:\Ruby200\bin\jota" (2)
164
127
 
128
+ Optimize batch script:
129
+ Edit (2) "C:\Ruby200\bin\jota.bat" and change the calls of
130
+ "ruby.exe" to "rubyw.exe" (2 times), then you don't get a cmd window
165
131
 
166
132
  (1) Execute either by
167
- - clicking Start->Run on Windows XP
168
133
  - hitting Win-R
169
134
  - opening a command prompt window (cmd.exe) and entering a command
170
135
 
171
- (2) Use the install path from the first step instead of c:\Ruby187,
172
- if different.
136
+ (2) Use the install path from the first step instead of C:\Ruby200, if
137
+ different.
173
138
 
139
+ (3) If you get an "SSL Connect" Error, append
140
+ "--source=http://rubygems.org" to the command line. Ignore the errors
141
+ after "Installing ri documentation" and "Parsing documention" then.
174
142
 
175
143
 
176
144
  UPDATING
@@ -194,4 +162,3 @@ tools:
194
162
 
195
163
  - rake "make" alternative with ruby syntax
196
164
  - rdoc inline documentation generator
197
- - rtags "tags" for ruby code
data/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2008-2011 Derik van Zuetphen <dz@426.ch>
2
+ Copyright (c) 2008-2015 Derik van Zuetphen <dz@426.ch>
3
3
  All rights reserved.
4
4
 
5
5
  Redistribution and use in source and binary forms, with or without
data/bin/jota CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- # $Id: jota 68 2010-01-04 14:23:45Z dz $
4
3
  begin
5
4
  require 'jota'
6
5
  rescue LoadError
@@ -1,5 +1,3 @@
1
1
 
2
- # $Id: app_error.rb 68 2010-01-04 14:23:45Z dz $
3
-
4
2
  class AppError < StandardError
5
3
  end
@@ -1,6 +1,4 @@
1
1
 
2
- # $Id: clip.rb 296 2011-01-31 10:39:18Z dz $
3
-
4
2
  require 'time'
5
3
  require 'version'
6
4
 
@@ -18,35 +16,36 @@ class Clip
18
16
 
19
17
  attr_accessor :wrap, :title, :created, :pos, :type, :data
20
18
 
21
- def initialize
19
+ def initialize
22
20
  @data = "" # no lines at all, "\n" would be 1 empty line
23
21
  @wrap = false
24
22
  @type = :text
25
23
  @title = ""
26
24
  @created = Time.now
27
25
  @pos = 0
28
- end
26
+ end
29
27
 
30
28
  def Clip.from_mbox(str)
31
29
  # "From_" line already removed
32
30
  cl = Clip.new
33
31
  in_header = true
34
- charset = nil
32
+ charset = "UTF-8"
35
33
  str.each_line do | line |
34
+ line.encode!(charset)
36
35
  if in_header then
37
36
  if line == "\n" then
38
37
  in_header = false
39
38
  next
40
39
  end
41
- #(key, value) = line.split(/\s*:\s*/,2)
40
+ #(key, value) = line.split(/\s*:\s*/,2)
42
41
  # stricter pattern to preserve leading spaces
43
- (key, value) = line.split(/\s*: /,2)
42
+ (key, value) = line.split(/\s*: /,2)
44
43
  value.chomp!
45
44
  case key.downcase
46
45
  when "flags", "x-flags"
47
46
  cl.wrap = value.downcase.include?("w")
48
47
  when "subject"
49
- cl.title,charset = value
48
+ cl.title = value
50
49
  when "created-at", "date"
51
50
  cl.created = Time.parse(value)
52
51
  when "content-type"
@@ -64,7 +63,7 @@ def Clip.from_mbox(str)
64
63
  end
65
64
  end
66
65
  return cl
67
- end
66
+ end
68
67
 
69
68
  def to_mbox
70
69
  str = ""
@@ -73,7 +72,7 @@ def to_mbox
73
72
  str << "Created-At: %s\n" % @created.ctime
74
73
 
75
74
  str << "Subject: %s\n" % @title
76
-
75
+
77
76
  case @type
78
77
  when :text
79
78
  str << "Content-Type: text/plain; charset=#{charset}\n"
@@ -92,7 +91,7 @@ def to_mbox
92
91
  str << @data
93
92
 
94
93
  return str
95
- end
94
+ end
96
95
 
97
96
  def Clip.from_hash(hash)
98
97
  cl = Clip.new
@@ -104,7 +103,7 @@ def Clip.from_hash(hash)
104
103
  cl.created = hash["created"]
105
104
  end
106
105
  return cl
107
- end
106
+ end
108
107
 
109
108
  def to_hash
110
109
  hash = Hash.new
@@ -114,17 +113,17 @@ def to_hash
114
113
  hash["title"] = @title
115
114
  hash["created"] = @created
116
115
  return hash
117
- end
116
+ end
118
117
 
119
118
 
120
119
  def empty?
121
120
  # strip also removes LFs
122
121
  return @data.strip == "" && @title.strip == ""
123
- end
122
+ end
124
123
 
125
124
  def ==(clip)
126
125
  return self.to_hash == clip.to_hash
127
- end
126
+ end
128
127
 
129
128
  # POSSIBLE CASES FOR TEXT <-> TITLE/DATA CONVERSION
130
129
  # text title data
@@ -144,18 +143,18 @@ def text
144
143
  # map (2) to (b) and (3) to (d)
145
144
  return "%s\n%s" % [@title,@data]
146
145
  end
147
- end
146
+ end
148
147
 
149
148
  def text=(str)
150
149
  # map (a),(b) to (c) and (d) to (e)
151
150
  str = str.chomp + "\n"
152
-
151
+
153
152
  # map (c) to (2) and (e) to (3)
154
153
  arr = str.split("\n",-1) # arr has at least 2 elems
155
154
  # the last elem is empty
156
155
  @title = arr[0] # first elem = first line
157
156
  @data = arr[1..-1].join("\n") # second to last elem
158
- end
157
+ end
159
158
 
160
159
  # Return modified title for easier readabiliy
161
160
  # - empty string is replaced with "..."
@@ -164,7 +163,7 @@ def title!
164
163
  if @title.strip == "" then
165
164
  return "..."
166
165
  else
167
-
166
+
168
167
  return expand_tabs(@title)
169
168
  end
170
169
  end
@@ -1,8 +1,4 @@
1
1
 
2
- # $Id: clip_array.rb 273 2010-08-01 11:46:58Z dz $
3
-
4
-
5
-
6
2
  require 'app_error'
7
3
  require 'clip'
8
4
  require 'helper'
@@ -41,20 +37,20 @@ def initialize
41
37
  @filename = nil
42
38
  @pref = Preferences.defaults
43
39
  print_verbose "initializing clip array"
44
- end
40
+ end
45
41
 
46
42
  def <<(clip)
47
43
  push(clip)
48
44
  @current_index = length-1
49
45
  return self
50
- end
46
+ end
51
47
 
52
48
  def set_file(file,file_and_path)
53
49
  @file = file
54
50
  @file_and_path = file_and_path
55
51
  @filename = File.basename(file_and_path)
56
52
  @dirname = File.dirname(file_and_path)
57
- end
53
+ end
58
54
 
59
55
  def goto_regexp(re)
60
56
  return nil if re.nil?
@@ -76,7 +72,7 @@ def goto_regexp(re)
76
72
  end
77
73
  return nil
78
74
  end
79
- end
75
+ end
80
76
 
81
77
  def current_index=(num)
82
78
  if num < 0 then
@@ -87,7 +83,7 @@ def current_index=(num)
87
83
  @current_index = num
88
84
  end
89
85
  print_verbose "going to clip #{@current_index+1}"
90
- end
86
+ end
91
87
 
92
88
  def next
93
89
  if @current_index < length-1 then
@@ -95,7 +91,7 @@ def next
95
91
  print_verbose "going to next clip #{@current_index+1}"
96
92
  end
97
93
  return self
98
- end
94
+ end
99
95
 
100
96
  def prev
101
97
  if @current_index > 0 then
@@ -103,7 +99,7 @@ def prev
103
99
  print_verbose "going to previous clip #{@current_index+1}"
104
100
  end
105
101
  return self
106
- end
102
+ end
107
103
 
108
104
  def delete
109
105
  if @current_index == length-1 then
@@ -120,8 +116,8 @@ def delete
120
116
  else
121
117
  @current_index = new_current_index
122
118
  end
123
-
124
- end
119
+
120
+ end
125
121
 
126
122
  def new
127
123
  if length > 0 and self[length-1].empty? then
@@ -133,11 +129,11 @@ def new
133
129
  @current_index = length-1
134
130
  print_verbose "creating new clip #{@current_index+1}"
135
131
  end
136
- end
132
+ end
137
133
 
138
134
  def current
139
135
  return self[@current_index]
140
- end
136
+ end
141
137
 
142
138
  #
143
139
  # Locking
@@ -152,23 +148,31 @@ def ClipArray.obtain_shared_lock(file)
152
148
  print_debug " cannot lock"
153
149
  #file.flock(File::LOCK_SH) TODO
154
150
  end
155
- end
151
+ end
156
152
 
157
153
  def ClipArray.obtain_exclusive_lock(file)
158
154
  release_lock(file) # necessary for win32
159
155
 
160
- # an exclusive, non-blocking lock
161
- print_debug "obtaining EXCLUSIVE LOCK on '#{file.path}'"
162
- if not file.flock(File::LOCK_EX|File::LOCK_NB) then
163
- print_debug " cannot lock"
164
- #file.flock(File::LOCK_EX) TODO
156
+ begin
157
+ # an exclusive, non-blocking lock
158
+ print_debug "obtaining EXCLUSIVE LOCK on '#{file.path}'"
159
+ if not file.flock(File::LOCK_EX|File::LOCK_NB) then
160
+ print_debug " cannot lock"
161
+ #file.flock(File::LOCK_EX) TODO
162
+ end
163
+ rescue Exception => e
164
+ print_debug "#{e}";
165
165
  end
166
- end
166
+ end
167
167
 
168
168
  def ClipArray.release_lock(file)
169
- print_debug "releasing LOCK from '#{file.path}'"
170
- file.flock(File::LOCK_UN)
171
- end
169
+ begin
170
+ print_debug "releasing LOCK from '#{file.path}'"
171
+ file.flock(File::LOCK_UN)
172
+ rescue Exception => e
173
+ print_debug "#{e}"
174
+ end
175
+ end
172
176
 
173
177
  def ClipArray.create(file_and_path)
174
178
  print_verbose "creating file '#{file_and_path}'"
@@ -181,7 +185,7 @@ def ClipArray.create(file_and_path)
181
185
  file = File.open(file_and_path,"w+")
182
186
  ca = ClipArray.new.clear1
183
187
  ca.set_file(file,file_and_path)
184
-
188
+
185
189
  # test if writable
186
190
  ClipArray.obtain_exclusive_lock(file)
187
191
 
@@ -192,7 +196,7 @@ def ClipArray.create(file_and_path)
192
196
  end
193
197
 
194
198
  return ca
195
- end
199
+ end
196
200
 
197
201
  def ClipArray.open(file_and_path)
198
202
  print_verbose "opening file '#{file_and_path}'"
@@ -200,6 +204,7 @@ def ClipArray.open(file_and_path)
200
204
  begin
201
205
  file = File.open(file_and_path,"r+")
202
206
  ca = ClipArray.read_mbox(file)
207
+ ca.clear1 if ca == []
203
208
  ca.set_file(file,file_and_path)
204
209
 
205
210
  # test if writable
@@ -212,7 +217,7 @@ def ClipArray.open(file_and_path)
212
217
  end
213
218
 
214
219
  return ca
215
- end
220
+ end
216
221
 
217
222
  def save
218
223
  if @file.nil? then
@@ -227,17 +232,17 @@ def save
227
232
  write_mbox(@file)
228
233
  @file.flush
229
234
  ClipArray.obtain_shared_lock(@file)
230
- end
235
+ end
231
236
 
232
237
  def append(file)
233
238
  print_verbose "append to mbox '#{file}'"
234
239
  File.open(file,"a") do | f |
235
- f.print "From %s@localhost %s\n" %
240
+ f.print "From %s@localhost %s\n" %
236
241
  [Version::PROGRAM_NAMELC, Time.now.ctime]
237
242
  f.print(escape_from(self[@current_index].to_mbox.chomp))
238
243
  f.print("\n")
239
244
  end
240
- end
245
+ end
241
246
 
242
247
  def close
243
248
  save
@@ -249,9 +254,9 @@ def close
249
254
  @file = nil
250
255
  @filename = nil
251
256
  clear
252
- end
257
+ end
253
258
 
254
- private
259
+ private
255
260
 
256
261
 
257
262
  def ClipArray.read_mbox(file)
@@ -302,7 +307,7 @@ def ClipArray.read_mbox(file)
302
307
 
303
308
  ca.current_index = ca.length - 1
304
309
  return ca
305
- end
310
+ end
306
311
 
307
312
  def write_mbox(file)
308
313
  print_debug "writing clips, mbox format"
@@ -315,13 +320,13 @@ def write_mbox(file)
315
320
  pc.data = @pref.write
316
321
 
317
322
  ([pc]+self).each do | clip |
318
- file.print "From %s@localhost %s\n" %
323
+ file.print "From %s@localhost %s\n" %
319
324
  [Version::PROGRAM_NAMELC, Time.now.ctime]
320
325
  file.print(escape_from(clip.to_mbox.chomp))
321
326
  file.print("\n")
322
327
  print_debug " #{i}: '#{clip.title}'"
323
328
  i += 1
324
329
  end
325
- end
330
+ end
326
331
 
327
332
  end # class