bowie 0.3.8 → 0.3.9
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/song_utils.rb +59 -15
- data/lib/bowie/version.rb +1 -1
- data/spec/bowie/actions/install_spec.rb +58 -0
- data/spec/{actions → bowie/actions}/list_spec.rb +0 -0
- data/spec/{actions → bowie/actions}/prune_spec.rb +0 -0
- data/spec/{actions → bowie/actions}/search_spec.rb +0 -0
- data/spec/{actions → bowie/actions}/uninstall_spec.rb +0 -0
- data/spec/{actions → bowie/actions}/update_spec.rb +0 -0
- data/spec/bowie/song_utils_spec.rb +81 -0
- data/spec/bowie_spec.rb +3 -4
- metadata +16 -14
- data/spec/actions/install_spec.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1d11347f6f13ef0b6277970b9a3ddd1be58ee5b
|
4
|
+
data.tar.gz: 2ddb2a6e22adc24846c9f872844784e863835fdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec78b408d237502e9d225e647edc83cb2902cfcce9dc63d5642dc28d81ac0a507cf525b5a409856cb06d24f7b2bdbd4c65355183a5f7c01382ac8e610b1be840
|
7
|
+
data.tar.gz: 46f11400095274a130c39fcd4cee63aadeb4d1640a80796b8238b920892bd7afcea62b064bf2bacad47abdfe13ec6f413af4b2e7b865430486ef4ce3ce20aee6
|
data/lib/bowie/song_utils.rb
CHANGED
@@ -5,34 +5,37 @@ module Bowie
|
|
5
5
|
begin
|
6
6
|
YAML.parse(open("https://raw.github.com/axyz/bowie-songs/master/songs.yml")).to_ruby
|
7
7
|
rescue
|
8
|
-
|
8
|
+
raise "cannot connect to github.com"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
# Retrive the local registry of installed songs
|
13
13
|
def self.get_local_songs
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
if File.exist? 'songs.yml'
|
15
|
+
if self.valid_songs_file? 'songs.yml'
|
16
|
+
self.check_songs_dir
|
17
|
+
return YAML.load_file('songs.yml')
|
18
|
+
else
|
19
|
+
raise "songs.yml is not valid"
|
20
20
|
end
|
21
|
-
|
21
|
+
else
|
22
|
+
self.create_empty_songs_file
|
23
|
+
self.check_songs_dir
|
22
24
|
return Array.new
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
28
|
# Retrive the local lyrics file
|
27
29
|
def self.get_local_lyrics
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
rescue
|
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')
|
33
|
+
else
|
34
|
+
raise "bowie_songs/lyrics.yml is not valid"
|
34
35
|
end
|
35
|
-
|
36
|
+
else
|
37
|
+
self.check_songs_dir
|
38
|
+
self.create_empty_lyrics_file
|
36
39
|
return Hash.new
|
37
40
|
end
|
38
41
|
end
|
@@ -57,5 +60,46 @@ module Bowie
|
|
57
60
|
def self.parse_song_version(s)
|
58
61
|
s.split("#")[1]
|
59
62
|
end
|
63
|
+
|
64
|
+
def self.valid_songs_file?(file)
|
65
|
+
begin
|
66
|
+
f = YAML.load_file file
|
67
|
+
f.each do |s|
|
68
|
+
unless valid_song? s
|
69
|
+
return false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
return true
|
73
|
+
rescue
|
74
|
+
return false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.valid_song?(string)
|
79
|
+
(string =~ /^[a-z0-9]+(-?[a-z0-9])*(#\d+.\d+.\d+)?$/) == nil ? false : true
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.valid_lyrics_file?(file)
|
83
|
+
begin
|
84
|
+
f = YAML.load_file file
|
85
|
+
(f.is_a? Hash)? true : false
|
86
|
+
rescue
|
87
|
+
false
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.create_empty_songs_file
|
92
|
+
File.open("./songs.yml", "w"){|f| YAML.dump(Array.new, f)}
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.check_songs_dir
|
96
|
+
unless File.directory? 'bowie_songs'
|
97
|
+
FileUtils.mkdir 'bowie_songs'
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.create_empty_lyrics_file
|
102
|
+
File.open("./bowie_songs/lyrics.yml", "w"){|f| YAML.dump(Hash.new, f)}
|
103
|
+
end
|
60
104
|
end
|
61
105
|
end
|
data/lib/bowie/version.rb
CHANGED
@@ -0,0 +1,58 @@
|
|
1
|
+
describe "Bowie::Actions" do
|
2
|
+
it ".install [song]" do
|
3
|
+
expect {Bowie::Actions.install('bowie-test')}.to_not raise_error
|
4
|
+
expect(File.directory? './bowie_songs').to be true
|
5
|
+
expect(File.directory? './bowie_songs/bowie-test').to be true
|
6
|
+
expect(File.exist? './songs.yml').to be true
|
7
|
+
expect(Bowie::SongUtils.get_local_songs.include? 'bowie-test').to be true
|
8
|
+
expect(Bowie::SongUtils.get_local_songs.length).to be 1
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when songs.yml exist" do
|
12
|
+
before(:each) do
|
13
|
+
File.open("./songs.yml", "w"){|f| YAML.dump(["bowie-test"], f)}
|
14
|
+
end
|
15
|
+
after(:each) do
|
16
|
+
FileUtils.rm_rf('./songs.yml')
|
17
|
+
end
|
18
|
+
|
19
|
+
it "install with no argument" do
|
20
|
+
expect {Bowie::Actions.install()}.to_not raise_error
|
21
|
+
expect(File.directory? './bowie_songs').to be true
|
22
|
+
expect(File.directory? './bowie_songs/bowie-test').to be true
|
23
|
+
expect(File.exist? './songs.yml').to be true
|
24
|
+
expect(Bowie::SongUtils.get_local_songs.include? 'bowie-test').to be true
|
25
|
+
expect(Bowie::SongUtils.get_local_songs.length).to be 1
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when songs.yml do not exist" do
|
30
|
+
it "install with no argument" do
|
31
|
+
expect {Bowie::Actions.install()}.to_not raise_error
|
32
|
+
expect(File.directory? './bowie_songs').to be true
|
33
|
+
expect(File.directory? './bowie_songs/bowie-test').to be false
|
34
|
+
expect(File.exist? './songs.yml').to be true
|
35
|
+
expect(Bowie::SongUtils.get_local_songs.include? 'bowie-test').to be false
|
36
|
+
expect(Bowie::SongUtils.get_local_songs.length).to be 0
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "when songs.yml is not valid" do
|
41
|
+
before(:each) do
|
42
|
+
h = Hash.new
|
43
|
+
h['bowie-test'] = '0.0.1'
|
44
|
+
File.open("./songs.yml", "w"){|f| YAML.dump(h, f)}
|
45
|
+
end
|
46
|
+
after(:each) do
|
47
|
+
FileUtils.rm_rf('./songs.yml')
|
48
|
+
end
|
49
|
+
|
50
|
+
it "install with no argument" do
|
51
|
+
expect {Bowie::Actions.install()}.to raise_error "songs.yml is not valid"
|
52
|
+
expect(File.directory? './bowie_songs').to be false
|
53
|
+
expect(File.directory? './bowie_songs/bowie-test').to be false
|
54
|
+
expect(File.exist? './songs.yml').to be true
|
55
|
+
expect(Bowie::SongUtils.valid_songs_file? './songs.yml').to be false
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,81 @@
|
|
1
|
+
describe "Bowie::SongUtils" do
|
2
|
+
it ".parse_song_name" do
|
3
|
+
expect {Bowie::SongUtils.parse_song_name 'bowie-test#0.0.1'}.to_not raise_error
|
4
|
+
expect(Bowie::SongUtils.parse_song_name 'bowie-test#0.0.1').to match "bowie-test"
|
5
|
+
end
|
6
|
+
|
7
|
+
it ".parse_song_version" do
|
8
|
+
expect {Bowie::SongUtils.parse_song_version 'bowie-test#0.0.1'}.to_not raise_error
|
9
|
+
expect(Bowie::SongUtils.parse_song_version 'bowie-test#0.0.1').to match "0.0.1"
|
10
|
+
end
|
11
|
+
|
12
|
+
it ".valid_song?" do
|
13
|
+
expect(Bowie::SongUtils.valid_song? 'bowie-test').to be true
|
14
|
+
expect(Bowie::SongUtils.valid_song? 'bowie-test#0.0.1').to be true
|
15
|
+
expect(Bowie::SongUtils.valid_song? '-foo-bar').to be false
|
16
|
+
expect(Bowie::SongUtils.valid_song? 'foo-bar-').to be false
|
17
|
+
expect(Bowie::SongUtils.valid_song? 'foo-bar-#0.0.1').to be false
|
18
|
+
expect(Bowie::SongUtils.valid_song? 'foo-bar#0.1').to be false
|
19
|
+
expect(Bowie::SongUtils.valid_song? 'foo-bar#0.1.2.3').to be false
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when lyrics.yml is valid" do
|
23
|
+
before(:each) do
|
24
|
+
File.open("./lyrics.yml", "w"){|f| YAML.dump(Hash.new, f)}
|
25
|
+
end
|
26
|
+
after(:each) do
|
27
|
+
FileUtils.rm_rf('./lyrics.yml')
|
28
|
+
end
|
29
|
+
|
30
|
+
it ".valid_lyrics_file?" do
|
31
|
+
expect {Bowie::SongUtils.valid_lyrics_file? './lyrics.yml'}.to_not raise_error
|
32
|
+
expect(Bowie::SongUtils.valid_lyrics_file? './lyrics.yml').to be true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when lyrics.yml is not valid" do
|
37
|
+
before(:each) do
|
38
|
+
File.open("./lyrics.yml", "w"){|f| YAML.dump(Array.new, f)}
|
39
|
+
end
|
40
|
+
after(:each) do
|
41
|
+
FileUtils.rm_rf('./lyrics.yml')
|
42
|
+
end
|
43
|
+
|
44
|
+
it ".valid_lyrics_file?" do
|
45
|
+
expect {Bowie::SongUtils.valid_lyrics_file? './lyrics.yml'}.to_not raise_error
|
46
|
+
expect(Bowie::SongUtils.valid_lyrics_file? './lyrics.yml').to be false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when songs.yml is valid" do
|
51
|
+
before(:each) do
|
52
|
+
File.open("./songs.yml", "w"){|f| YAML.dump(["bowie-test", "foo", "bar"], f)}
|
53
|
+
end
|
54
|
+
after(:each) do
|
55
|
+
FileUtils.rm_rf('./songs.yml')
|
56
|
+
end
|
57
|
+
|
58
|
+
it ".valid_songs_file?" do
|
59
|
+
expect {Bowie::SongUtils.valid_songs_file? './songs.yml'}.to_not raise_error
|
60
|
+
expect(Bowie::SongUtils.valid_songs_file? './songs.yml').to be true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when songs.yml is not valid" do
|
65
|
+
before(:each) do
|
66
|
+
h = Hash.new
|
67
|
+
h["bowie-test"] = ".0.1"
|
68
|
+
h["susy"] = "0.0.1"
|
69
|
+
File.open("./songs.yml", "w"){|f| YAML.dump(h, f)}
|
70
|
+
end
|
71
|
+
after(:each) do
|
72
|
+
FileUtils.rm_rf('./songs.yml')
|
73
|
+
end
|
74
|
+
|
75
|
+
it ".valid_songs_file?" do
|
76
|
+
expect {Bowie::SongUtils.valid_songs_file? './songs.yml'}.to_not raise_error
|
77
|
+
expect(Bowie::SongUtils.valid_songs_file? './songs.yml').to be false
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/spec/bowie_spec.rb
CHANGED
@@ -3,9 +3,8 @@ require './lib/bowie'
|
|
3
3
|
require './spec/spec_helper.rb'
|
4
4
|
|
5
5
|
describe "Bowie" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
6
|
+
require './spec/bowie/song_utils_spec'
|
7
|
+
Dir.glob('./spec/bowie/actions/*') do |spec|
|
8
|
+
require spec
|
10
9
|
end
|
11
10
|
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.
|
4
|
+
version: 0.3.9
|
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-
|
11
|
+
date: 2013-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,12 +108,13 @@ files:
|
|
108
108
|
- lib/bowie/utils.rb
|
109
109
|
- lib/bowie/version.rb
|
110
110
|
- lib/semver/semver.rb
|
111
|
-
- spec/actions/install_spec.rb
|
112
|
-
- spec/actions/list_spec.rb
|
113
|
-
- spec/actions/prune_spec.rb
|
114
|
-
- spec/actions/search_spec.rb
|
115
|
-
- spec/actions/uninstall_spec.rb
|
116
|
-
- spec/actions/update_spec.rb
|
111
|
+
- spec/bowie/actions/install_spec.rb
|
112
|
+
- spec/bowie/actions/list_spec.rb
|
113
|
+
- spec/bowie/actions/prune_spec.rb
|
114
|
+
- spec/bowie/actions/search_spec.rb
|
115
|
+
- spec/bowie/actions/uninstall_spec.rb
|
116
|
+
- spec/bowie/actions/update_spec.rb
|
117
|
+
- spec/bowie/song_utils_spec.rb
|
117
118
|
- spec/bowie_spec.rb
|
118
119
|
- spec/spec_helper.rb
|
119
120
|
homepage: http://axyz.github.io/bowie/
|
@@ -141,11 +142,12 @@ signing_key:
|
|
141
142
|
specification_version: 4
|
142
143
|
summary: The White Duke rules them all
|
143
144
|
test_files:
|
144
|
-
- spec/actions/install_spec.rb
|
145
|
-
- spec/actions/list_spec.rb
|
146
|
-
- spec/actions/prune_spec.rb
|
147
|
-
- spec/actions/search_spec.rb
|
148
|
-
- spec/actions/uninstall_spec.rb
|
149
|
-
- spec/actions/update_spec.rb
|
145
|
+
- spec/bowie/actions/install_spec.rb
|
146
|
+
- spec/bowie/actions/list_spec.rb
|
147
|
+
- spec/bowie/actions/prune_spec.rb
|
148
|
+
- spec/bowie/actions/search_spec.rb
|
149
|
+
- spec/bowie/actions/uninstall_spec.rb
|
150
|
+
- spec/bowie/actions/update_spec.rb
|
151
|
+
- spec/bowie/song_utils_spec.rb
|
150
152
|
- spec/bowie_spec.rb
|
151
153
|
- spec/spec_helper.rb
|
@@ -1,10 +0,0 @@
|
|
1
|
-
describe "Bowie::Actions" do
|
2
|
-
it ".install [song]" do
|
3
|
-
expect {Bowie::Actions.install('bowie-test')}.to_not raise_error
|
4
|
-
expect(File.directory? './bowie_songs').to be true
|
5
|
-
expect(File.directory? './bowie_songs/bowie-test').to be true
|
6
|
-
expect(File.exist? './songs.yml').to be true
|
7
|
-
expect(Bowie::SongUtils.get_local_songs.include? 'bowie-test').to be true
|
8
|
-
expect(Bowie::SongUtils.get_local_songs.length).to be 1
|
9
|
-
end
|
10
|
-
end
|