rubyshelltools 0.0.7 → 0.0.8

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.
@@ -115,6 +115,29 @@ List entries with IDs and delete by ID
115
115
 
116
116
  $ rst cal --delete-event e5e14e59
117
117
 
118
+ Print a pretty calendar
119
+ -----------------------
120
+
121
+ $ rst cal -n work --print-calendar
122
+
123
+ April 2013 EVENTS:
124
+ Su Mo Tu We Th Fr Sa Wed, Apr 24 2013: RailsConf2013 7h Abflug München + TÜV-Audit
125
+ 1 2 3 4 5 6 Mon, Apr 29 2013: RailsConf2013
126
+ 7 8 9 10 11 12 13 Tue, Apr 30 2013: RailsConf2013
127
+ 14 15 16 17 18 19 20 Wed, May 01 2013: RailsConf2013
128
+ 21 22 23 24 25 26 27 Thu, May 02 2013: RailsConf2013
129
+ 28 29 30 Fri, May 03 2013: RailsConf2013
130
+ Sat, May 04 2013: RailsConf2013 Ankunft München
131
+ Mon, May 06 2013: Prüfung Romy
132
+ May 2013
133
+ Su Mo Tu We Th Fr Sa
134
+ 1 2 3 4
135
+ 5 6 7 8 9 10 11
136
+ 12 13 14 15 16 17 18
137
+ 19 20 21 22 23 24 25
138
+ 26 27 28 29 30 31
139
+
140
+
118
141
 
119
142
  Save defaults
120
143
  =============
@@ -175,11 +175,13 @@ module RST
175
175
  # Output a calendar for the given range.Including a small
176
176
  # monthly calendar on the upper, left and a list of all
177
177
  # events within given date-range
178
- def to_text(from,to)
178
+ # @param [String|Date] from - Start on date
179
+ # @param [String|Date] to - End on date
180
+ # @return [String]
181
+ def to_text(from,to,empty=false,ids=false)
179
182
  unless (_content=list_days(from,to)).empty?
180
- _date = ensure_date(from)
181
- left_column=build_cal(_date,ensure_date(to))
182
- right_column=["EVENTS:"] + list_days(from,to)
183
+ left_column=build_cal(ensure_date(from),ensure_date(to))
184
+ right_column=("EVENTS:\n"+list_days(from,to,empty,ids).join("\n")).split(/\n/)
183
185
  rows = []
184
186
  source = left_column.count > right_column.count ? left_column : right_column
185
187
  source.each_with_index do |_r,idx|
@@ -201,7 +203,7 @@ module RST
201
203
  def build_cal from, to
202
204
  (from..to).map{ |d| [d.month, d.year ] }.uniq.map { |m,y|
203
205
  `cal #{m} #{y}`
204
- }.join("\n\n").split(/\n/)
206
+ }.join("\n").split(/\n/)
205
207
  end
206
208
  # Output date and Events on this date in one line
207
209
  # @param [Date] _date
@@ -210,7 +212,7 @@ module RST
210
212
  # @param [Boolean] show_ids - output ids for events
211
213
  def format_events_for(_date,show_empty=false,show_ids=false)
212
214
  if (_line=event_headlines_for(_date,show_ids)) != '' || show_empty
213
- (show_ids ? "%s:\n %s" : "%s: %s") % [_date.strftime(DEFAULT_DATE_FORMAT), _line]
215
+ (show_ids ? "%s:\n%s" : "%s: %s") % [_date.strftime(DEFAULT_DATE_FORMAT), _line]
214
216
  end
215
217
  end
216
218
 
@@ -223,8 +225,8 @@ module RST
223
225
  events_on(_date).map(&:event_headline).join(' + ').strip
224
226
  else
225
227
  events_on(_date).map{|e|
226
- "%s > %s" % [e.respond_to?(:id) ? e.id : 'n/a' ,e.event_headline]
227
- }.join("\n ").strip
228
+ "%16.16s: %s" % [e.respond_to?(:id) ? e.id : 'n/a' ,e.event_headline]
229
+ }.join("\n").gsub(/\s*$/,'')
228
230
  end
229
231
  end
230
232
 
data/lib/rst.rb CHANGED
@@ -301,8 +301,11 @@ module RST
301
301
  def print_long_calendar
302
302
  store = Persistent::DiskStore.new(CALENDAR_FILE)
303
303
  store.all.map { |calendar|
304
- calendar.to_text(@options[:from], @options[:to])
305
- }.join("\n\n")
304
+ if @options[:name].blank? || @options[:name] == calendar.name
305
+ calendar.name + "\n" +
306
+ calendar.to_text(@options[:from], @options[:to], @options[:show_empty], @options[:with_ids]).to_s
307
+ end
308
+ }.compact.join("\n\n")
306
309
  end
307
310
 
308
311
  # Dump the calendar(s), thus the output can be used as input for -e again
data/rst.rb CHANGED
@@ -3,7 +3,7 @@ require 'logger'
3
3
  # # Ruby Shell Tools Top-level file
4
4
  module RST
5
5
  # Gem-version
6
- VERSION = '0.0.7'
6
+ VERSION = '0.0.8'
7
7
 
8
8
  # Path to the docs used by the software
9
9
  DOCS = File.expand_path('../assets/docs', __FILE__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyshelltools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: