Skip to content

Commit c23198c

Browse files
committed
Merge branch 'matt/ignore_quote_for_version_parse' into 'master'
Ignore quote for version parse See merge request mx/binks!6
2 parents 7964e7b + a42a0b7 commit c23198c

7 files changed

Lines changed: 36 additions & 8 deletions

File tree

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
binks (0.0.4)
4+
binks (0.0.5)
55
thor (>= 0.20.3)
66

77
GEM

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ binks release -f
6161
See [process wiki page](https://gitlab.mx.com/mx/io/wikis/Gems) for details on updating a gem.
6262

6363
1. Create your feature branch (`git checkout -b my-new-feature`)
64-
2. If changing a `.proto` file
65-
1. `brew install protobuf` _(unless you already have it)_
66-
2. `rake compile`
6764
3. Commit your changes (`git commit -am 'Add some feature'`)
6865
4. Push to the branch (`git push origin my-new-feature`)
6966
5. Create new Pull Request

lib/binks/gradle.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Binks
22
class Gradle
3-
GRADLE_VERSION = %r{version[\s]*\=[\s]*'(?<version>[\.\d]+(|\.pre))'}
3+
GRADLE_VERSION = %r{version[\s]*\=[\s]*['"](?<version>[\.\d]+(|\.pre))['"]}
44

55
attr_reader :filename
66

@@ -12,6 +12,7 @@ def initialize(filename)
1212
def version
1313
@version ||= begin
1414
match = @text.match(GRADLE_VERSION)
15+
raise ::Binks::BinksError, "No valid version detected in #{@filename}" if match.nil?
1516
::Binks::VersionParser.new(match[:version])
1617
end
1718
end

spec/binks/gradle_spec.rb

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
require "spec_helper"
22

33
describe ::Binks::Gradle do
4-
subject { described_class.new("build.gradle") }
4+
let(:build_file) { "spec/resources/build_single_quote.gradle" }
55

6-
it "loads version of with correct value" do
7-
expect("#{subject.version}").to eq("0.0.1")
6+
subject { described_class.new(build_file) }
7+
8+
context "with single-quotes" do
9+
let(:build_file) { "spec/resources/build_single_quote.gradle" }
10+
11+
it "loads version of with correct value" do
12+
expect("#{subject.version}").to eq("0.0.1")
13+
end
14+
end
15+
16+
context "with double-quotes" do
17+
let(:build_file) { "spec/resources/build_double_quote.gradle" }
18+
19+
it "loads version of with correct value" do
20+
expect("#{subject.version}").to eq("0.0.2")
21+
end
22+
end
23+
24+
context "with invalid version" do
25+
let(:build_file) { "spec/resources/build_invalid.gradle" }
26+
27+
it "loads version of with correct value" do
28+
expect { subject.version }.to raise_error ::Binks::BinksError, "No valid version detected in spec/resources/build_invalid.gradle"
29+
end
830
end
931

1032
it "loads version of type VersionParser" do
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apply plugin: 'java'
2+
apply plugin: 'eclipse'
3+
4+
version = "0.0.2"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apply plugin: 'java'
2+
apply plugin: 'eclipse'
3+
4+
version = '0.0.1-some_invalid_junk'

0 commit comments

Comments
 (0)