bowie 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bowie +13 -2
  3. data/lib/bowie.rb +14 -6
  4. data/lib/bowie/version.rb +1 -1
  5. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 062999b7376962157823fd767ac330e0c79c29e2
4
- data.tar.gz: 045112b430a375800f46301fc694f7a347792150
3
+ metadata.gz: c9b107c89b5f3647d132d994af73e341afd2d36c
4
+ data.tar.gz: d37b94e0a81352959a8da418a9aa2024eb68cb2a
5
5
  SHA512:
6
- metadata.gz: 494bec77effdc5ccfddf0be9f80ae1c40cb793eb8ba86aca2bbe867c630e954cd8e2193854f2110fdc7daa202bff7b7774b93476c0134b82b43f5f5ce0104448
7
- data.tar.gz: ff1a61dcd3624ba5c5a0fb19824e2da4374b6cce43d98c0fcb300b8181518ec9d55dd84d1240a3885f9b4b25fb7525b1549cad14308b068edce92c8f6cac4b8a
6
+ metadata.gz: f8cdf313ff26138c51eff1c01557c6bacdbc512c5d07a42e4727d6d6f71a3e678b6df5733a1993c7fb0575a62c1680d9d917cb2a9eba1c63fc1a3b7c398270dc
7
+ data.tar.gz: a2721819f16d45819ae7cdb889a4113b1aedb1d8c6564a7f4ded87f390f569fc809d838993ae3853ba0a53c6b1fc321fcaa067916aaef98e9819ecfc3895b681
data/bin/bowie CHANGED
@@ -4,11 +4,22 @@ require 'bowie'
4
4
  require 'thor'
5
5
 
6
6
  class BowieCLI < Thor
7
- desc "command song", "bowie sing that song"
8
-
7
+
8
+ desc "install song", "install the selected package"
9
9
  def install(song)
10
10
  Bowie.install(song)
11
11
  end
12
+
13
+ desc "uninstall song", "remove the selected package"
14
+ def uninstall(song)
15
+ Bowie.uninstall(song)
16
+ end
17
+
18
+ desc "search song", "list all availables packages matching [song]"
19
+ def search(song)
20
+ results = Bowie.search(song)
21
+ results.each { |key, values| puts "#{values['name']}:\n #{values['description']}" }
22
+ end
12
23
  end
13
24
 
14
25
  BowieCLI.start(ARGV)
data/lib/bowie.rb CHANGED
@@ -6,27 +6,35 @@ require "git"
6
6
 
7
7
  module Bowie
8
8
 
9
+ # Parse the remote list of packages
9
10
  @songs = YAML.parse(open("https://raw.github.com/axyz/bowie-songs/master/songs.yml")).to_ruby
10
11
 
12
+ # Returns the list of packages
11
13
  def self.get_songs
12
14
  @songs
13
15
  end
14
16
 
15
- def self.list
16
- @songs.each_key do |song|
17
- puts @songs[song]['name'] + ': ' + @songs[song]['description']
18
- end
17
+ # Return a printable list of available packages matching the [query]
18
+ def self.search(query)
19
+ @songs.select { |el| /.*#{query}.*/ =~ el }
19
20
  end
20
21
 
22
+ # Install the selected [song] in the bowie_songs directory
21
23
  def self.install(song)
22
24
  name = @songs[song]['name']
23
25
  url = @songs[song]['url']
24
26
  path = "bowie_songs/#{name}"
25
27
 
26
- puts "name: #{name}, url: #{url}" #TO-DELETE
27
-
28
28
  FileUtils.mkdir_p(path)
29
29
  Git.clone(url, path)
30
30
  end
31
31
 
32
+ # Remove the selected package
33
+ def self.uninstall(song)
34
+ name = @songs[song]['name']
35
+ path = "bowie_songs/#{name}"
36
+
37
+ FileUtils.rm_rf(path) # use remove_entry_secure for security reasons?
38
+ end
39
+
32
40
  end
data/lib/bowie/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bowie
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  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.0.1
4
+ version: 0.0.2
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-05 00:00:00.000000000 Z
11
+ date: 2013-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler