ipod_db 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/TODO +0 -1
  2. data/bin/ipod +34 -15
  3. data/lib/ipod_db/version.rb +1 -1
  4. metadata +1 -1
data/TODO CHANGED
@@ -1,3 +1,2 @@
1
- - allow grouping some podcasts so their episodes are spread out (via config field)
2
1
  - display totals in ls output: total time and bytes; bytes left on device etc
3
2
 
data/bin/ipod CHANGED
@@ -11,7 +11,23 @@ Main {
11
11
  author 'artm <femistofel@gmail.com>'
12
12
 
13
13
  name 'ipod_db'
14
- config ipod_root: "/media/#{ENV['USER']}/IPOD"
14
+ config(
15
+ ipod_root: "/media/#{ENV['USER']}/IPOD",
16
+ group_together: [
17
+ # Just an example
18
+ [ "60-Second", "Science Talk", "This Week in Science" ],
19
+ [ "StarShipSofa", "Tales To Terrify" ],
20
+ ])
21
+ option('books','b') {
22
+ argument_required
23
+ default 'books'
24
+ description 'subdirectory of ipod with bookmarkable media'
25
+ }
26
+ option('songs','s') {
27
+ argument_required
28
+ default 'songs'
29
+ description 'subdirectory of ipod with non-bookmarkable media'
30
+ }
15
31
  option('version','v') {
16
32
  description 'show package version and exit'
17
33
  }
@@ -52,16 +68,6 @@ Main {
52
68
  database on the device and it's ready for consumption.
53
69
  __
54
70
 
55
- option('books','b') {
56
- argument_required
57
- default 'books'
58
- description 'subdirectory of ipod with bookmarkable media'
59
- }
60
- option('songs','s') {
61
- argument_required
62
- default 'songs'
63
- description 'subdirectory of ipod with non-bookmarkable media'
64
- }
65
71
  def run
66
72
  load_ipod_db
67
73
  sync
@@ -100,7 +106,7 @@ Main {
100
106
  books_path = params['books'].value
101
107
  songs_path = params['songs'].value
102
108
  books = collect_tracks books_path
103
- books = riffle(books)
109
+ books = spread(books)
104
110
  songs = collect_tracks songs_path
105
111
  @ipod_db.update books: books, songs: songs
106
112
  @ipod_db.save
@@ -221,11 +227,22 @@ Main {
221
227
  tracks
222
228
  end
223
229
 
224
- def riffle paths
225
- bins = paths.group_by{|path| File.dirname(path)}.values
226
- Spread.spread *bins
230
+ def spread paths, group_lambda = lambda {|path| track_group(path)}
231
+ bins = paths.group_by &group_lambda
232
+ bins.each do |key, bin|
233
+ bins[key] = spread(bins[key], lambda{|path| File.dirname(path)}) if key.is_a? Integer
234
+ end
235
+ Spread.spread *bins.values
227
236
  end
228
237
 
238
+ def track_group track
239
+ config['group_together'].each_with_index do |patterns,group|
240
+ patterns.each do |pattern|
241
+ return group if track.downcase.index pattern.downcase
242
+ end
243
+ end
244
+ File.dirname(track)
245
+ end
229
246
  }
230
247
 
231
248
  BEGIN {
@@ -237,6 +254,8 @@ BEGIN {
237
254
  require 'taglib'
238
255
  require 'ruby-progressbar'
239
256
  require 'highline/import'
257
+ require 'fileutils'
258
+ require 'pp'
240
259
 
241
260
  # our own
242
261
  require 'ipod_db'
@@ -1,3 +1,3 @@
1
1
  class IpodDB
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ipod_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: