bowie 0.3.11 → 0.4.1
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.
- checksums.yaml +4 -4
- data/lib/bowie/actions/get.rb +1 -1
- data/lib/bowie/actions/install.rb +1 -1
- data/lib/bowie/actions/prune.rb +1 -1
- data/lib/bowie/actions/uninstall.rb +1 -1
- data/lib/bowie/actions/update.rb +1 -1
- data/lib/bowie/song_utils.rb +18 -8
- data/lib/bowie/version.rb +1 -1
- data/spec/bowie/actions/get_spec.rb +1 -0
- data/spec/bowie/song_utils_spec.rb +39 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fa7d85ce9a40d75e9f8e7614258f77e31fa2dc5
|
4
|
+
data.tar.gz: a6b502b078f8a2ef145795e9e3acc814a9f6b547
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2fe012d8083513a4a9eb865f40471b5277ad249fabb22c676edbd58c9709fa3d44dc828ab759cda80fe38c9333cfbe0ad1b1474725b075738a7a7f38883d34b
|
7
|
+
data.tar.gz: e207f998bd9cecc8890ea6b130e2f35d5f18de57560d8c11d40ab6b7b8e167ed1445af96f755613ced5f71eb373d952b9d9098ff8aed310f96a72a351bb98e78
|
data/lib/bowie/actions/get.rb
CHANGED
data/lib/bowie/actions/prune.rb
CHANGED
data/lib/bowie/actions/update.rb
CHANGED
data/lib/bowie/song_utils.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
module Bowie
|
2
2
|
module SongUtils
|
3
|
+
|
4
|
+
def self.get_bowie_dir
|
5
|
+
if File.exist? '.bowierc'
|
6
|
+
f = YAML.load_file '.bowierc'
|
7
|
+
(f['bowie-dir'] == nil) ? (return 'bowie_songs') : (return f['bowie-dir'])
|
8
|
+
else
|
9
|
+
return 'bowie_songs'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
3
13
|
# Retrive the online registry of available songs
|
4
14
|
def self.get_songs
|
5
15
|
begin
|
@@ -27,11 +37,11 @@ module Bowie
|
|
27
37
|
|
28
38
|
# Retrive the local lyrics file
|
29
39
|
def self.get_local_lyrics
|
30
|
-
if File.exist?
|
31
|
-
if self.valid_lyrics_file?
|
32
|
-
return YAML.load_file(
|
40
|
+
if File.exist? "#{self.get_bowie_dir}/lyrics.yml"
|
41
|
+
if self.valid_lyrics_file? "#{self.get_bowie_dir}/lyrics.yml"
|
42
|
+
return YAML.load_file("#{self.get_bowie_dir}/lyrics.yml")
|
33
43
|
else
|
34
|
-
raise "
|
44
|
+
raise "#{self.get_bowie_dir}/lyrics.yml is not valid"
|
35
45
|
end
|
36
46
|
else
|
37
47
|
self.check_songs_dir
|
@@ -43,7 +53,7 @@ module Bowie
|
|
43
53
|
# Return an array with all the direcotry inside bowye_songs
|
44
54
|
def self.get_songs_dirs
|
45
55
|
result = []
|
46
|
-
Dir.foreach(
|
56
|
+
Dir.foreach(self.get_bowie_dir) do |el|
|
47
57
|
unless (el == "." or el == ".." or el == "lyrics.yml")
|
48
58
|
result.push el
|
49
59
|
end
|
@@ -107,13 +117,13 @@ module Bowie
|
|
107
117
|
end
|
108
118
|
|
109
119
|
def self.check_songs_dir
|
110
|
-
unless File.directory?
|
111
|
-
FileUtils.mkdir
|
120
|
+
unless File.directory? self.get_bowie_dir
|
121
|
+
FileUtils.mkdir self.get_bowie_dir
|
112
122
|
end
|
113
123
|
end
|
114
124
|
|
115
125
|
def self.create_empty_lyrics_file
|
116
|
-
File.open("
|
126
|
+
File.open("./#{self.get_bowie_dir}/lyrics.yml", "w"){|f| YAML.dump(Hash.new, f)}
|
117
127
|
end
|
118
128
|
|
119
129
|
end
|
data/lib/bowie/version.rb
CHANGED
@@ -114,4 +114,43 @@ describe "Bowie::SongUtils" do
|
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|
117
|
+
context "when .bowierc exist and is valid" do
|
118
|
+
before(:each) do
|
119
|
+
h = Hash.new
|
120
|
+
h["bowie-dir"] = "foo"
|
121
|
+
File.open("./.bowierc", "w"){|f| YAML.dump(h, f)}
|
122
|
+
end
|
123
|
+
after(:each) do
|
124
|
+
FileUtils.rm_rf('./.bowierc')
|
125
|
+
end
|
126
|
+
|
127
|
+
it ".valid_songs_file?" do
|
128
|
+
expect {Bowie::SongUtils.get_bowie_dir}.to_not raise_error
|
129
|
+
expect(Bowie::SongUtils.get_bowie_dir).to match "foo"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "when .bowierc exist and is not valid" do
|
134
|
+
before(:each) do
|
135
|
+
h = Hash.new
|
136
|
+
h["bowie"] = "foo"
|
137
|
+
File.open("./.bowierc", "w"){|f| YAML.dump(h, f)}
|
138
|
+
end
|
139
|
+
after(:each) do
|
140
|
+
FileUtils.rm_rf('./.bowierc')
|
141
|
+
end
|
142
|
+
|
143
|
+
it ".valid_songs_file?" do
|
144
|
+
expect {Bowie::SongUtils.get_bowie_dir}.to_not raise_error
|
145
|
+
expect(Bowie::SongUtils.get_bowie_dir).to match "bowie_songs"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
context "when .bowierc do not exist" do
|
150
|
+
it ".valid_songs_file?" do
|
151
|
+
expect {Bowie::SongUtils.get_bowie_dir}.to_not raise_error
|
152
|
+
expect(Bowie::SongUtils.get_bowie_dir).to match "bowie_songs"
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
117
156
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bowie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrea Moretti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|