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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75ab56cdb9510cd448eafbd96c1fdde3a73ae160
4
- data.tar.gz: 3cebaac0a1f7b284ef92532956e39eae8111b51b
3
+ metadata.gz: 0fa7d85ce9a40d75e9f8e7614258f77e31fa2dc5
4
+ data.tar.gz: a6b502b078f8a2ef145795e9e3acc814a9f6b547
5
5
  SHA512:
6
- metadata.gz: 5f804cf36522ffaaec3c0db1ebcda964243c8d736e50e245074569e5756ddccdfaf3bdd9252e10be8e657a34a7040e35990861614fafd0b7ea55a0d4299573ab
7
- data.tar.gz: 7b3af97e43d4d424691df13555c72298365e970f60b9b9f30f2b57ff6fcb61e135b3c2c203879b2c24e4a353226b0966232edf922e4c89b5889f77bfe7d29d26
6
+ metadata.gz: d2fe012d8083513a4a9eb865f40471b5277ad249fabb22c676edbd58c9709fa3d44dc828ab759cda80fe38c9333cfbe0ad1b1474725b075738a7a7f38883d34b
7
+ data.tar.gz: e207f998bd9cecc8890ea6b130e2f35d5f18de57560d8c11d40ab6b7b8e167ed1445af96f755613ced5f71eb373d952b9d9098ff8aed310f96a72a351bb98e78
@@ -6,7 +6,7 @@ module Bowie
6
6
  raise "song not installed"
7
7
  end
8
8
  begin
9
- @lyrics = YAML.load_file("bowie_songs/#{song}/bowie.yml")
9
+ @lyrics = YAML.load_file("#{SongUtils.get_bowie_dir}/#{song}/bowie.yml")
10
10
  rescue
11
11
  raise "bowie.yml not found"
12
12
  end
@@ -13,7 +13,7 @@ module Bowie
13
13
  version = false
14
14
  end
15
15
  url = @songs[name]['url']
16
- path = "bowie_songs/#{name}"
16
+ path = "#{SongUtils.get_bowie_dir}/#{name}"
17
17
 
18
18
  if File.directory? path
19
19
  self.update(name)
@@ -6,7 +6,7 @@ module Bowie
6
6
 
7
7
  SongUtils.get_songs_dirs.each do |dir|
8
8
  unless @local_songs.include? dir
9
- FileUtils.rm_rf("bowie_songs/#{dir}")
9
+ FileUtils.rm_rf("#{SongUtils.get_bowie_dir}/#{dir}")
10
10
  end
11
11
  end
12
12
  end
@@ -12,7 +12,7 @@ module Bowie
12
12
  rescue
13
13
  version = false
14
14
  end
15
- path = "bowie_songs/#{name}"
15
+ path = "#{SongUtils.get_bowie_dir}/#{name}"
16
16
 
17
17
  FileUtils.rm_rf(path) # use remove_entry_secure for security reasons?
18
18
 
@@ -13,7 +13,7 @@ module Bowie
13
13
  rescue
14
14
  version = false
15
15
  end
16
- path = "bowie_songs/#{name}"
16
+ path = "#{SongUtils.get_bowie_dir}/#{name}"
17
17
 
18
18
  g = Git.open(path, :log => Logger.new(STDOUT))
19
19
  g.reset_hard('HEAD')
@@ -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? 'bowie_songs/lyrics.yml'
31
- if self.valid_lyrics_file? 'bowie_songs/lyrics.yml'
32
- return YAML.load_file('bowie_songs/lyrics.yml')
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 "bowie_songs/lyrics.yml is not valid"
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('bowie_songs') do |el|
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? 'bowie_songs'
111
- FileUtils.mkdir 'bowie_songs'
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("./bowie_songs/lyrics.yml", "w"){|f| YAML.dump(Hash.new, f)}
126
+ File.open("./#{self.get_bowie_dir}/lyrics.yml", "w"){|f| YAML.dump(Hash.new, f)}
117
127
  end
118
128
 
119
129
  end
@@ -1,3 +1,3 @@
1
1
  module Bowie
2
- VERSION = "0.3.11"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -9,6 +9,7 @@ describe "Bowie::Actions" do
9
9
 
10
10
  it ".get" do
11
11
  expect {Bowie::Actions.get('bowie-test', 'foo')}.to_not raise_error
12
+ expect(Bowie::Actions.get('bowie-test', 'foo')).to match "bar"
12
13
  end
13
14
  end
14
15
 
@@ -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.3.11
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-26 00:00:00.000000000 Z
11
+ date: 2013-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler