listlace 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b99b9e103972f209f74a53b2328cc01aef9ee89f
4
+ data.tar.gz: 335147f7cbda256c7ed70273b14736edf46d697e
5
+ SHA512:
6
+ metadata.gz: 1e7de49eb1117788b45e41fccee8bbbb987f3b1ee6d1bff7415096a510b4853bf8f2cd7c383d542f2b88cfb7ed5db8f33d92a116cb2203589a3a58a6b2395231
7
+ data.tar.gz: bd62fdc1d420b838d3699ea10f773e9cd98ceece1ef443a4f4bba7f44cace6d18e35ab91ef442049d15251e713d43edd23922c0098305c0829b28fe3447bdd91
data/Gemfile CHANGED
File without changes
data/Gemfile.lock CHANGED
@@ -1,47 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- listlace (0.0.9)
5
- activerecord
6
- activesupport
4
+ listlace (0.0.1)
7
5
  bundler
8
- open4
9
- plist
6
+ mpd_client
10
7
  pry
11
- sqlite3
12
- taglib-ruby
13
8
 
14
9
  GEM
15
10
  remote: http://rubygems.org/
16
11
  specs:
17
- activemodel (3.2.8)
18
- activesupport (= 3.2.8)
19
- builder (~> 3.0.0)
20
- activerecord (3.2.8)
21
- activemodel (= 3.2.8)
22
- activesupport (= 3.2.8)
23
- arel (~> 3.0.2)
24
- tzinfo (~> 0.3.29)
25
- activesupport (3.2.8)
26
- i18n (~> 0.6)
27
- multi_json (~> 1.0)
28
- arel (3.0.2)
29
- builder (3.0.3)
30
- coderay (1.0.7)
31
- i18n (0.6.1)
32
- method_source (0.8)
33
- multi_json (1.3.6)
34
- open4 (1.3.0)
35
- plist (3.1.0)
36
- pry (0.9.10)
37
- coderay (~> 1.0.5)
12
+ coderay (1.1.0)
13
+ method_source (0.8.2)
14
+ mpd_client (0.0.3)
15
+ pry (0.9.12.6)
16
+ coderay (~> 1.0)
38
17
  method_source (~> 0.8)
39
- slop (~> 3.3.1)
18
+ slop (~> 3.4)
40
19
  rake (0.9.2.2)
41
- slop (3.3.3)
42
- sqlite3 (1.3.6)
43
- taglib-ruby (0.5.1)
44
- tzinfo (0.3.33)
20
+ slop (3.5.0)
45
21
 
46
22
  PLATFORMS
47
23
  ruby
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Jeremy Ruten
1
+ Copyright (c) 2014 Jeremy Ruten
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
data/README.md CHANGED
@@ -1,26 +1,6 @@
1
- # Listlace
1
+ # ♫> Listlace
2
2
 
3
- Listlace is a music player that does Ruby. Here's how it works:
4
-
5
- First add your music library.
6
-
7
- >> add "/path/to/Music"
8
- 1067 songs added.
9
-
10
- ...Or import your iTunes library.
11
-
12
- >> import :itunes, "/path/to/iTunes/iTunes Music Library.xml"
13
-
14
- Once your library is in place, start grouping your songs into playlists.
15
-
16
- >> save artist("muse"), :muse
17
- => muse (108 tracks)
18
-
19
- Finally, go ahead and play your playlists.
20
-
21
- >> p :muse
22
- Playlist: muse (108 tracks)
23
- Blackout - Muse (0:00 / 4:22)
3
+ Listlace is an mpd (music player daemon) client that uses a Ruby prompt as the interface, allowing you to use the power of Ruby to query your music library and build playlists.
24
4
 
25
5
  ## Install
26
6
 
@@ -28,26 +8,24 @@ It's a gem, so do this:
28
8
 
29
9
  $ gem install listlace
30
10
 
