anvil-core 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/VERSION +1 -1
- data/lib/anvil/cli.rb +30 -19
- data/lib/anvil/extensions_manager.rb +1 -1
- data/lib/anvil/options_detector.rb +20 -0
- data/lib/anvil/parser.rb +5 -0
- data/lib/anvil/task.rb +5 -6
- data/lib/anvil/task/options.rb +2 -0
- data/lib/anvil/task/repositories.rb +1 -1
- data/lib/anvil/versioner.rb +1 -0
- data/lib/tasks/gem/build_task.rb +1 -1
- data/lib/tasks/gem/bump_task.rb +1 -1
- data/lib/tasks/gem/release_task.rb +1 -1
- data/lib/tasks/help_task.rb +2 -2
- data/lib/tasks/projects/add_task.rb +2 -5
- data/lib/tasks/projects/list_task.rb +1 -1
- data/spec/lib/anvil/cli_spec.rb +5 -5
- data/spec/lib/anvil/config_spec.rb +8 -13
- data/spec/lib/anvil/extensions_manager_spec.rb +2 -2
- data/spec/lib/anvil/parser_spec.rb +1 -1
- data/spec/lib/anvil/task/naming_spec.rb +2 -2
- data/spec/lib/anvil/task/projects_spec.rb +1 -1
- data/spec/lib/anvil/task_spec.rb +19 -14
- data/spec/lib/anvil/versioner_spec.rb +5 -5
- data/spec/lib/tasks/gem/build_task_spec.rb +3 -3
- data/spec/lib/tasks/gem/bump_task_spec.rb +7 -5
- data/spec/lib/tasks/gem/release_task_spec.rb +3 -3
- data/spec/lib/tasks/projects/add_task_spec.rb +2 -1
- data/spec/spec_helper.rb +13 -6
- data/spec/support/{fixtures → dummy_tasks}/dummy_after_task.rb +0 -0
- data/spec/support/{fixtures → dummy_tasks}/dummy_assure.rb +0 -0
- data/spec/support/{fixtures → dummy_tasks}/dummy_before_task.rb +0 -0
- data/spec/support/{fixtures → dummy_tasks}/dummy_failed_assure.rb +0 -0
- data/spec/support/{fixtures → dummy_tasks}/dummy_task.rb +0 -0
- data/spec/support/{fixtures → dummy_tasks}/foo/dummy_task.rb +0 -0
- data/spec/support/{dot_anvil → fixtures}/config.rb +1 -1
- data/spec/support/shared/config_mock.rb +17 -0
- metadata +38 -39
- data/spec/support/shared/config_context.rb +0 -12
- data/spec/support/shared/fake_fs_context.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5d7e961a633411eb45ceb405a568842370a3eed
|
4
|
+
data.tar.gz: 00a6cebfdbe8811e733670b064af7ccff0fc3642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d40908e160de0e79fa3215722ba546117846db2afec7df5e02eebb669a7f85e17cae623b87fc5381877f0bdd82ab63e059cf51bdb22eb047d061b2dc7e5aae05
|
7
|
+
data.tar.gz: 00b6901c779416e932aea2e02b91fe5d622d6c700a60033a6ab4bbb65909a8b8039999f11acea029b8934155905b2ad753e72cb04a1820e09ffcee726cecfcd2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Anvil
|
2
2
|
|
3
|
-
Anvil is a tool for the real
|
3
|
+
Anvil is a tool for the real craftspeople to build their own tools.
|
4
4
|
|
5
5
|
[![Build Status](https://travis-ci.org/anvil-src/anvil-core.png?branch=master)](https://travis-ci.org/anvil-src/anvil-core)
|
6
6
|
[![Gem Version](https://badge.fury.io/rb/anvil-core.svg)](http://badge.fury.io/rb/anvil-core)
|
@@ -11,8 +11,8 @@ Anvil tries to be a framework for building command line applications
|
|
11
11
|
to automate tedious tasks like apps or gems releasing process. Pull
|
12
12
|
request updating, etc.
|
13
13
|
|
14
|
-
It's purpose is to provide an easy to use Object Oriented toolset
|
15
|
-
|
14
|
+
It's purpose is to provide an easy to use Object Oriented toolset that
|
15
|
+
developers can use to automate par of its day to day work.
|
16
16
|
|
17
17
|
Things like:
|
18
18
|
|
@@ -23,7 +23,8 @@ Things like:
|
|
23
23
|
|
24
24
|
## Sample tasks
|
25
25
|
|
26
|
-
You can find some sample tasks in the samples directory, if you want
|
26
|
+
You can find some sample tasks in the samples directory, if you want
|
27
|
+
to give them a try, clone this project and do:
|
27
28
|
|
28
29
|
```shell
|
29
30
|
ANVIL_EXTENSIONS_DIR=./sample bin/anvil
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
data/lib/anvil/cli.rb
CHANGED
@@ -6,11 +6,11 @@ require 'tasks/help_task'
|
|
6
6
|
module Anvil
|
7
7
|
# Anvil command line interface
|
8
8
|
class Cli
|
9
|
-
|
9
|
+
HELP_HEADER = <<-HELP_HEADER
|
10
10
|
Anvil is a tool for making your life easier.
|
11
11
|
|
12
12
|
Available tasks:
|
13
|
-
|
13
|
+
HELP_HEADER
|
14
14
|
|
15
15
|
# Runs a task or prints its help if it needs arguments
|
16
16
|
#
|
@@ -19,11 +19,10 @@ HELP
|
|
19
19
|
def run(argv)
|
20
20
|
load_tasks
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
22
|
+
return build_task(argv).run unless argv.empty?
|
23
|
+
|
24
|
+
print_help_header
|
25
|
+
print_help_body
|
27
26
|
end
|
28
27
|
|
29
28
|
def load_tasks
|
@@ -41,30 +40,42 @@ HELP
|
|
41
40
|
klazz.new(*klazz.parse_options!(arguments))
|
42
41
|
rescue NameError
|
43
42
|
task_not_found(task_name)
|
44
|
-
exit
|
43
|
+
exit false
|
45
44
|
rescue ArgumentError
|
46
|
-
|
47
|
-
exit
|
45
|
+
bad_arguments(task_name)
|
46
|
+
exit false
|
48
47
|
end
|
49
48
|
|
50
|
-
def task_not_found(task_name)
|
51
|
-
|
52
|
-
|
49
|
+
def task_not_found(task_name = nil)
|
50
|
+
Anvil.logger.info "Task '#{task_name}' not found"
|
51
|
+
Anvil.logger.info('Maybe you mean one of the following') if task_name
|
52
|
+
Anvil.logger.info("\n")
|
53
|
+
print_help_body task_name
|
53
54
|
end
|
54
55
|
|
55
|
-
def
|
56
|
-
|
56
|
+
def bad_arguments(task_name)
|
57
|
+
Anvil.logger.info("Wrong number of arguments.\n")
|
57
58
|
HelpTask.run(task_name)
|
58
59
|
end
|
59
60
|
|
60
|
-
def
|
61
|
-
|
61
|
+
def print_help_body(task_name = nil)
|
62
|
+
task_list(task_name).each { |task| print_task_line(task) }
|
63
|
+
end
|
64
|
+
|
65
|
+
def task_list(task_name)
|
62
66
|
tasks = Anvil::ExtensionsManager.tasks_by_name
|
63
|
-
|
67
|
+
|
68
|
+
return tasks unless task_name
|
69
|
+
tasks.select { |task| task.to_s.underscore =~ /#{task_name}/ }
|
64
70
|
end
|
65
71
|
|
66
72
|
def print_task_line(task)
|
67
|
-
|
73
|
+
message = format '%-20s %s', task.task_name, task.description
|
74
|
+
Anvil.logger.info message
|
75
|
+
end
|
76
|
+
|
77
|
+
def print_help_header
|
78
|
+
Anvil.logger.info HELP_HEADER
|
68
79
|
end
|
69
80
|
end
|
70
81
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Anvil
|
2
|
+
# Detect whether the options parser has parsed any option or not in
|
3
|
+
# order, for example, to write the required help for them.
|
4
|
+
class OptionsDetector
|
5
|
+
attr_accessor :has_options
|
6
|
+
|
7
|
+
def on(*_, &_block)
|
8
|
+
self.has_options = true
|
9
|
+
end
|
10
|
+
|
11
|
+
def arguments(*_, &_block)
|
12
|
+
end
|
13
|
+
|
14
|
+
def detect_options(&block)
|
15
|
+
instance_eval(&block)
|
16
|
+
|
17
|
+
has_options
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/anvil/parser.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
|
3
3
|
require 'anvil/task'
|
4
|
+
require 'anvil/options_detector'
|
4
5
|
|
5
6
|
module Anvil
|
6
7
|
# Parser for anvil command line arguments and options
|
@@ -39,5 +40,9 @@ module Anvil
|
|
39
40
|
task_klass = Anvil::Task.from_name(name)
|
40
41
|
instance_eval(&task_klass.parser_block) if task_klass.parser_block
|
41
42
|
end
|
43
|
+
|
44
|
+
def detect_options(&block)
|
45
|
+
OptionsDetector.new.detect_options(&block)
|
46
|
+
end
|
42
47
|
end
|
43
48
|
end
|
data/lib/anvil/task.rb
CHANGED
@@ -22,13 +22,12 @@ module Anvil
|
|
22
22
|
#
|
23
23
|
# @return [Object, nil] anything the task might return
|
24
24
|
def run
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
return unless run_assures
|
26
|
+
run_before_callbacks
|
27
|
+
task_return_value = run_task
|
28
|
+
run_after_callbacks
|
29
29
|
|
30
|
-
|
31
|
-
end
|
30
|
+
task_return_value
|
32
31
|
end
|
33
32
|
|
34
33
|
def logger
|
data/lib/anvil/task/options.rb
CHANGED
data/lib/anvil/versioner.rb
CHANGED
data/lib/tasks/gem/build_task.rb
CHANGED
data/lib/tasks/gem/bump_task.rb
CHANGED
data/lib/tasks/help_task.rb
CHANGED
@@ -16,10 +16,10 @@ class HelpTask < Anvil::Task
|
|
16
16
|
def task
|
17
17
|
return default_message unless task_name.present?
|
18
18
|
klazz = Anvil::Task.from_name(task_name)
|
19
|
-
|
19
|
+
Anvil.logger.info(klazz.help)
|
20
20
|
end
|
21
21
|
|
22
22
|
def default_message
|
23
|
-
|
23
|
+
Anvil.logger.info(self.class.help)
|
24
24
|
end
|
25
25
|
end
|
@@ -7,14 +7,11 @@ module Projects
|
|
7
7
|
class AddTask < Anvil::Task
|
8
8
|
include Anvil::Task::Repositories
|
9
9
|
description 'Adds a new project for anvil.'
|
10
|
-
|
11
|
-
parser do
|
12
|
-
arguments %w[name repository]
|
13
|
-
end
|
10
|
+
parser { arguments %w(name repository) }
|
14
11
|
|
15
12
|
attr_reader :name, :repo
|
16
13
|
|
17
|
-
def initialize(name, repo,
|
14
|
+
def initialize(name, repo, _options = {})
|
18
15
|
@name = name
|
19
16
|
@repo = repo
|
20
17
|
end
|
data/spec/lib/anvil/cli_spec.rb
CHANGED
@@ -8,9 +8,9 @@ describe Anvil::Cli do
|
|
8
8
|
|
9
9
|
context 'with a task name' do
|
10
10
|
before do
|
11
|
-
dummy_task.
|
11
|
+
expect(dummy_task).to receive(:new)
|
12
12
|
.with('arg1', 'arg2', argument: 'value').and_call_original
|
13
|
-
subject.
|
13
|
+
expect(subject).to_not receive(:print_help)
|
14
14
|
end
|
15
15
|
|
16
16
|
it('runs the task in the first parameter') { subject.run argv }
|
@@ -18,7 +18,7 @@ describe Anvil::Cli do
|
|
18
18
|
|
19
19
|
describe '#build_task' do
|
20
20
|
it 'builds the task and parses the arguments' do
|
21
|
-
subject.build_task(argv).options.
|
21
|
+
expect(subject.build_task(argv).options).to eq({ argument: 'value' })
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'if the task is not found' do
|
@@ -37,7 +37,7 @@ describe Anvil::Cli do
|
|
37
37
|
let(:argv) { %w[foo:dummy arg1 arg2 arg3 arg4 arg5 arg6 arg7] }
|
38
38
|
|
39
39
|
it 'prints task list and exits' do
|
40
|
-
expect(subject).to receive(:
|
40
|
+
expect(subject).to receive(:bad_arguments).with('foo:dummy')
|
41
41
|
expect do
|
42
42
|
subject.build_task(argv)
|
43
43
|
end.to raise_error(SystemExit)
|
@@ -47,7 +47,7 @@ describe Anvil::Cli do
|
|
47
47
|
|
48
48
|
context 'without a task name' do
|
49
49
|
let(:argv) { [] }
|
50
|
-
before { subject.
|
50
|
+
before { expect(subject).to receive(:print_help_body) }
|
51
51
|
it('prints the help') { subject.run argv }
|
52
52
|
end
|
53
53
|
end
|
@@ -1,24 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Anvil::Config
|
3
|
+
describe Anvil::Config do
|
4
4
|
subject { Anvil::Config }
|
5
|
-
before { Anvil::Config.
|
5
|
+
before { Anvil::Config.init }
|
6
6
|
|
7
|
-
its('github.user') {
|
8
|
-
its('github.token') {
|
9
|
-
|
10
|
-
context 'with a config file', config: true do
|
11
|
-
its('github.user') { should eq('dummy_user') }
|
12
|
-
its('github.token') { should eq('dummy_token') }
|
13
|
-
end
|
7
|
+
its('github.user') { is_expected.to eq('dummy_user') }
|
8
|
+
its('github.token') { is_expected.to eq('dummy_token') }
|
14
9
|
|
15
10
|
context '.init_base_path' do
|
16
11
|
before { Anvil::Config.send :init_base_path }
|
17
12
|
subject { File }
|
18
13
|
|
19
|
-
it {
|
20
|
-
it {
|
21
|
-
it {
|
22
|
-
it {
|
14
|
+
it { is_expected.to be_directory(Anvil::Config.base_path) }
|
15
|
+
it { is_expected.to be_directory(Anvil::Config.base_tasks_path) }
|
16
|
+
it { is_expected.to be_exists(Anvil::Config.base_config_path) }
|
17
|
+
it { is_expected.to be_exists(Anvil::Config.base_projects_path) }
|
23
18
|
end
|
24
19
|
end
|
@@ -25,7 +25,7 @@ describe Anvil::ExtensionsManager do
|
|
25
25
|
let(:pwd) { '/home/user/src/project/' }
|
26
26
|
context 'on a path managed by git' do
|
27
27
|
before do
|
28
|
-
Rugged::Repository.
|
28
|
+
allow(Rugged::Repository).to receive(:discover)
|
29
29
|
.and_return(double(path: "#{pwd}.git/"))
|
30
30
|
end
|
31
31
|
|
@@ -37,7 +37,7 @@ describe Anvil::ExtensionsManager do
|
|
37
37
|
|
38
38
|
context 'on a path not managed by git' do
|
39
39
|
before do
|
40
|
-
Rugged::Repository.
|
40
|
+
allow(Rugged::Repository).to receive(:discover)
|
41
41
|
.and_raise(Rugged::RepositoryError)
|
42
42
|
end
|
43
43
|
|
@@ -13,13 +13,13 @@ describe Anvil::Task::Naming do
|
|
13
13
|
describe '.from_name' do
|
14
14
|
context 'without a namespace' do
|
15
15
|
it 'finds the task class' do
|
16
|
-
klass.from_name('dummy').
|
16
|
+
expect(klass.from_name('dummy')).to eq(DummyTask)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
context 'with a namespace' do
|
21
21
|
it 'finds the namespaced tasks class' do
|
22
|
-
klass.from_name('foo:dummy').
|
22
|
+
expect(klass.from_name('foo:dummy')).to eq(Foo::DummyTask)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -33,7 +33,7 @@ describe Anvil::Task::Projects, fakefs: true do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
describe '#on_project' do
|
36
|
-
before { subject.
|
36
|
+
before { allow(subject).to receive(:git).and_return(double('git')) }
|
37
37
|
|
38
38
|
it 'keeps the project changed inside the block' do
|
39
39
|
subject.on_project project do
|
data/spec/lib/anvil/task_spec.rb
CHANGED
@@ -12,8 +12,8 @@ describe Anvil::Task do
|
|
12
12
|
|
13
13
|
subject(:afters) { dummy_task.afters }
|
14
14
|
it 'adds DummyBeforeTask to the after callbacks' do
|
15
|
-
afters.first.
|
16
|
-
afters.first.task.
|
15
|
+
expect(afters.first).to be_an_instance_of(Anvil::Task::Callback)
|
16
|
+
expect(afters.first.task).to be(DummyAfterTask)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -21,7 +21,7 @@ describe Anvil::Task do
|
|
21
21
|
before { dummy_task.class_eval { assure :dummy } }
|
22
22
|
|
23
23
|
it 'adds DummyAssure to the assures' do
|
24
|
-
dummy_task.assures.
|
24
|
+
expect(dummy_task.assures).to include(assure)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -32,8 +32,8 @@ describe Anvil::Task do
|
|
32
32
|
|
33
33
|
subject(:befores) { dummy_task.befores }
|
34
34
|
it 'adds DummyBeforeTask to the before callbacks' do
|
35
|
-
befores.first.
|
36
|
-
befores.first.task.
|
35
|
+
expect(befores.first).to be_an_instance_of(Anvil::Task::Callback)
|
36
|
+
expect(befores.first.task).to be(DummyBeforeTask)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -47,31 +47,36 @@ describe Anvil::Task do
|
|
47
47
|
subject { dummy_task.new }
|
48
48
|
|
49
49
|
context 'with a passing assure' do
|
50
|
-
before
|
50
|
+
before do
|
51
|
+
allow(dummy_task).to receive(:assures).and_return([DummyAssure])
|
52
|
+
end
|
51
53
|
|
52
54
|
it 'runs the callbacks and the task' do
|
53
|
-
subject.
|
54
|
-
subject.
|
55
|
-
subject.
|
55
|
+
expect(subject).to receive(:run_before_callbacks)
|
56
|
+
expect(subject).to receive(:run_after_callbacks)
|
57
|
+
expect(subject).to receive(:run_task)
|
56
58
|
subject.run
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
60
62
|
context 'with a non passing assure' do
|
61
|
-
before
|
63
|
+
before do
|
64
|
+
allow(dummy_task).to receive(:assures).and_return([DummyFailedAssure])
|
65
|
+
end
|
62
66
|
|
63
67
|
it 'does not run the callbacks nor the task' do
|
64
|
-
subject.
|
65
|
-
subject.
|
66
|
-
subject.
|
68
|
+
expect(subject).to_not receive(:run_before_callbacks)
|
69
|
+
expect(subject).to_not receive(:run_after_callbacks)
|
70
|
+
expect(subject).to_not receive(:run_task)
|
67
71
|
subject.run
|
68
72
|
end
|
69
73
|
end
|
70
74
|
end
|
71
75
|
|
72
76
|
describe '.run' do
|
77
|
+
let(:task) { double run: true }
|
73
78
|
it 'calls run in a instance of the task' do
|
74
|
-
|
79
|
+
expect(described_class).to receive(:new).and_return(task)
|
75
80
|
dummy_task.run(1, 2)
|
76
81
|
end
|
77
82
|
end
|
@@ -6,31 +6,31 @@ describe Anvil::Versioner do
|
|
6
6
|
|
7
7
|
describe '#major!' do
|
8
8
|
it 'bumps the major version and resets the others' do
|
9
|
-
subject.major
|
9
|
+
expect(subject.major!).to eq('2.0.0')
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
describe '#minor!' do
|
14
14
|
it 'bumps minor term and resets patch, pre and build' do
|
15
|
-
subject.minor
|
15
|
+
expect(subject.minor!).to eq('1.3.0')
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '#patch!' do
|
20
20
|
it 'bumps the patch term and resets the pre and build' do
|
21
|
-
subject.patch
|
21
|
+
expect(subject.patch!).to eq('1.2.4')
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
describe '#pre' do
|
26
26
|
it 'bumps the pre-release version and resets the build' do
|
27
|
-
subject.pre
|
27
|
+
expect(subject.pre!).to eq('1.2.3-alpha.2')
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe '#build!' do
|
32
32
|
it 'bumps the build version' do
|
33
|
-
subject.build
|
33
|
+
expect(subject.build!).to eq('1.2.3-alpha.1+build.3')
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -49,7 +49,7 @@ describe Gem::BuildTask do
|
|
49
49
|
let(:gem_file) { 'alfred.gem' }
|
50
50
|
|
51
51
|
before do
|
52
|
-
Anvil::Rubygems.
|
52
|
+
allow(Anvil::Rubygems).to receive(:build) do
|
53
53
|
FileUtils.touch('anvil-2.0.0.gem')
|
54
54
|
|
55
55
|
output
|
@@ -59,11 +59,11 @@ describe Gem::BuildTask do
|
|
59
59
|
it 'builds the gem' do
|
60
60
|
subject.build_gem(gem_file)
|
61
61
|
|
62
|
-
expect(File.exists?('pkg/anvil-2.0.0.gem')).to
|
62
|
+
expect(File.exists?('pkg/anvil-2.0.0.gem')).to be_truthy
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'returns the gem file path' do
|
66
|
-
expect(subject.build_gem(gem_file)).to
|
66
|
+
expect(subject.build_gem(gem_file)).to include('/pkg/anvil-2.0.0.gem')
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -7,11 +7,13 @@ describe Gem::BumpTask do
|
|
7
7
|
subject { Gem::BumpTask.new 'major' }
|
8
8
|
|
9
9
|
describe '#task' do
|
10
|
-
before { subject.
|
10
|
+
before { allow(subject).to receive(:read_version).and_return('2.0.0') }
|
11
11
|
|
12
12
|
it 'bumps the version and writes it' do
|
13
13
|
expect(subject).to receive(:prepare_repo).and_return(true)
|
14
|
-
|
14
|
+
allow(subject).to receive(:write_version)
|
15
|
+
.with(instance_of(String))
|
16
|
+
.and_return(true)
|
15
17
|
|
16
18
|
expect(subject.task).to eq('3.0.0')
|
17
19
|
end
|
@@ -39,8 +41,8 @@ describe Gem::BumpTask do
|
|
39
41
|
describe '#prepare_repo' do
|
40
42
|
context 'on a clean repo' do
|
41
43
|
before do
|
42
|
-
subject.
|
43
|
-
subject.
|
44
|
+
allow(subject).to receive(:clean?).and_return(true)
|
45
|
+
allow(subject).to receive(:git).and_return(double)
|
44
46
|
end
|
45
47
|
|
46
48
|
it 'pulls' do
|
@@ -51,7 +53,7 @@ describe Gem::BumpTask do
|
|
51
53
|
end
|
52
54
|
|
53
55
|
context 'on a dirty repo' do
|
54
|
-
before { subject.
|
56
|
+
before { allow(subject).to receive(:clean?).and_return(false) }
|
55
57
|
|
56
58
|
it 'raises RepoNotClean' do
|
57
59
|
expect do
|
@@ -10,12 +10,12 @@ describe Gem::ReleaseTask do
|
|
10
10
|
|
11
11
|
describe '#task' do
|
12
12
|
before do
|
13
|
-
subject.
|
14
|
-
subject.
|
13
|
+
allow(subject).to receive(:bump).and_return(version)
|
14
|
+
allow(subject).to receive(:build).and_return(gem_file)
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'pushes the gem to rubygems' do
|
18
|
-
subject.
|
18
|
+
expect(subject).to receive(:push)
|
19
19
|
end
|
20
20
|
|
21
21
|
after { subject.task }
|
@@ -4,6 +4,7 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
describe Projects::AddTask do
|
6
6
|
let(:repo_url) { 'git@github.com:account/repo' }
|
7
|
+
before { Anvil::Config.send :init_base_path }
|
7
8
|
|
8
9
|
subject { described_class.new('repo', 'account/repo') }
|
9
10
|
|
@@ -18,7 +19,7 @@ describe Projects::AddTask do
|
|
18
19
|
|
19
20
|
describe '#clone_repo', config: true do
|
20
21
|
it 'clones the repo with Git' do
|
21
|
-
Git.
|
22
|
+
expect(Git).to receive(:clone)
|
22
23
|
|
23
24
|
subject.clone_repo(repo_url, 'repo')
|
24
25
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -5,19 +5,20 @@
|
|
5
5
|
#
|
6
6
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
7
|
|
8
|
-
require '
|
8
|
+
require 'rspec/its'
|
9
9
|
require 'anvil'
|
10
10
|
|
11
11
|
begin
|
12
12
|
require 'codeclimate-test-reporter'
|
13
13
|
CodeClimate::TestReporter.start
|
14
|
-
rescue LoadError
|
14
|
+
rescue LoadError
|
15
|
+
puts "Couldn't load the codeclimate test reporter"
|
16
|
+
end
|
15
17
|
|
16
|
-
Dir["#{File.dirname(__FILE__)}/support/
|
18
|
+
Dir["#{File.dirname(__FILE__)}/support/dummy_tasks/**/*.rb"].each { |f| require f }
|
17
19
|
Dir["#{File.dirname(__FILE__)}/support/shared/**/*.rb"].each { |f| require f }
|
18
20
|
|
19
21
|
RSpec.configure do |config|
|
20
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
21
22
|
config.run_all_when_everything_filtered = true
|
22
23
|
config.filter_run :focus
|
23
24
|
|
@@ -26,7 +27,13 @@ RSpec.configure do |config|
|
|
26
27
|
# the seed, which is printed after each run.
|
27
28
|
# --seed 1234
|
28
29
|
config.order = 'random'
|
29
|
-
config.before(:
|
30
|
-
|
30
|
+
config.before(:suite) { Anvil.module_eval { @logger = Logger.new(nil) } }
|
31
|
+
config.before do
|
32
|
+
FileUtils.rm_rf ConfigMock.base_path
|
33
|
+
FileUtils.mkdir_p ConfigMock.base_path
|
34
|
+
FileUtils.cp ConfigMock.config_file,
|
35
|
+
ConfigMock.base_path
|
31
36
|
end
|
37
|
+
|
38
|
+
config.after { FileUtils.rm_rf ConfigMock.base_path }
|
32
39
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,2 +1,2 @@
|
|
1
|
-
github.user
|
1
|
+
github.user 'dummy_user'
|
2
2
|
github.token 'dummy_token'
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Mocks the anvil config and folder for the specs so that it uses a
|
2
|
+
# sandbox instead of the user's one
|
3
|
+
module ConfigMock
|
4
|
+
def self.base_path
|
5
|
+
File.expand_path('../dot_anvil', File.dirname(__FILE__))
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.config_file
|
9
|
+
File.expand_path('../fixtures/config.rb', File.dirname(__FILE__))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Anvil::Config::ClassMethods.module_eval do
|
14
|
+
def base_path
|
15
|
+
ConfigMock.base_path
|
16
|
+
end
|
17
|
+
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fran Casas
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: git
|
@@ -115,28 +115,28 @@ dependencies:
|
|
115
115
|
requirements:
|
116
116
|
- - "~>"
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: '2
|
118
|
+
version: '3.2'
|
119
119
|
type: :development
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
123
|
- - "~>"
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: '2
|
125
|
+
version: '3.2'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: rspec-its
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- - "
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version: '0
|
132
|
+
version: '0'
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- - "
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version: '0
|
139
|
+
version: '0'
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
141
|
name: rubocop
|
142
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -175,6 +175,7 @@ files:
|
|
175
175
|
- lib/anvil/config.rb
|
176
176
|
- lib/anvil/config/class_methods.rb
|
177
177
|
- lib/anvil/extensions_manager.rb
|
178
|
+
- lib/anvil/options_detector.rb
|
178
179
|
- lib/anvil/parser.rb
|
179
180
|
- lib/anvil/rubygems.rb
|
180
181
|
- lib/anvil/task.rb
|
@@ -213,15 +214,14 @@ files:
|
|
213
214
|
- spec/lib/tasks/projects/add_task_spec.rb
|
214
215
|
- spec/lib/tasks/projects/list_task_spec.rb
|
215
216
|
- spec/spec_helper.rb
|
216
|
-
- spec/support/
|
217
|
-
- spec/support/
|
218
|
-
- spec/support/
|
219
|
-
- spec/support/
|
220
|
-
- spec/support/
|
221
|
-
- spec/support/
|
222
|
-
- spec/support/fixtures/
|
223
|
-
- spec/support/shared/
|
224
|
-
- spec/support/shared/fake_fs_context.rb
|
217
|
+
- spec/support/dummy_tasks/dummy_after_task.rb
|
218
|
+
- spec/support/dummy_tasks/dummy_assure.rb
|
219
|
+
- spec/support/dummy_tasks/dummy_before_task.rb
|
220
|
+
- spec/support/dummy_tasks/dummy_failed_assure.rb
|
221
|
+
- spec/support/dummy_tasks/dummy_task.rb
|
222
|
+
- spec/support/dummy_tasks/foo/dummy_task.rb
|
223
|
+
- spec/support/fixtures/config.rb
|
224
|
+
- spec/support/shared/config_mock.rb
|
225
225
|
homepage: http://github.com/anvil-src/anvil-core
|
226
226
|
licenses:
|
227
227
|
- MIT
|
@@ -242,37 +242,36 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
242
|
version: 2.1.0
|
243
243
|
requirements: []
|
244
244
|
rubyforge_project:
|
245
|
-
rubygems_version: 2.3
|
245
|
+
rubygems_version: 2.4.3
|
246
246
|
signing_key:
|
247
247
|
specification_version: 4
|
248
248
|
summary: Anvil is a tool for building tools. A tool that a real craftsmen uses to
|
249
249
|
build its tools.
|
250
250
|
test_files:
|
251
251
|
- spec/spec_helper.rb
|
252
|
-
- spec/
|
253
|
-
- spec/
|
254
|
-
- spec/
|
255
|
-
- spec/
|
256
|
-
- spec/
|
257
|
-
- spec/
|
258
|
-
- spec/support/dot_anvil/config.rb
|
259
|
-
- spec/support/shared/config_context.rb
|
260
|
-
- spec/support/shared/fake_fs_context.rb
|
261
|
-
- spec/lib/anvil/assure_spec.rb
|
252
|
+
- spec/lib/tasks/projects/add_task_spec.rb
|
253
|
+
- spec/lib/tasks/projects/list_task_spec.rb
|
254
|
+
- spec/lib/tasks/gem/release_task_spec.rb
|
255
|
+
- spec/lib/tasks/gem/build_task_spec.rb
|
256
|
+
- spec/lib/tasks/gem/bump_task_spec.rb
|
257
|
+
- spec/lib/anvil/config_spec.rb
|
262
258
|
- spec/lib/anvil/cli_spec.rb
|
263
259
|
- spec/lib/anvil/task_spec.rb
|
264
|
-
- spec/lib/anvil/
|
265
|
-
- spec/lib/anvil/assures/file_assure_spec.rb
|
260
|
+
- spec/lib/anvil/extensions_manager_spec.rb
|
266
261
|
- spec/lib/anvil/assures/directory_assure_spec.rb
|
267
|
-
- spec/lib/anvil/
|
262
|
+
- spec/lib/anvil/assures/file_assure_spec.rb
|
268
263
|
- spec/lib/anvil/parser_spec.rb
|
264
|
+
- spec/lib/anvil/versioner_spec.rb
|
265
|
+
- spec/lib/anvil/task/projects_spec.rb
|
269
266
|
- spec/lib/anvil/task/callback_spec.rb
|
270
267
|
- spec/lib/anvil/task/naming_spec.rb
|
271
|
-
- spec/lib/anvil/task/projects_spec.rb
|
272
268
|
- spec/lib/anvil/task/options_spec.rb
|
273
|
-
- spec/lib/anvil/
|
274
|
-
- spec/
|
275
|
-
- spec/
|
276
|
-
- spec/
|
277
|
-
- spec/
|
278
|
-
- spec/
|
269
|
+
- spec/lib/anvil/assure_spec.rb
|
270
|
+
- spec/support/dummy_tasks/dummy_failed_assure.rb
|
271
|
+
- spec/support/dummy_tasks/dummy_before_task.rb
|
272
|
+
- spec/support/dummy_tasks/foo/dummy_task.rb
|
273
|
+
- spec/support/dummy_tasks/dummy_task.rb
|
274
|
+
- spec/support/dummy_tasks/dummy_after_task.rb
|
275
|
+
- spec/support/dummy_tasks/dummy_assure.rb
|
276
|
+
- spec/support/fixtures/config.rb
|
277
|
+
- spec/support/shared/config_mock.rb
|
@@ -1,12 +0,0 @@
|
|
1
|
-
shared_context 'init anvil config', config: true do
|
2
|
-
include_context 'with FakeFS'
|
3
|
-
|
4
|
-
let(:test_config_path) do
|
5
|
-
File.expand_path('./spec/support/dot_anvil', File.dirname(__FILE__))
|
6
|
-
end
|
7
|
-
|
8
|
-
before do
|
9
|
-
Anvil::Config.stub(:base_path).and_return(test_config_path)
|
10
|
-
Anvil::Config.init
|
11
|
-
end
|
12
|
-
end
|