hearken 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15943a5107f579fc0766e685b8d792414e7a9c0e
4
+ data.tar.gz: 434056523b9daed4ff637fba7c47dc111eb88761
5
+ SHA512:
6
+ metadata.gz: 7bd1fe7362205feee7edec57999a948cd9b1cff4c43a38f1a75fbf76e9cff33fb413a80cce4b3f5bc56db117d9ba90ff60c7f00b59353a65e61f29d3db6bb9d6
7
+ data.tar.gz: bc4a16fe354735aff6645b75a07a9c9d33a2c286c62a6ddb7e21d14c1aa773116ee6edd0d67b3b89076d6f5ac0f42deb7060ab8384ad6241fbe0a4a773ac412b
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.dirname(__FILE__)+'/../lib'
4
+
5
+ command = ARGV.shift
6
+
7
+ unless %w{setup start finish}.include? command
8
+ puts 'usage:'
9
+ puts ' hearken_scrobble setup'
10
+ puts ' hearken_scrobble start PATH_TO_AUDIO_FILE'
11
+ puts ' hearken_scrobble finish PATH_TO_AUDIO_FILE'
12
+ exit 0
13
+ end
14
+
15
+ require 'hearken/indexing/ffmpeg_file'
16
+ require 'hearken/scrobbler'
17
+
18
+ scrobbler = Hearken::Scrobbler.new
19
+ scrobbler.enabled = true
20
+
21
+ if command == 'setup'
22
+ scrobbler.setup
23
+ exit 0
24
+ end
25
+
26
+ file = ARGV.shift
27
+ track = Hearken::Indexing::FfmpegFile.from_file file
28
+
29
+ if command == 'start'
30
+ scrobbler.started track
31
+ elsif command == 'finish'
32
+ scrobbler.finished track
33
+ else
34
+ puts 'unknown command'
35
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $: << File.dirname(__FILE__)+'/../lib'
4
+
5
+
6
+ require 'pp'
7
+ require 'hearken/indexing/ffmpeg_file'
8
+
9
+ ARGV.each do |path|
10
+ pp Hearken::Indexing::FfmpegFile.from_file path
11
+ end
@@ -40,9 +40,9 @@ EOF
40
40
  s.required_ruby_version = '>= 1.9.2'
41
41
 
42
42
  s.add_dependency 'shell_shock', '~>0'
43
- s.add_dependency 'rainbow', '~> 1'
43
+ s.add_dependency 'rainbow', '~> 2'
44
44
  s.add_dependency 'nokogiri', '~> 1'
45
45
 
46
46
  s.add_development_dependency 'rake', '~>0'
47
- s.add_development_dependency 'rspec', '~>2'
47
+ s.add_development_dependency 'rspec', '~>3'
48
48
  end
@@ -1,3 +1,3 @@
1
1
  module Hearken
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -1,5 +1,7 @@
1
+ require 'rainbow'
2
+
1
3
  module Hearken::Colour
2
4
  def c text,colour
3
- text.to_s.foreground colour
5
+ Rainbow(text.to_s).color colour
4
6
  end
5
7
  end
@@ -26,12 +26,13 @@ module Hearken
26
26
  at_exit { @player.stop }
27
27
  @prompt = "hearken > "
28
28
  with :status, "'"
29
- with :restart, 'next'
29
+ with :restart, 'next', 'k'
30
30
  with :list, 'ls'
31
- with :enqueue, 'add'
32
- with :remove, 'rm'
33
- with :start, 'play'
34
- with_all *%w{reload search stop scrobbling shuffle setup_scrobbling recent love profile}
31
+ with :enqueue, 'add', '+'
32
+ with :remove, 'rm', '-'
33
+ with :start, 'play', 'go'
34
+ with :search, 'find'
35
+ with_all *%w{reload stop scrobbling shuffle setup_scrobbling recent love profile}
35
36
  end
36
37
  end
37
38
  end
@@ -1,9 +1,16 @@
1
+ require 'hearken/indexing/file'
1
2
  require 'hearken/indexing/executor'
2
3
  require 'hearken/monkey_violence'
4
+ require 'pathname'
3
5
 
4
6
  class Hearken::Indexing::FfmpegFile
5
7
  include Hearken::Indexing::Executor
6
8
 