31
- You also need mplayer in your $PATH, if you want to atually play your music.
11
+ Listlace is an mpd client, so make sure mpd is installed and running in the background.
32
12
 
33
13
  ## Usage
34
14
 
35
15
  The gem gives you an executable, so do this:
36
16
 
37
17
  $ listlace
38
- Hello, you have 0 songs.
39
- >>
18
+ ♫>
40
19
 
41
- Now you're ready to play.
20
+ It gives you a prompt, which is just a Ruby prompt, with the commands below implemented as methods.
42
21
 
43
- ## Library
22
+ ## Commands
44
23
 
45
- ...
24
+ ### p
46
25
 
47
- ## Playlists
26
+ `p` is like a play/pause button. If the player is paused, it unpauses. If the player is playing, then it pauses. If the player is stopped, then it starts playing.
48
27
 
49
- ...
28
+ ### mpd
50
29
 
51
- ## The Player
30
+ `mpd` gives you an instance of the `MPDClient` object, which you can use to send any `mpd` command that isn't available in Listlace yet. This'll probably be removed once I actually implement all the commands.
52
31
 
53
- ...
data/bin/listlace CHANGED
@@ -4,22 +4,21 @@ require "bundler/setup"
4
4
  require "pry"
5
5
  require "listlace"
6
6
 
7
- ActiveRecord::Migration.verbose = false
7
+ host, port = *ARGV
8
+ host ||= "localhost"
9
+ port ||= 6600
8
10
 
9
- Listlace.extend Listlace::Commands::LibraryCommands
10
- Listlace.extend Listlace::Commands::PlayerCommands
11
-
12
- Listlace.library = Listlace::Library.new
13
- Listlace.player = Listlace::Player.new
14
-
15
- puts "Hello, you have #{Listlace.library.size} songs."
16
-
17
- at_exit do
18
- Listlace.player.stop
11
+ begin
12
+ listlace = Listlace.new(host, port)
13
+ rescue Exception => e
14
+ puts "Couldn't connect to MPD server."
15
+ puts "Reason: #{e.message}"
16
+ exit
19
17
  end
20
18
 
