bowie 0.3.9 → 0.3.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1d11347f6f13ef0b6277970b9a3ddd1be58ee5b
4
- data.tar.gz: 2ddb2a6e22adc24846c9f872844784e863835fdd
3
+ metadata.gz: 42aab442a0a17cea8dd78c49d288f59dd5906aff
4
+ data.tar.gz: e6ef02f2594e95dfd81b2e92f7f2e2ed1c7becf4
5
5
  SHA512:
6
- metadata.gz: ec78b408d237502e9d225e647edc83cb2902cfcce9dc63d5642dc28d81ac0a507cf525b5a409856cb06d24f7b2bdbd4c65355183a5f7c01382ac8e610b1be840
7
- data.tar.gz: 46f11400095274a130c39fcd4cee63aadeb4d1640a80796b8238b920892bd7afcea62b064bf2bacad47abdfe13ec6f413af4b2e7b865430486ef4ce3ce20aee6
6
+ metadata.gz: 0f487c1da790206168320b44d040d15ebda1a43f568355fdb1f816f05989077ede2ce394662cebbdb4166a591c8a34f9f6af2f1f6b7c630c3a0d2c0ca5cb1197
7
+ data.tar.gz: ee60ffb690f85fd246027754ce8cb1dfb01078533c7ff93a7e4a75927983a310968297881d7338ec66cf632c523698a53e22d238dde7f86e8fcf51addb337e46
@@ -7,7 +7,11 @@ module Bowie
7
7
  if songs.length > 0
8
8
  songs.each do |song|
9
9
  name = SongUtils.parse_song_name song
10
- version = Semver.new(SongUtils.parse_song_version song)
10
+ begin
11
+ version = Semver.new(SongUtils.parse_song_version song)
12
+ rescue
13
+ version = false
14
+ end
11
15
  url = @songs[name]['url']
12
16
  path = "bowie_songs/#{name}"
13
17
 
@@ -16,7 +20,7 @@ module Bowie
16
20
  else
17
21
  FileUtils.mkdir_p(path)
18
22
  Git.clone(url, path)
19
- if version.major != nil
23
+ if version
20
24
  g = Git.open(path)
21
25
  begin
22
26
  g.checkout(version.to_s)
@@ -30,7 +34,7 @@ module Bowie
30
34
  end
31
35
 
32
36
  unless @local_songs.include? name or @local_songs.include? name+'#'+version.to_s
33
- version.major ? @local_songs.push(name+'#'+version.to_s) : @local_songs.push(name)
37
+ version ? @local_songs.push(name+'#'+version.to_s) : @local_songs.push(name)
34
38
  end
35
39
  File.open("songs.yml", "w"){|f| YAML.dump(@local_songs, f)}
36
40
  end
@@ -7,12 +7,16 @@ module Bowie
7
7
 
8
8
  songs.each do |song|
9
9
  name = SongUtils.parse_song_name song
10
- version = Semver.new(SongUtils.parse_song_version song)
10
+ begin
11
+ version = Semver.new(SongUtils.parse_song_version song)
12
+ rescue
13
+ version = false
14
+ end
11
15
  path = "bowie_songs/#{name}"
12
16
 
13
17
  FileUtils.rm_rf(path) # use remove_entry_secure for security reasons?
14
18
 
15
- if version.major != nil
19
+ if version
16
20
  @local_songs.delete "#{name}##{version}"
17
21
  else