9
+ def self.from_file path
10
+ file = Hearken::Indexing::File.new Pathname.new path
11
+ Hearken::Indexing::FfmpegFile.new file
12
+ end
13
+
7
14
  def initialize path
8
15
  extract_file_attributes path
9
16
  content = execute "ffmpeg -i #{@path.escape_for_sh}"
@@ -1,5 +1,7 @@
1
+ module Hearken; module Indexing; end; end
2
+
1
3
  class Hearken::Indexing::File
2
- def initialize path, root
4
+ def initialize path, root=nil
3
5
  @path, @root = path, root
4
6
  end
5
7
 
@@ -29,7 +29,7 @@ module Hearken
29
29
  timing = "(#{c track.time.to_i-played, :yellow} remaining)" if track.time
30
30
  puts "#{c Time.at(track.started).strftime("%H:%M:%S %d/%m/%Y"), :blue}: #{track} #{timing}"
31
31
  else
32
- puts 'not playing'.foreground(:yellow)
32
+ puts c 'not playing', :yellow
33
33
  end
34
34
  end
35
35
 
@@ -63,7 +63,11 @@ module Hearken
63
63
  @notifiers.each {|notifier| notifier.finished track if notifier.respond_to? :finished}
64
64
  end
65
65
 
66
- def scrobbling tf
66
+ def scrobbling
67
+ @scrobbler.enabled
68
+ end
69
+
70
+ def scrobbling= tf
67
71
  @scrobbler.enabled = tf
68
72
  end
69
73
 
@@ -1,6 +1,9 @@
1
+ require 'yaml'
1
2
  require 'hearken/paths'
2
3
  require 'hearken/monkey_violence'
3
4
 
5
+ module Hearken; end
6
+
4
7
  module Hearken
5
8
  class Preferences
6
9
  include Hearken::Paths
@@ -1,3 +1,4 @@
1
+ require 'hearken/preferences'
1
2
  require 'hearken/simple_scrobbler'
2
3
  require 'hearken/debug'
3
4
 
@@ -8,10 +9,14 @@ module Hearken
8
9
  SECRET = 'ab77019c84eef8bc16bcfd5ba8db0c5d'
9
10
  include Debug
10
11
 
11
- def initialize preferences
12
+ def initialize preferences=Hearken::Preferences.new
12
13
  @preferences = preferences
13
14
  end
14
15
 
16
+ def enabled
17
+ !!@scrobbler
18
+ end
19
+
15
20
  def enabled= tf
16
21
  @scrobbler = nil
17
22
  if @preferences['lastfm'] and tf
@@ -1,8 +1,10 @@
1
1
  require 'hearken/tagged'
2
- require 'rainbow'
2
+ require 'hearken/colour'
3
3
 
4
4
  class Hearken::Track
5
5
  include Hearken::Tagged
6
+ include Hearken::Colour
7
+
6
8
  attr_accessor :id, :started
7
9
 
8
10
  def initialize id=nil
@@ -34,6 +36,6 @@ class Hearken::Track
34
36
  end
35
37
 
36
38
  def my field, colour
37
- self.send(field).to_s.foreground(colour)
39
+ c self.send(field).to_s, colour
38
40
  end
39
41
  end
@@ -8,16 +8,16 @@ describe Hearken::Command::Enqueue do
8
8
  with_help 'enqueues the list of songs with the specified ids'
9
9
 
10
10
  before do
11
- @player = stub('player')
11
+ @player = double 'player'
12
12
  @command = Hearken::Command::Enqueue.new @player
13
13
  end
14
14
 
15
15
  it 'should enqueue whatever is returned from the expander' do
16
- expander = stub('expander')
17
- Hearken::RangeExpander.should_receive(:new).and_return(expander)
18
- expander.should_receive(:expand).with('some text').and_return([1,2,3])
16
+ expander = double 'expander'
17
+ allow(Hearken::RangeExpander).to receive(:new) { expander }
18
+ allow(expander).to receive(:expand).with('some text') { [1,2,3] }
19
19
 
20
- [1,2,3].each {|id| @player.should_receive(:enqueue).with id}
20
+ [1,2,3].each {|id| expect(@player).to receive(:enqueue).with(id) }
21
21
 
22
22
  @command.execute "some text"
23
23
  end