21
- Listlace.pry(
19
+ listlace.pry(
22
20
  quiet: true,
23
- prompt: [proc { ">> " }, proc { " | " }],
21
+ prompt: [proc { "\u266B> " }, proc { " | " }],
24
22
  print: proc { |output, value| Pry::DEFAULT_PRINT.call(output, value) unless value.nil? }
25
23
  )
24
+
@@ -0,0 +1,18 @@
1
+ class Listlace
2
+ module Commands
3
+ REPEAT_SYMBOL = "\u221E"
4
+ TIMES_SYMBOL = "\u00D7"
5
+
6
+ def p
7
+ case mpd.status["state"]
8
+ when "play"
9
+ mpd.pause(1)
10
+ when "pause"
11
+ mpd.pause(0)
12
+ when "stop"
13
+ mpd.play
14
+ end
15
+ end
16
+ end
17
+ end
18
+
data/lib/listlace.rb CHANGED
@@ -1,35 +1,19 @@
1
- require "open4"
2
- require "active_record"
3
- require "fileutils"
4
- require "plist"
5
- require "active_support/core_ext/string"
6
- require "taglib"
1
+ require "mpd_client"
7
2
 
8
- require "listlace/core_ext/array"
9
- require "listlace/time_helper"
3
+ require "listlace/commands"
10
4
 
11
- require "listlace/models/track"
12
- require "listlace/models/playlist"
13
- require "listlace/models/playlist_item"
5
+ class Listlace
6
+ attr_reader :mpd
14
7
 
15
- require "listlace/library"
16
- require "listlace/library/database"
17
- require "listlace/library/selectors"
8
+ include Commands
18
9
 
19
- require "listlace/simple_track"
20
- require "listlace/single_player"
21
- require "listlace/single_players/mplayer"
22
- require "listlace/player"
23
-
24
- require "listlace/commands/library_commands"
25
- require "listlace/commands/player_commands"
26
-
27
- module Listlace
28
- extend Listlace::Library::Selectors
29
-
30
- class << self
31
- attr_accessor :library, :player
10
+ def initialize(host, port)
11
+ @mpd = MPDClient.new
12
+ @mpd.connect(host, port)
32
13
  end
33
14
 
34
- DIR = ENV["LISTLACE_DIR"] || (ENV["HOME"] + "/.listlace")
15
+ def disconnect
16
+ @mpd.disconnect
17
+ end
35
18
  end
19
+
data/listlace.gemspec CHANGED
@@ -1,23 +1,21 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "listlace"
3
- s.version = "0.0.9"
4
- s.date = "2012-09-17"
5
- s.summary = "A music player in a REPL."
6
- s.description = "Listlace is a music player which is interacted with through a Ruby REPL."
3
+ s.version = "0.1.0"
4
+ s.date = "2014-03-15"
5
+ s.summary = "An mpd (music player daemon) client with a Ruby shell as the interface."
6
+ s.description = "Listlace is an mpd (music player daemon) client with a Ruby shell as the interface."
7
7
  s.author = "Jeremy Ruten"
8
8
  s.email = "jeremy.ruten@gmail.com"
9
9
  s.homepage = "http://github.com/yjerem/listlace"
10
10
  s.license = "MIT"
11
11
  s.required_ruby_version = ">= 1.9.2"
12
- s.requirements << "mplayer"
13
- s.requirements << "taglib"
14
12
  s.executables << "listlace"
15
13
 
16
- s.files = ["Gemfile", "Gemfile.lock", "LICENSE", "listlace.gemspec", "README.md", "README.old"]
14
+ s.files = ["Gemfile", "Gemfile.lock", "LICENSE", "listlace.gemspec", "README.md"]
17
15
  s.files += ["bin/listlace"]
18
16
  s.files += Dir["lib/**/*.rb"]
19
17
 
20
- %w(bundler pry plist sqlite3 activerecord activesupport open4 taglib-ruby).each do |gem_name|
18
+ %w(bundler pry mpd_client).each do |gem_name|
21
19
  s.add_runtime_dependency gem_name
22
20
  end
23
21
 
@@ -25,3 +23,4 @@ Gem::Specification.new do |s|
25
23
  s.add_development_dependency gem_name
26
24
  end
27
25
  end
26
+
metadata CHANGED
@@ -1,161 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listlace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jeremy Ruten
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-09-17 00:00:00.000000000 Z
11
+ date: 2014-03-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: pry
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
- name: plist
42
+ name: mpd_client
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: sqlite3
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: activerecord
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :runtime
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
- - !ruby/object:Gem::Dependency
95
- name: activesupport
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :runtime
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- - !ruby/object:Gem::Dependency
111
- name: open4
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: taglib-ruby
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ! '>='
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :runtime
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ! '>='
52
+ - - ">="
140
53
  - !ruby/object:Gem::Version
141
54
  version: '0'
142
55
  - !ruby/object:Gem::Dependency
143
56
  name: rake
144
57
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
58
  requirements:
147
- - - ! '>='
59
+ - - ">="
148
60
  - !ruby/object:Gem::Version
149
61
  version: '0'
150
62
  type: :development
151
63
  prerelease: false
152
64
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
65
  requirements:
155
- - - ! '>='
66
+ - - ">="
156
67
  - !ruby/object:Gem::Version
157
68
  version: '0'
158
- description: Listlace is a music player which is interacted with through a Ruby REPL.
69
+ description: Listlace is an mpd (music player daemon) client with a Ruby shell as
70
+ the interface.
159
71
  email: jeremy.ruten@gmail.com
160
72
  executables:
161
73
  - listlace
@@ -165,50 +77,33 @@ files:
165
77
  - Gemfile
166
78
  - Gemfile.lock
167
79
  - LICENSE
168
- - listlace.gemspec
169
80
  - README.md
170
- - README.old
171
81
  - bin/listlace
172
- - lib/listlace/commands/library_commands.rb
173
- - lib/listlace/commands/player_commands.rb
174
- - lib/listlace/core_ext/array.rb
175
- - lib/listlace/library/database.rb
176
- - lib/listlace/library/selectors.rb
177
- - lib/listlace/library.rb
178
- - lib/listlace/models/playlist.rb
179
- - lib/listlace/models/playlist_item.rb
180
- - lib/listlace/models/track.rb
181
- - lib/listlace/player.rb
182
- - lib/listlace/simple_track.rb
183
- - lib/listlace/single_player.rb
184
- - lib/listlace/single_players/mplayer.rb
185
- - lib/listlace/time_helper.rb
186
82
  - lib/listlace.rb
83
+ - lib/listlace/commands.rb
84
+ - listlace.gemspec
187
85
  homepage: http://github.com/yjerem/listlace
188
86
  licenses:
189
87
  - MIT
88
+ metadata: {}
190
89
  post_install_message:
191
90
  rdoc_options: []
192
91
  require_paths:
193
92
  - lib
194
93
  required_ruby_version: !ruby/object:Gem::Requirement
195
- none: false
196
94
  requirements:
197
- - - ! '>='
95
+ - - ">="
198
96
  - !ruby/object:Gem::Version
199
97
  version: 1.9.2
200
98
  required_rubygems_version: !ruby/object:Gem::Requirement
201
- none: false
202
99
  requirements:
203
- - - ! '>='
100
+ - - ">="
204
101
  - !ruby/object:Gem::Version
205
102
  version: '0'
206
- requirements:
207
- - mplayer
208
- - taglib
103
+ requirements: []
209
104
  rubyforge_project:
210
- rubygems_version: 1.8.23
105
+ rubygems_version: 2.2.2
211
106
  signing_key:
212
- specification_version: 3
213
- summary: A music player in a REPL.
107
+ specification_version: 4
108
+ summary: An mpd (music player daemon) client with a Ruby shell as the interface.
214
109
  test_files: []
data/README.old DELETED
@@ -1,86 +0,0 @@
1
- < listlace >
2
-
3
- listlace is a music player with a REPL.
4
- It allows you to forge complex playlists
5
- with ease... as long as you know your
6
- way around Ruby.
7
-
8
- No more staring a database in the face.
9
- No more click, shift-click, ctrl-click,
10
- ctrl-click, drag-and-drop, click,
11
- double-click.
12
-
13
- Conjuring audio with spells is much more
14
- appropriate, don't you think?
15
-
16
- -- install
17
-
18
- It's a gem. So do this:
19
-
20
- $ gem install listlace
21
-
22
- But you also need mplayer. It has to be
23
- at /usr/bin/mplayer, for now.
24
-
25
- -- usage
26
-
27
- The gem gives you an executable called
28
- 'listlace'. So do this:
29
-
30
- $ listlace
31
-
32
- It will make a '.listlace' directory in
33
- $HOME, where the database of tracks and
34
- playlists is stored. Then it will give you
35
- a prompt. Don't be alarmed, it speaks
36
- Ruby.
37
-
38
- The only way to populate the database right
39
- now is to import your iTunes library.
40
- That goes a little something like this:
41
-
42
- >> import :itunes, "/Users/jeremy/Music/iTunes/iTunes Music Library.xml"
43
-
44
- Now you can play your music.
45
-
46
- -- p's and q's
47
-
48
- p is the most important command. It's the
49
- play command. It's also the pause/resume
50
- command. You can pass it some tracks or a
51
- playlist, and it will queue up the music
52
- and start playing it, sequentially. If you
53
- don't pass it anything, that's when it acts
54
- as a pause/resume button.
55
-
56
- q is the queue command. You can pass it some
57
- tracks or a playlist and it'll add them to the
58
- queue. The queue is just an array of tracks
59
- to be played in order. The p command by
60
- itself will start playing the queue.
61
-
62
- -- commands
63
-
64
- * playback
65
- - p: play/pause/resume
66
- - stop: stop playback
67
- - restart: seek back to the beginning of the current track
68
- - back: go back a song
69
- - skip: go to the next song
70
- - seek: move to a different part of the track
71
- - ff: fast-forward, or slow down
72
- - repeat: choose the repeat mode, either :one or :all
73
- - norepeat: turn off the repeat mode
74
- - status: show what's currently playing, as well as other information
75
- * queue
76
- - q: append some tracks to the queue, or get the queue
77
- - clear: clear the queue
78
- - shuffle: shuffle the songs in the queue
79
- - sort: sort the songs in the queue however you want
80
- * library
81
- - import: import another program's music library
82
- - wipe_library: remove all tracks and playlists from the library
83
-
84
- -- selectors
85
-
86
- ...
@@ -1,90 +0,0 @@
1
- module Listlace
2
- module Commands
3
- module LibraryCommands
4
- # Save a playlist to the database. As a shortcut, you can pass the name
5
- # to save it as, instead of setting the name on the playlist and then
6
- # saving it.
7
- def save(playlist, name = nil)
8
- playlist.name = name if name
9
- library.save_playlist(playlist)
10
- end
11
-
12
- def like
13
- if player.current_track.respond_to?(:rating)
14
- player.current_track.increment! :rating
15
- end
16
- end
17
-
18
- def dislike
19
- if player.current_track.respond_to?(:rating)
20
- player.current_track.decrement! :rating
21
- end
22
- end
23
-
24
- def add(path, options = {})
25
- if File.directory?(path)
26
- extensions = {}
27
- Array(options.delete(:extensions)).each do |ext|
28
- extensions[ext.to_s] = true
29
- end
30
-
31
- num_tracks = 0
32
- Dir[File.join(path, "**", "*")].each do |file|
33
- unless File.directory?(file)
34
- ext = File.extname(file).sub(/^\./, "")
35
- if extensions[ext].nil?
36
- print "Do you want to add files with the '.#{ext}' extension [y/N]? "
37
- if gets[0].downcase == "y"
38
- extensions[ext] = true
39
- else
40
- extensions[ext] = false
41
- end
42
- end
43
-
44
- if extensions[ext]
45
- if library.add_track(file, options)
46
- num_tracks += 1
47
- end
48
- end
49
- end
50
- end
51
-
52
- if num_tracks == 0
53
- puts "Can't find any audio files there. Perhaps they are already added?"
54
- elsif num_tracks == 1
55
- puts "1 track added."
56
- else
57
- puts "#{num_tracks} tracks added."
58
- end
59
- else
60
- if library.add_track(path, options)
61
- puts "1 track added."
62
- else
63
- puts "Track couldn't be added. Perhaps it's not an audio file?"
64
- end
65
- end
66
- rescue Library::FileNotFoundError => e
67
- puts e.message
68
- end
69
-
70
- # Imports the music library from another program. Currently only iTunes is
71
- # supported.
72
- def import(from, path)
73
- library.import(from, path, logger: method(:puts))
74
- rescue Library::FileNotFoundError => e
75
- puts e.message
76
- end
77
-
78
- # Wipes the database. With no arguments, it just asks "Are you sure?" without
79
- # doing anything. To actually wipe the database, pass :yes_im_sure.
80
- def wipe_library(are_you_sure = :nope)
81
- if are_you_sure == :yes_im_sure
82
- library.wipe
83
- puts "Library wiped."
84
- else
85
- puts "Are you sure? If you are, then type: wipe_library :yes_im_sure"
86
- end
87
- end
88
- end
89
- end
90
- end