spinna 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/Gemfile +1 -0
- data/README.md +16 -1
- data/lib/spinna.rb +4 -0
- data/lib/spinna/cli.rb +1 -0
- data/lib/spinna/client.rb +1 -0
- data/lib/spinna/config.rb +4 -0
- data/lib/spinna/history.rb +1 -0
- data/lib/spinna/music_library.rb +1 -0
- data/lib/spinna/picker.rb +1 -0
- data/lib/spinna/version.rb +2 -1
- data/spec/fixtures/data_dir/config.yml +1 -1
- data/spec/unit/config_spec.rb +45 -24
- data/spec/unit/history_spec.rb +7 -7
- data/spinna.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00e1136dcfb00747d5be9846956575382fb00892
|
4
|
+
data.tar.gz: c2a0680d7623897bbde5ee57dcfcd8639d87df1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9d735075b974c50d9a5d9fdfedac6786d0caf2361ef812b6ee838c404e250f680efc96a28e8e791eba30441915a9fcdf481f01f93b4ea0903934c8cfb012498
|
7
|
+
data.tar.gz: 65b7489e861410157bb422cb84a06725bace93eb85939b37b89f5a899304b0100425b311d893ffa8f368f882a1866e4c89a52c754d4f6ada11a5b6ac176628d0
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
## 0.0.2 - 2014-08-02
|
5
|
+
|
6
|
+
### Added
|
7
|
+
- Nothing.
|
8
|
+
|
9
|
+
### Deprecated
|
10
|
+
- Nothing.
|
11
|
+
|
12
|
+
### Removed
|
13
|
+
- Nothing.
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- Cleaned up the specs.
|
17
|
+
- Now displays a proper error if the source_dir does not exist.
|
18
|
+
|
19
|
+
## 0.0.1 - 2014-07-31
|
20
|
+
|
21
|
+
### Added
|
22
|
+
- Initial release!
|
23
|
+
- Spinna::Client
|
24
|
+
- Spinna::Config
|
25
|
+
- Spinna::History
|
26
|
+
- Spinna::MusicLibrary
|
27
|
+
- Spinna::Picker
|
28
|
+
- Basic command-line interface using Thor.
|
29
|
+
|
30
|
+
### Deprecated
|
31
|
+
- Nothing.
|
32
|
+
|
33
|
+
### Removed
|
34
|
+
- Nothing.
|
35
|
+
|
36
|
+
### Fixed
|
37
|
+
- Nothing.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -9,6 +9,12 @@ to my current working directory. It will also keep track of the selections made
|
|
9
9
|
in order to improve the rotation by not allowing a recently selected album to be
|
10
10
|
selected again.
|
11
11
|
|
12
|
+
Spinna works great if your music collection is organized as a music directory
|
13
|
+
containing a flat structure of directories where each directory is an album.
|
14
|
+
It’s also helpful if the album folder names follow a proper naming scheme. I
|
15
|
+
use `<ARTIST NAME> - <YEAR> - <ALBUM TITLE>` which allows me to filter albums
|
16
|
+
on artist name or album year.
|
17
|
+
|
12
18
|
## Requirements
|
13
19
|
|
14
20
|
Spinna requires Ruby 1.9+.
|
@@ -48,7 +54,7 @@ To run, simply do:
|
|
48
54
|
|
49
55
|
`spinna get`
|
50
56
|
|
51
|
-
and it will download picks in the current working directory.
|
57
|
+
and it will download the default number of picks in the current working directory.
|
52
58
|
|
53
59
|
You can also request a given number of picks if you want:
|
54
60
|
|
@@ -57,6 +63,15 @@ You can also request a given number of picks if you want:
|
|
57
63
|
and it will pick 10 albums from your music library and download them
|
58
64
|
in the current working directory.
|
59
65
|
|
66
|
+
You can also pass in a pattern to only pick from matching albums. The
|
67
|
+
following would pick 10 albums from the albums that contain the string
|
68
|
+
"2014".
|
69
|
+
|
70
|
+
`spinna get -n 10 -p 2014`
|
71
|
+
|
72
|
+
## Tests
|
73
|
+
|
74
|
+
To run the test, run `bundle exec rake`.
|
60
75
|
|
61
76
|
## Contributing
|
62
77
|
|
data/lib/spinna.rb
CHANGED
data/lib/spinna/cli.rb
CHANGED
data/lib/spinna/client.rb
CHANGED
data/lib/spinna/config.rb
CHANGED
@@ -49,6 +49,10 @@ module Spinna
|
|
49
49
|
unless source_dir
|
50
50
|
raise Spinna::InvalidConfigFileError, "You must set a source_dir in your configuration file."
|
51
51
|
end
|
52
|
+
|
53
|
+
unless Dir.exists?(source_dir)
|
54
|
+
raise Spinna::InvalidSourceDirError, "The source_dir #{source_dir} does not exist."
|
55
|
+
end
|
52
56
|
end
|
53
57
|
|
54
58
|
def ensure_data_dir_exists
|
data/lib/spinna/history.rb
CHANGED
data/lib/spinna/music_library.rb
CHANGED
data/lib/spinna/picker.rb
CHANGED
data/lib/spinna/version.rb
CHANGED
data/spec/unit/config_spec.rb
CHANGED
@@ -21,10 +21,6 @@ describe Spinna::Config do
|
|
21
21
|
context 'when the data_dir does not exist' do
|
22
22
|
let(:opts) { {:data_dir => non_existing_data_dir} }
|
23
23
|
|
24
|
-
subject {
|
25
|
-
Hash.new(:foo => 'bar')
|
26
|
-
}
|
27
|
-
|
28
24
|
it 'creates it and raises error because the configuration file is missing' do
|
29
25
|
Dir.expects(:mkdir).with(opts[:data_dir], 0700)
|
30
26
|
proc { Spinna::Config.new(opts) }.must_raise Spinna::ConfigFileNotFoundError
|
@@ -43,17 +39,19 @@ describe Spinna::Config do
|
|
43
39
|
end
|
44
40
|
|
45
41
|
it 'throws an exception' do
|
46
|
-
opts = {:data_dir => non_existing_data_dir}
|
47
42
|
err = proc { subject }.must_raise Spinna::ConfigFileNotFoundError
|
48
43
|
err.message.must_match %r{Could not find the configuration file.}
|
49
44
|
end
|
50
45
|
end
|
51
46
|
|
52
47
|
context 'when the configuration file is not valid json' do
|
48
|
+
before do
|
49
|
+
YAML.stubs(:load_file).returns("&&&foo")
|
50
|
+
end
|
51
|
+
|
53
52
|
it 'throws an exception' do
|
54
53
|
opts = {
|
55
|
-
:data_dir => data_dir
|
56
|
-
:config_file => 'config1.yml'
|
54
|
+
:data_dir => data_dir
|
57
55
|
}
|
58
56
|
err = proc { Spinna::Config.new(opts) }.must_raise Spinna::InvalidConfigFileError
|
59
57
|
err.message.must_match %r{Could not parse the configuration file.}
|
@@ -61,16 +59,32 @@ describe Spinna::Config do
|
|
61
59
|
end
|
62
60
|
|
63
61
|
context 'when the source_dir config parameter is missing' do
|
62
|
+
before do
|
63
|
+
YAML.stubs(:load_file).returns({'foo' => 'bar'})
|
64
|
+
end
|
65
|
+
|
64
66
|
it 'throws an exception' do
|
65
|
-
opts = {
|
66
|
-
:data_dir => data_dir,
|
67
|
-
:config_file => 'config2.yml'
|
68
|
-
}
|
67
|
+
opts = {:data_dir => data_dir}
|
69
68
|
err = proc { Spinna::Config.new(opts) }.must_raise Spinna::InvalidConfigFileError
|
70
69
|
err.message.must_match %r{You must set a source_dir in your configuration file.}
|
71
70
|
end
|
72
71
|
end
|
73
72
|
|
73
|
+
context 'when the source_dir does not actually exist on the filesystem' do
|
74
|
+
before do
|
75
|
+
YAML.stubs(:load_file).returns({
|
76
|
+
'source_dir' => '/this/dir/does/not/exist'
|
77
|
+
})
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'throws an exception' do
|
81
|
+
opts = {
|
82
|
+
:data_dir => data_dir
|
83
|
+
}
|
84
|
+
proc { Spinna::Config.new(opts) }.must_raise Spinna::InvalidSourceDirError
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
74
88
|
context 'when the configuration is valid and all parameters were provided' do
|
75
89
|
it 'sets the source_dir' do
|
76
90
|
opts = {
|
@@ -78,7 +92,7 @@ describe Spinna::Config do
|
|
78
92
|
:config_file => 'config.yml'
|
79
93
|
}
|
80
94
|
config = Spinna::Config.new(opts)
|
81
|
-
config.source_dir.must_equal '/
|
95
|
+
config.source_dir.must_equal '/tmp'
|
82
96
|
end
|
83
97
|
|
84
98
|
it 'sets the history_size' do
|
@@ -101,25 +115,32 @@ describe Spinna::Config do
|
|
101
115
|
end
|
102
116
|
|
103
117
|
context 'when the configuration is valid but the history_size was not provided' do
|
118
|
+
let(:opts) { {:data_dir => data_dir} }
|
119
|
+
|
120
|
+
subject { Spinna::Config.new(opts) }
|
121
|
+
|
122
|
+
before do
|
123
|
+
YAML.stubs(:load_file).returns({'source_dir' => '/tmp'})
|
124
|
+
end
|
125
|
+
|
104
126
|
it 'uses the default value' do
|
105
|
-
|
106
|
-
:data_dir => data_dir,
|
107
|
-
:config_file => 'config3.yml'
|
108
|
-
}
|
109
|
-
config = Spinna::Config.new(opts)
|
110
|
-
config.history_size.must_equal Spinna::Config::DEFAULT_HISTORY_SIZE
|
127
|
+
subject.history_size.must_equal Spinna::Config::DEFAULT_HISTORY_SIZE
|
111
128
|
end
|
112
129
|
end
|
113
130
|
|
114
131
|
context 'when the configuration is valid but the number_of_picks was not provided' do
|
132
|
+
let(:opts) { {:data_dir => data_dir} }
|
133
|
+
|
134
|
+
subject { Spinna::Config.new(opts) }
|
135
|
+
|
136
|
+
before do
|
137
|
+
YAML.stubs(:load_file).returns({'source_dir' => '/tmp'})
|
138
|
+
end
|
139
|
+
|
115
140
|
it 'uses the default value' do
|
116
|
-
|
117
|
-
:data_dir => data_dir,
|
118
|
-
:config_file => 'config4.yml'
|
119
|
-
}
|
120
|
-
config = Spinna::Config.new(opts)
|
121
|
-
config.number_of_picks.must_equal Spinna::Config::DEFAULT_NUMBER_OF_PICKS
|
141
|
+
subject.number_of_picks.must_equal Spinna::Config::DEFAULT_NUMBER_OF_PICKS
|
122
142
|
end
|
123
143
|
end
|
124
144
|
end
|
125
145
|
end
|
146
|
+
|
data/spec/unit/history_spec.rb
CHANGED
@@ -5,7 +5,7 @@ require 'spinna/config'
|
|
5
5
|
describe Spinna::History do
|
6
6
|
let(:data_dir) { File.expand_path("../../fixtures/data_dir", __FILE__) }
|
7
7
|
let(:opts) { {:data_dir => data_dir} }
|
8
|
-
let(:config) {
|
8
|
+
let(:config) { stub(:data_dir => data_dir, :history_size => 10 ) }
|
9
9
|
let(:history_size) { 3 }
|
10
10
|
|
11
11
|
describe '#new' do
|
@@ -41,8 +41,8 @@ describe Spinna::History do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
context 'when the history log is full' do
|
44
|
+
let(:config) { stub(:data_dir => data_dir, :history_size => 3) }
|
44
45
|
it 'removes the old albums from the log to make room for the new albums' do
|
45
|
-
subject.config.history_size = 3
|
46
46
|
subject.append('album 4')
|
47
47
|
subject.log.size.must_equal 3
|
48
48
|
subject.log.first.must_equal 'album 2'
|
@@ -69,14 +69,14 @@ describe Spinna::History do
|
|
69
69
|
|
70
70
|
describe '#save' do
|
71
71
|
# This is used to fake writing the history.log file.
|
72
|
-
let(:
|
72
|
+
let(:history_log) { StringIO.new('', 'w+') }
|
73
73
|
|
74
|
+
subject { Spinna::History.new(config) }
|
74
75
|
it 'saves the log to the filesystem' do
|
75
|
-
subject
|
76
|
-
# Use of mocking here so that we don’t actually write to the filesystem.
|
77
|
-
File.expects(:open).with(subject.history_path, 'w+').yields(fake_history_log)
|
76
|
+
File.expects(:open).with(subject.history_path, 'w+').yields(history_log)
|
78
77
|
subject.save
|
79
|
-
|
78
|
+
history_log.string.must_equal "album 1\nalbum 2\nalbum 3\n"
|
80
79
|
end
|
81
80
|
end
|
82
81
|
end
|
82
|
+
|
data/spinna.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Spinna::VERSION
|
9
9
|
spec.authors = ["Patrick Paul-Hus"]
|
10
10
|
spec.email = ["hydrozen@gmail.com"]
|
11
|
-
spec.summary = %q{Randomly picks albums from your music library
|
11
|
+
spec.summary = %q{Randomly picks albums from your music library so you don’t have to.}
|
12
12
|
spec.description = ""
|
13
13
|
spec.homepage = "https://github.com/hydrozen/spinna"
|
14
14
|
spec.license = "MIT"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spinna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Paul-Hus
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,6 +132,7 @@ extra_rdoc_files: []
|
|
132
132
|
files:
|
133
133
|
- ".gitignore"
|
134
134
|
- ".travis.yml"
|
135
|
+
- CHANGELOG.md
|
135
136
|
- Gemfile
|
136
137
|
- LICENSE.txt
|
137
138
|
- README.md
|
@@ -185,7 +186,7 @@ rubyforge_project:
|
|
185
186
|
rubygems_version: 2.2.2
|
186
187
|
signing_key:
|
187
188
|
specification_version: 4
|
188
|
-
summary: Randomly picks albums from your music library
|
189
|
+
summary: Randomly picks albums from your music library so you don’t have to.
|
189
190
|
test_files:
|
190
191
|
- spec/fixtures/data_dir/config.yml
|
191
192
|
- spec/fixtures/data_dir/config1.yml
|