@@ -11,21 +11,21 @@ when playing, approximate times for each track will be displayed
11
11
  EOF
12
12
 
13
13
  before do
14
- @player = stub('player')
14
+ @player = double 'player'
15
15
  @command = Hearken::Command::List.new @player
16
16
  end
17
17
 
18
18
  it 'should display nothing when there is no current track and nothing enqueued' do
19
- @player.stub!(:current).and_return nil
20
- @player.stub! :each
19
+ allow(@player).to receive(:current) { nil }
20
+ allow(@player).to receive(:each)
21
21
  @command.execute ''
22
22
  end
23
23
 
24
24
  it 'should display queue contents with no times when there is no current track' do
25
- track = stub 'track'
26
- @player.stub!(:current).and_return nil
27
- @player.stub!(:each).and_yield track
28
- @command.should_receive(:puts).with track
25
+ track = double 'track'
26
+ allow(@player).to receive(:current) { nil }
27
+ allow(@player).to receive(:each).and_yield track
28
+ expect(@command).to receive(:puts).with(track)
29
29
  @command.execute ''
30
30
  end
31
31
  end
@@ -8,13 +8,14 @@ describe Hearken::Command::Reload do
8
8
  with_help 'reloads the contents of the music library for fast searching'
9
9
 
10
10
  before do
11
- @library = stub('library')
12
- @player = stub('player', :library => @library)
11
+ @library = double 'library'
12
+ @player = double 'player'
13
+ allow(@player).to receive(:library) { @library }
13
14
  @command = Hearken::Command::Reload.new @player
14
15
  end
15
16
 
16
17
  it 'should reload the library' do
17
- @library.should_receive(:reload)
18
+ expect(@library).to receive(:reload)
18
19
  @command.execute '123'
19
20
  end
20
21
  end
@@ -8,23 +8,25 @@ describe Hearken::Command::Shuffle do
8
8
  with_help 'shuffles the current queue'
9
9
 
10
10
  before do
11
- @player = stub 'player'
11
+ @player = double 'player'
12
12
  @command = Hearken::Command::Shuffle.new @player
13
13
  end
14
14
 
15
15
  it 'should dequeue all tracks, shuffle then enqueue them' do
16
- track = stub 'track'
17
- track.should_receive(:id).and_return 1
18
- track.should_receive(:id).and_return 2
19
- track.should_receive(:id).and_return 3
20
- @player.should_receive(:dequeue).and_return track
21
- @player.should_receive(:dequeue).and_return track
22
- @player.should_receive(:dequeue).and_return track
23
- @player.should_receive(:dequeue).and_return nil
24
-
25
- @player.should_receive(:enqueue).with 3
26
- @player.should_receive(:enqueue).with 2
27
- @player.should_receive(:enqueue).with 1
16
+ track = double 'track'
17
+
18
+ expect(track).to receive(:id) { 1 }
19
+ expect(track).to receive(:id) { 2 }
20
+ expect(track).to receive(:id) { 3 }
21
+
22
+ expect(@player).to receive(:dequeue) { track }
23
+ expect(@player).to receive(:dequeue) { track }
24
+ expect(@player).to receive(:dequeue) { track }
25
+ expect(@player).to receive(:dequeue) { nil }
26
+
27
+ expect(@player).to receive(:enqueue) { 1 }
28
+ expect(@player).to receive(:enqueue) { 2 }
29
+ expect(@player).to receive(:enqueue) { 3 }
28
30
 
29
31
  @command.execute
30
32
  end
@@ -6,33 +6,33 @@ describe Hearken::Player do
6
6
  let(:player) { Hearken::Player.new preferences }
7
7
 
8
8
  before do
9
- scrobbler = mock 'scrobbler'
10
- library = mock 'library'
11
- Hearken::Scrobbler.stub!(:new).and_return scrobbler
12
- Hearken::Library.stub!(:new).and_return library
13
- library.stub! :reload
14
- scrobbler.stub! :enabled=
9
+ scrobbler = double 'scrobbler'
10
+ library = double 'library'
11
+ allow(Hearken::Scrobbler).to receive(:new) { scrobbler }
12
+ allow(Hearken::Library).to receive(:new) { library }
13
+ allow(library).to receive(:reload)
14
+ allow(scrobbler).to receive(:enabled=)
15
15
  end
