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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3637f82bf12955b91f1647012a7a7e589e181402
4
- data.tar.gz: 358cd302089acded7dd2c9a4105492639dba0a68
3
+ metadata.gz: 4619ca670d4770bd49a0ca0952ee0fc9f73bd3ad
4
+ data.tar.gz: d9ed7416284ff70208266cac8d00e9e499dc3f6b
5
5
  SHA512:
6
- metadata.gz: 5bf0f02f9dabe7277bb82ac87175999326998fbdeaaef3832b91fa0221711d164addce7cdb9e33fbc0b1c86ea645580350bf483bdab0a2e10f782e0ef817ec0e
7
- data.tar.gz: be9ecd874ca3cbb442965e2d015d293fb6bc52a2955beec1165d694cc151072a72f085aab41fa97442a097852658468c90adb174f27abb096bf0c9d2a7f65d5b
6
+ metadata.gz: 1bd95c602a6f88992cd2e6ae431d54c9f72903476927e78af8251434762e48e53b8cdcdbb157d84fd609f1ecd8fb2f7086a3528f1cf8b3ea64b117f45f74538f
7
+ data.tar.gz: d253c8c3643cadc21023f4cb0dcc8fe7808f77c9ccdac55728985f937676fada699cf85bb6dcd2d9b6451bf5e05bf3d1070ec43ef2386bde4f5760c406472c51
data/bin/bowie CHANGED
@@ -4,6 +4,10 @@ require 'bowie'
4
4
  require 'thor'
5
5
 
6
6
  class BowieCLI < Thor
7
+
8
+ Bowie.get_songs
9
+ Bowie.get_local_songs
10
+ Bowie.get_local_lyrics
7
11
 
8
12
  desc "install song", "install the selected package"
9
13
  def install(song)
data/lib/bowie.rb CHANGED
@@ -7,35 +7,79 @@ require "logger"
7
7
 
8
8
  module Bowie
9
9
 
10
- # Parse the remote list of packages
11
- @songs = YAML.parse(open("https://raw.github.com/axyz/bowie-songs/master/songs.yml")).to_ruby
10
+ @songs
11
+ @local_songs
12
+ @local_lyrics
12
13
 
13
- # Returns the list of packages
14
+ # Retrive the online registry of available songs
14
15
  def self.get_songs
15
- @songs
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
@@ -1,3 +1,3 @@
1
1
  module Bowie
2
- VERSION = "0.0.4"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bowie
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrea Moretti