bowie 0.3.10 → 0.3.11

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: 42aab442a0a17cea8dd78c49d288f59dd5906aff
4
- data.tar.gz: e6ef02f2594e95dfd81b2e92f7f2e2ed1c7becf4
3
+ metadata.gz: 75ab56cdb9510cd448eafbd96c1fdde3a73ae160
4
+ data.tar.gz: 3cebaac0a1f7b284ef92532956e39eae8111b51b
5
5
  SHA512:
6
- metadata.gz: 0f487c1da790206168320b44d040d15ebda1a43f568355fdb1f816f05989077ede2ce394662cebbdb4166a591c8a34f9f6af2f1f6b7c630c3a0d2c0ca5cb1197
7
- data.tar.gz: ee60ffb690f85fd246027754ce8cb1dfb01078533c7ff93a7e4a75927983a310968297881d7338ec66cf632c523698a53e22d238dde7f86e8fcf51addb337e46
6
+ metadata.gz: 5f804cf36522ffaaec3c0db1ebcda964243c8d736e50e245074569e5756ddccdfaf3bdd9252e10be8e657a34a7040e35990861614fafd0b7ea55a0d4299573ab
7
+ data.tar.gz: 7b3af97e43d4d424691df13555c72298365e970f60b9b9f30f2b57ff6fcb61e135b3c2c203879b2c24e4a353226b0966232edf922e4c89b5889f77bfe7d29d26
@@ -1,4 +1,5 @@
1
1
  require 'bowie/song_utils'
2
+ require 'bowie/actions/get'
2
3
  require 'bowie/actions/install'
3
4
  require 'bowie/actions/list'
4
5
  require 'bowie/actions/prune'
@@ -0,0 +1,17 @@
1
+ module Bowie
2
+ module Actions
3
+ # List all the installed packages
4
+ def self.get(song, key)
5
+ unless SongUtils.installed_song? song
6
+ raise "song not installed"
7
+ end
8
+ begin
9
+ @lyrics = YAML.load_file("bowie_songs/#{song}/bowie.yml")
10
+ rescue
11
+ raise "bowie.yml not found"
12
+ end
13
+
14
+ return @lyrics[key]
15
+ end
16
+ end
17
+ end
@@ -79,6 +79,20 @@ module Bowie
79
79
  (string =~ /\A[a-z0-9]+(-?[a-z0-9])*(#\d+.\d+.\d+)?\z/) == nil ? false : true
80
80
  end
81
81
 
82
+ def self.installed_song? (song)
83
+ @songs = self.get_local_songs
84
+ @dirs = self.get_songs_dirs
85
+
86
+ unless (@songs.grep /#{song}/).empty?
87
+ if (@dirs.grep /#{song}/).empty?
88
+ return false
89
+ else
90
+ return true
91
+ end
92
+ end
93
+ return false
94
+ end
95
+
82
96
  def self.valid_lyrics_file?(file)
83
97
  begin
84
98
  f = YAML.load_file file
@@ -101,5 +115,6 @@ module Bowie
101
115
  def self.create_empty_lyrics_file
102
116
  File.open("./bowie_songs/lyrics.yml", "w"){|f| YAML.dump(Hash.new, f)}
103
117
  end
118
+
104
119
  end
105
120
  end
@@ -1,3 +1,3 @@
1
1
  module Bowie
2
- VERSION = "0.3.10"
2
+ VERSION = "0.3.11"
3
3
  end
@@ -0,0 +1,20 @@
1
+ describe "Bowie::Actions" do
2
+ context "when the song is installed" do
3
+ before(:each) do
4
+ Bowie::Actions.install 'bowie-test'
5
+ end
6
+ after(:each) do
7
+ Bowie::Actions.uninstall 'bowie-test'
8
+ end
9
+
10
+ it ".get" do
11
+ expect {Bowie::Actions.get('bowie-test', 'foo')}.to_not raise_error
12
+ end
13
+ end
14
+
15
+ context "when the song is not installed" do
16
+ it ".get" do
17
+ expect {Bowie::Actions.get('bowie-test', 'foo')}.to raise_error "song not installed"
18
+ end
19
+ end
20
+ end
@@ -78,4 +78,40 @@ describe "Bowie::SongUtils" do
78
78
  end
79
79
  end
80
80
 
81
+ context "when a song is correctly installed" do
82
+ before(:each) do
83
+ Bowie::Actions.install 'bowie-test'
84
+ end
85
+ after(:each) do
86
+ Bowie::Actions.uninstall 'bowie-test'
87
+ end
88
+
89
+ it ".installed_song?" do
90
+ expect {Bowie::SongUtils.installed_song? 'bowie-test'}.to_not raise_error
91
+ expect(Bowie::SongUtils.installed_song? 'bowie-test').to be true
92
+ end
93
+ end
94
+
95
+ context "when a song is not installed" do
96
+ it ".installed_song?" do
97
+ expect {Bowie::SongUtils.installed_song? 'bowie-test'}.to_not raise_error
98
+ expect(Bowie::SongUtils.installed_song? 'bowie-test').to be false
99
+ end
100
+ end
101
+
102
+ context "when a song is not correctly installed" do
103
+ before(:each) do
104
+ Bowie::Actions.install 'bowie-test'
105
+ FileUtils.rm_rf('./songs.yml')
106
+ end
107
+ after(:each) do
108
+ Bowie::Actions.uninstall 'bowie-test'
109
+ end
110
+
111
+ it ".installed_song?" do
112
+ expect {Bowie::SongUtils.installed_song? 'bowie-test'}.to_not raise_error
113
+ expect(Bowie::SongUtils.installed_song? 'bowie-test').to be false
114
+ end
115
+ end
116
+
81
117
  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.10
4
+ version: 0.3.11
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-19 00:00:00.000000000 Z
11
+ date: 2013-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,6 +97,7 @@ files:
97
97
  - bowie.gemspec
98
98
  - lib/bowie.rb
99
99
  - lib/bowie/actions.rb
100
+ - lib/bowie/actions/get.rb
100
101
  - lib/bowie/actions/install.rb
101
102
  - lib/bowie/actions/list.rb
102
103
  - lib/bowie/actions/prune.rb
@@ -108,6 +109,7 @@ files:
108
109
  - lib/bowie/utils.rb
109
110
  - lib/bowie/version.rb
110
111
  - lib/semver/semver.rb
112
+ - spec/bowie/actions/get_spec.rb
111
113
  - spec/bowie/actions/install_spec.rb
112
114
  - spec/bowie/actions/list_spec.rb
113
115
  - spec/bowie/actions/prune_spec.rb
@@ -143,6 +145,7 @@ signing_key:
143
145
  specification_version: 4
144
146
  summary: The White Duke rules them all
145
147
  test_files:
148
+ - spec/bowie/actions/get_spec.rb
146
149
  - spec/bowie/actions/install_spec.rb
147
150
  - spec/bowie/actions/list_spec.rb
148
151
  - spec/bowie/actions/prune_spec.rb