18
22
  @local_songs.delete_if {|el| not (el =~ /^#{name}#/).nil?}
@@ -8,13 +8,17 @@ module Bowie
8
8
  if songs.length > 0
9
9
  songs.each do |song|
10
10
  name = SongUtils.parse_song_name song
11
- version = Semver.new(SongUtils.parse_song_version song)
11
+ begin
12
+ version = Semver.new(SongUtils.parse_song_version song)
13
+ rescue
14
+ version = false
15
+ end
12
16
  path = "bowie_songs/#{name}"
13
17
 
14
18
  g = Git.open(path, :log => Logger.new(STDOUT))
15
19
  g.reset_hard('HEAD')
16
20
  g.pull
17
- unless version.major.nil?
21
+ unless version
18
22
  begin
19
23
  g.checkout(version.to_s)
20
24
  rescue
@@ -26,7 +30,7 @@ module Bowie
26
30
  end
27
31
  @local_songs.delete name
28
32
  @local_songs.delete_if {|el| not (el =~ /^#{name}#/).nil?}
29
- version.major ? @local_songs.push(name+'#'+version.to_s) : @local_songs.push(name)
33
+ version ? @local_songs.push(name+'#'+version.to_s) : @local_songs.push(name)
30
34
  File.open("songs.yml", "w"){|f| YAML.dump(@local_songs, f)}
31
35
  end
32
36
  else
@@ -76,7 +76,7 @@ module Bowie
76
76
  end
77
77
 
78
78
  def self.valid_song?(string)
79
- (string =~ /^[a-z0-9]+(-?[a-z0-9])*(#\d+.\d+.\d+)?$/) == nil ? false : true
79
+ (string =~ /\A[a-z0-9]+(-?[a-z0-9])*(#\d+.\d+.\d+)?\z/) == nil ? false : true
80
80
  end
81
81
 
82
82
  def self.valid_lyrics_file?(file)
@@ -1,3 +1,3 @@
1
1
  module Bowie
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.10"
3
3
  end
@@ -16,10 +16,10 @@ class Semver
16
16
  @minor = Integer v[1]
17
17
  @patch = Integer v[2]
18
18
  else
19
- false
19
+ raise "invalid semver"
20
20
  end
21
21
  else
22
- false
22
+ raise ArgumentError
23
23
  end
24
24
  end
25
25
 
@@ -87,6 +87,6 @@ private
87
87
 
88
88
  # return true if [string] is a valid semantic version in the form x.x.x or vx.x.x
89
89
  def valid?(string)
90
- (/^v?\d+.\d+.\d+$/ =~ string)? true : false
90
+ (/\Av?\d+.\d+.\d+\z/ =~ string)? true : false
91
91
  end
92
92
  end
@@ -0,0 +1,44 @@
1
+ require 'rspec'
2
+ require './lib/semver/semver'
3
+
4
+ describe Semver do
5
+
6
+ context "when valid #semver in x.x.x form" do
7
+ it "initialize without errors" do
8
+ expect {Semver.new "1.2.3"}.to_not raise_error
9
+ end
10
+
11
+ subject(:version) {Semver.new "1.2.3"}
12
+ it "initialize correctly major, minor and patch parameters" do
13
+ expect(version.major).to be 1
14
+ expect(version.minor).to be 2
15
+ expect(version.patch).to be 3
16
+ end
17
+ end
18
+
19
+ context "when valid #semver in vx.x.x form" do
20
+ it "initialize without errors" do
21
+ expect {Semver.new "v1.2.3"}.to_not raise_error
22
+ end
23
+
24
+ subject(:version) {Semver.new "v1.2.3"}
25
+ it "initialize correctly major, minor and patch parameters" do
26
+ expect(version.major).to be 1
27
+ expect(version.minor).to be 2
28
+ expect(version.patch).to be 3
29
+ end
30
+ end
31
+
32
+ context "when initialized with invalid semver string" do
33
+ it "raise invalid semver error" do
34
+ expect {Semver.new "v1.2.3.4"}.to raise_error "invalid semver"
35
+ end
36
+ end
37
+
38
+ context "when initialized with too mani arguments" do
39
+ it "raise ArgumentError" do
40
+ expect {Semver.new "v1.2.3", "foo"}.to raise_error ArgumentError
41
+ end
42
+ end
43
+
44
+ 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.9
4
+ version: 0.3.10
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-18 00:00:00.000000000 Z
11
+ date: 2013-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -116,6 +116,7 @@ files:
116
116
  - spec/bowie/actions/update_spec.rb
117
117
  - spec/bowie/song_utils_spec.rb
118
118
  - spec/bowie_spec.rb
119
+ - spec/semver/semver_spec.rb
119
120
  - spec/spec_helper.rb
120
121
  homepage: http://axyz.github.io/bowie/
121
122
  licenses:
@@ -150,4 +151,5 @@ test_files:
150
151
  - spec/bowie/actions/update_spec.rb
151
152
  - spec/bowie/song_utils_spec.rb
152
153
  - spec/bowie_spec.rb
154
+ - spec/semver/semver_spec.rb
153
155
  - spec/spec_helper.rb