bowie 0.0.4 → 0.1.0
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/bin/bowie +4 -0
- data/lib/bowie.rb +48 -4
- data/lib/bowie/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4619ca670d4770bd49a0ca0952ee0fc9f73bd3ad
|
4
|
+
data.tar.gz: d9ed7416284ff70208266cac8d00e9e499dc3f6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bd95c602a6f88992cd2e6ae431d54c9f72903476927e78af8251434762e48e53b8cdcdbb157d84fd609f1ecd8fb2f7086a3528f1cf8b3ea64b117f45f74538f
|
7
|
+
data.tar.gz: d253c8c3643cadc21023f4cb0dcc8fe7808f77c9ccdac55728985f937676fada699cf85bb6dcd2d9b6451bf5e05bf3d1070ec43ef2386bde4f5760c406472c51
|
data/bin/bowie
CHANGED
data/lib/bowie.rb
CHANGED
@@ -7,35 +7,79 @@ require "logger"
|
|
7
7
|
|
8
8
|
module Bowie
|
9
9
|
|
10
|
-
|
11
|
-
@
|
10
|
+
@songs
|
11
|
+
@local_songs
|
12
|
+
@local_lyrics
|
12
13
|
|
13
|
-
#
|
14
|
+
# Retrive the online registry of available songs
|
14
15
|
def self.get_songs
|
15
|
-
|
16
|
+
begin
|
17
|
+
YAML.parse(open("https://raw.github.com/axyz/bowie-songs/master/songs.yml")).to_ruby
|
18
|
+
rescue
|
19
|
+
puts "ERROR: Cannot connect to github.com"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Retrive the local registry of installed songs
|
24
|
+
def self.get_local_songs
|
25
|
+
begin
|
26
|
+
YAML.load_file('songs.yml')? YAML.load_file('songs.yml') : Array.new
|
27
|
+
rescue
|
28
|
+
begin
|
29
|
+
FileUtils.mkdir 'bowie_songs'
|
30
|
+
rescue
|
31
|
+
end
|
32
|
+
FileUtils.touch 'songs.yml'
|
33
|
+
return Array.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# Retrive the local lyrics file
|
38
|
+
def self.get_local_lyrics
|
39
|
+
begin
|
40
|
+
YAML.load_file('bowie_songs/lyrics.yml')? YAML.load_file('songs.yml') : Hash.new
|
41
|
+
rescue
|
42
|
+
begin
|
43
|
+
FileUtils.mkdir 'bowie_songs'
|
44
|
+
rescue
|
45
|
+
end
|
46
|
+
FileUtils.touch 'bowie_songs/lyrics.yml'
|
47
|
+
return Hash.new
|
48
|
+
end
|
16
49
|
end
|
17
50
|
|
18
51
|
# Return a printable list of available packages matching the [query]
|
19
52
|
def self.search(query)
|
53
|
+
@songs = self.get_songs
|
20
54
|
@songs.select { |el| /.*#{query}.*/ =~ el }
|
21
55
|
end
|
22
56
|
|
23
57
|
# Install the selected [song] in the bowie_songs directory
|
24
58
|
def self.install(song)
|
59
|
+
@songs = self.get_songs
|
60
|
+
@local_songs = self.get_local_songs
|
25
61
|
name = @songs[song]['name']
|
26
62
|
url = @songs[song]['url']
|
27
63
|
path = "bowie_songs/#{name}"
|
28
64
|
|
29
65
|
FileUtils.mkdir_p(path)
|
30
66
|
Git.clone(url, path)
|
67
|
+
|
68
|
+
@local_songs.push song
|
69
|
+
File.open("songs.yml", "w"){|f| YAML.dump(@local_songs, f)}
|
31
70
|
end
|
32
71
|
|
33
72
|
# Remove the selected package
|
34
73
|
def self.uninstall(song)
|
74
|
+
@songs = self.get_songs
|
75
|
+
@local_songs = self.get_local_songs
|
35
76
|
name = @songs[song]['name']
|
36
77
|
path = "bowie_songs/#{name}"
|
37
78
|
|
38
79
|
FileUtils.rm_rf(path) # use remove_entry_secure for security reasons?
|
80
|
+
|
81
|
+
@local_songs.delete song
|
82
|
+
File.open("songs.yml", "w"){|f| YAML.dump(@local_songs, f)}
|
39
83
|
end
|
40
84
|
|
41
85
|
# Update the selected package
|
data/lib/bowie/version.rb
CHANGED