16
16
 
17
17
  describe '#current' do
18
18
  it 'should return current_track when player has pid and file is present' do
19
19
  player.instance_eval { @pid = 1 }
20
- hash = stub 'hash'
21
- File.stub!(:exist?).with('current_song').and_return true
22
- YAML.stub!(:load_file).with('current_song').and_return hash
23
- player.current.should == hash
20
+ hash = double 'hash'
21
+ allow(File).to receive(:exist?).with('current_song') { true }
22
+ allow(YAML).to receive(:load_file).with('current_song') { hash }
23
+ expect(player.current).to eq(hash)
24
24
  end
25
25
 
26
26
  it 'should return nil when player has no pid and file is present' do
27
27
  player.instance_eval { @pid = nil }
28
- File.stub!(:exist?).with('current_song').and_return true
29
- player.current.should == nil
28
+ allow(File).to receive(:exist?).with('current_song') { true }
29
+ expect(player.current).to be_nil
30
30
  end
31
31
 
32
32
  it 'should return nil when has pid and file is not present' do
33
33
  player.instance_eval { @pid = 1 }
34
- File.stub!(:exist?).with('current_song').and_return false
35
- player.current.should == nil
34
+ allow(File).to receive(:exist?).with('current_song') { false }
35
+ expect(player.current).to be_nil
36
36
  end
37
37
  end
38
38
  end
@@ -7,22 +7,22 @@ describe Hearken::RangeExpander do
7
7
  end
8
8
 
9
9
  it 'should expand single values' do
10
- @expander.expand('123').should == [1371]
10
+ expect(@expander.expand('123')).to eq([1371])
11
11
  end
12
12
 
13
13
  it 'should expand multiple values separated by any non digit' do
14
- @expander.expand("123 \t 456 , 789 ").should == [1371, 5370, 9369]
14
+ expect(@expander.expand("123 \t 456 , 789 ")).to eq([1371, 5370, 9369])
15
15
  end
16
16
 
17
17
  it 'should expand a fully specified range' do
18
- @expander.expand(" 456-45i ").should == (5370..5382).to_a
18
+ expect(@expander.expand(" 456-45i ")).to eq((5370..5382).to_a)
19
19
  end
20
20
 
21
21
  it 'should expand an abbreviated range' do
22
- @expander.expand(" 456-i ").should == (5370..5382).to_a
22
+ expect(@expander.expand(" 456-i ")).to eq((5370..5382).to_a)
23
23
  end
24
24
 
25
25
  it 'should expand ids for a range' do
26
- @expander.expand_to_ids(" s-z ").should == %w{s t u v w x y z}
26
+ expect(@expander.expand_to_ids(" s-z ")).to eq(%w{s t u v w x y z})
27
27
  end
28
28
  end
@@ -2,4 +2,15 @@ $: << File.expand_path('../../lib', __FILE__)
2
2
 
3
3
  require 'bundler/setup'
4
4
  require 'rspec'
5
- require 'shell_shock/command_spec'
5
+
6
+ module ShellShock
7
+ module CommandSpec
8
+ def with_usage text
9
+ it('should display usage') { expect(@command.usage).to eq(text) }
10
+ end
11
+
12
+ def with_help text
13
+ it('should display help') { expect(@command.help).to eq(text) }
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,123 +1,110 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hearken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
5
- prerelease:
4
+ version: 0.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mark Ryall
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-09 00:00:00.000000000 Z
11
+ date: 2014-09-09 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: shell_shock
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: rainbow
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '1'
33
+ version: '2'
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
- version: '1'
40
+ version: '2'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: nokogiri
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: '1'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: '1'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ~>
73
+ - - "~>"
84
74
  - !ruby/object:Gem::Version
85
- version: '2'
75
+ version: '3'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ~>
80
+ - - "~>"
92
81
  - !ruby/object:Gem::Version
93
- version: '2'
94
- description: ! 'A command line tool to enqueue and play music tracks.
95
-
82
+ version: '3'
83
+ description: |
84
+ A command line tool to enqueue and play music tracks.
96
85
 
97
86
  This also extracts the tags from a collection of folders.
98
87
 
99
-
100
- This replaces and combines the functionality from a couple of other gems (audio_library
101
- and songbirdsh).
102
-
103
- '
88
+ This replaces and combines the functionality from a couple of other gems (audio_library and songbirdsh).
104
89
  email:
