anvil-core 0.0.1.pre.alpha.2 → 0.0.1.pre.alpha.3

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: 84737f5a429924a351d2d4b20c0206c5bd015b20
4
- data.tar.gz: 858cd983bf2629fafa1b781d6748985e326d95b5
3
+ metadata.gz: d11c632bfef80657b2626182273510e405208c03
4
+ data.tar.gz: 191dab915a4d5e375f421145dd4e84c2dc9ad35f
5
5
  SHA512:
6
- metadata.gz: 870d9fae3fcb4a4c48aa716a8aeb36770e62b95931208b60e26ccffe34c71d09a4023c87267fa8fd0454a51147bcc35088f913d41b8670101d16523bf9d50718
7
- data.tar.gz: 26769111bd818fd5833258819baf744a074d3d9fe2e4b87aad2170ce383214ea4ec5594e695ca516819c26211edfe02bd83fe43909d1bc9f466c8e7cf21f6f98
6
+ metadata.gz: 786e8d0568a15e2490d5a57335dac9e12183f6425441df80383c455e5c0158183cb13d34bcf3c6af13398e53499bd3d0cd57b1df9568733df40957a547c7c73b
7
+ data.tar.gz: a026c61d5e629bd7aecf88ec5cd28b3462420956a7278ca924c323676c091813678e67bb75b0bea19fd0857b0e137a743ffa2f7a9f75451232d2bd4418a54c56
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1-alpha.2
1
+ 0.0.1-alpha.3
data/lib/anvil.rb CHANGED
@@ -4,6 +4,8 @@ require 'active_support/core_ext'
4
4
  module Anvil
5
5
  Error = Class.new(StandardError)
6
6
 
7
+ class RepoNotClean < Error; end
8
+
7
9
  class << self
8
10
  def logger
9
11
  @logger ||= Logger.new(STDOUT).tap do |l|
@@ -15,6 +15,7 @@ class Gem::BumpTask < Anvil::Task
15
15
  end
16
16
 
17
17
  def task
18
+ prepare_repo
18
19
  version = bump(read_version)
19
20
  write_version version
20
21
 
@@ -48,6 +49,7 @@ class Gem::BumpTask < Anvil::Task
48
49
  git.add 'VERSION'
49
50
  git.commit "Bump version v#{version}"
50
51
  git.add_tag "v#{version}"
52
+ git.push
51
53
  end
52
54
 
53
55
  def write_version(version)
@@ -58,4 +60,16 @@ class Gem::BumpTask < Anvil::Task
58
60
 
59
61
  commit_and_tag version
60
62
  end
63
+
64
+ def prepare_repo
65
+ fail Anvil::RepoNotClean unless clean?
66
+
67
+ git.pull
68
+ end
69
+
70
+ def clean?
71
+ git.status.changed.empty? &&
72
+ git.status.deleted.empty? &&
73
+ git.status.added.empty?
74
+ end
61
75
  end
@@ -1,15 +1,53 @@
1
1
  require 'spec_helper'
2
2
  require 'tasks/gem/bump_task'
3
+ require 'git'
4
+ require 'anvil'
3
5
 
4
6
  describe Gem::BumpTask do
7
+ subject { Gem::BumpTask.new :major }
8
+
5
9
  describe '#task' do
6
- subject { Gem::BumpTask.new :major }
7
10
  before { subject.stub(:read_version).and_return('2.0.0') }
8
11
 
9
12
  it 'bumps the version and writes it' do
10
- expect(subject).to receive(:write_version)
13
+ expect(subject).to receive(:prepare_repo).and_return(true)
14
+ expect(subject).to receive(:write_version).and_return(true)
11
15
 
12
16
  expect(subject.task).to eq('3.0.0')
13
17
  end
14
18
  end
19
+
20
+ describe '#write_version' do
21
+ it 'writes the file and push the changes' do
22
+ expect(subject).to receive(:version_file).with('w+')
23
+ expect(subject).to receive(:commit_and_tag)
24
+ end
25
+
26
+ after { subject.send :write_version, '2.0.0' }
27
+ end
28
+
29
+ describe '#prepare_repo' do
30
+ context 'on a clean repo' do
31
+ before do
32
+ subject.stub(:clean?).and_return(true)
33
+ subject.stub(:git).and_return(double)
34
+ end
35
+
36
+ it 'pulls' do
37
+ expect(subject.send(:git)).to receive(:pull)
38
+ end
39
+
40
+ after { subject.send :prepare_repo }
41
+ end
42
+
43
+ context 'on a dirty repo' do
44
+ before { subject.stub(:clean?).and_return(false) }
45
+
46
+ it 'raises RepoNotClean' do
47
+ expect do
48
+ subject.send :prepare_repo
49
+ end.to raise_error(Anvil::RepoNotClean)
50
+ end
51
+ end
52
+ end
15
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anvil-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.alpha.2
4
+ version: 0.0.1.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fran Casas