105
90
  - mark@ryall.name
106
91
  executables:
107
92
  - hearken
108
93
  - hearken_index
94
+ - hearken_scrobble
95
+ - hearken_tags
109
96
  extensions: []
110
97
  extra_rdoc_files: []
111
98
  files:
112
- - .cards/4d6da46f-8838-488f-997b-9ec873092d5d
113
- - .cards/68695ed3-ef6c-4c65-939e-48695a4511c8
114
- - .cards/6ed72945-35a4-4372-97d8-13b357d8c7c0
115
- - .cards/91de072e-4427-48dc-89ad-0b03756eb689
116
- - .cards/9242c879-a66f-4144-8f24-b05f7c5a49f3
117
- - .cards/94f23de2-4e0c-417a-aa82-3147908e2481
118
- - .cards/a5be50c4-2117-4ecf-bc64-e9977f4d52c1
119
- - .cards/f742a9f4-36af-43e5-a7cb-480049a43821
120
- - .gitignore
99
+ - ".cards/4d6da46f-8838-488f-997b-9ec873092d5d"
100
+ - ".cards/68695ed3-ef6c-4c65-939e-48695a4511c8"
101
+ - ".cards/6ed72945-35a4-4372-97d8-13b357d8c7c0"
102
+ - ".cards/91de072e-4427-48dc-89ad-0b03756eb689"
103
+ - ".cards/9242c879-a66f-4144-8f24-b05f7c5a49f3"
104
+ - ".cards/94f23de2-4e0c-417a-aa82-3147908e2481"
105
+ - ".cards/a5be50c4-2117-4ecf-bc64-e9977f4d52c1"
106
+ - ".cards/f742a9f4-36af-43e5-a7cb-480049a43821"
107
+ - ".gitignore"
121
108
  - Gemfile
122
109
  - HISTORY.rdoc
123
110
  - MIT-LICENSE
@@ -125,6 +112,8 @@ files:
125
112
  - Rakefile
126
113
  - bin/hearken
127
114
  - bin/hearken_index
115
+ - bin/hearken_scrobble
116
+ - bin/hearken_tags
128
117
  - hearken.gemspec
129
118
  - lib/hearken.rb
130
119
  - lib/hearken/colour.rb
@@ -179,34 +168,35 @@ files:
179
168
  homepage: http://github.com/markryall/hearken
180
169
  licenses:
181
170
  - MIT
182
- post_install_message: ! "Hey - thanks for installing hearken.\n\nBefore doing anything
183
- else, you should index your music collection by running:\n\n hearken_index path_to_your_music_collection\n\nThis
184
- could take a while if you have a large collection - you should hear some applause
185
- when it's done\n\nAfter that just run hearken to start playing, queueing and rocking
186
- out.\n"
171
+ metadata: {}
172
+ post_install_message: |
173
+ Hey - thanks for installing hearken.
174
+
175
+ Before doing anything else, you should index your music collection by running:
176
+
177
+ hearken_index path_to_your_music_collection
178
+
179
+ This could take a while if you have a large collection - you should hear some applause when it's done
180
+
181
+ After that just run hearken to start playing, queueing and rocking out.
187
182
  rdoc_options: []
188
183
  require_paths:
189
184
  - lib
190
185
  required_ruby_version: !ruby/object:Gem::Requirement
191
- none: false
192
186
  requirements:
193
- - - ! '>='
187
+ - - ">="
194
188
  - !ruby/object:Gem::Version
195
189
  version: 1.9.2
196
190
  required_rubygems_version: !ruby/object:Gem::Requirement
197
- none: false
198
191
  requirements:
199
- - - ! '>='
192
+ - - ">="
200
193
  - !ruby/object:Gem::Version
201
194
  version: '0'
202
- segments:
203
- - 0
204
- hash: 2801778265441540950
205
195
  requirements: []
206
196
  rubyforge_project: hearken
207
- rubygems_version: 1.8.23
197
+ rubygems_version: 2.2.2
208
198
  signing_key:
209
- specification_version: 3
199
+ specification_version: 4
210
200
  summary: command line music player
211
201
  test_files:
212
202
  - spec/hearken/command/enqueue_spec.rb