anvil-core 0.1.0 → 0.2.0
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 +4 -4
- data/VERSION +1 -1
- data/lib/anvil/task/projects.rb +27 -0
- data/lib/anvil/task_manager.rb +1 -1
- data/lib/tasks/gem/bump_task.rb +16 -6
- data/spec/lib/anvil/task/projects_spec.rb +48 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee2a3e726f71df8d805f6948e7dddf8c865d983d
|
4
|
+
data.tar.gz: 268c51a44e9bd3aedded2d898e1cf91d353c7b80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b02d16e0f8c0430407742909227a7b31cec9a2d3f5ae2c9fb47a3531e324e42a90784e838bac6d34cf7c1bb26a1665ac22ba84d5171a29583a9980af9a31295
|
7
|
+
data.tar.gz: 087e1f4ae6030290d71d65902ffd2ba1d0d7580cbe2862f377fe2640a7c6f65dc07108fcd9e2990a72743fa90c47921921c00c0c01b2db71a62c1c514e0b3e50
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'git'
|
2
|
+
|
3
|
+
module Anvil
|
4
|
+
class Task
|
5
|
+
module Projects
|
6
|
+
def project_path(project)
|
7
|
+
Anvil::Config.base_projects_path + "/#{project}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def change_project(project)
|
11
|
+
Dir.chdir(project_path(project))
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_project(project)
|
15
|
+
Dir.chdir(project_path(project)) do
|
16
|
+
yield(git)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def git
|
23
|
+
Git.open(Dir.pwd)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/anvil/task_manager.rb
CHANGED
@@ -29,7 +29,7 @@ module Anvil
|
|
29
29
|
|
30
30
|
# @return [String] top level dir if this is a git managed project
|
31
31
|
def self.current_project_path
|
32
|
-
Rugged::Repository.discover(
|
32
|
+
Rugged::Repository.discover(Dir.pwd).gsub('.git/', '')
|
33
33
|
rescue Rugged::RepositoryError
|
34
34
|
''
|
35
35
|
end
|
data/lib/tasks/gem/bump_task.rb
CHANGED
@@ -7,8 +7,12 @@ class Gem::BumpTask < Anvil::Task
|
|
7
7
|
parser do
|
8
8
|
arguments %w(term)
|
9
9
|
|
10
|
-
on('-p', '--
|
11
|
-
options[:persist] =
|
10
|
+
on('-p', '--persist', 'Commit tag and push the changes') do |p|
|
11
|
+
options[:persist] = true
|
12
|
+
end
|
13
|
+
|
14
|
+
on('-f', '--force', 'Act even if the git repo is not clean') do |f|
|
15
|
+
options[:force] = true
|
12
16
|
end
|
13
17
|
end
|
14
18
|
|
@@ -30,7 +34,7 @@ class Gem::BumpTask < Anvil::Task
|
|
30
34
|
protected
|
31
35
|
|
32
36
|
def git
|
33
|
-
@git ||= Git.open
|
37
|
+
@git ||= Git.open Dir.pwd
|
34
38
|
end
|
35
39
|
|
36
40
|
def version_file(mode = 'r')
|
@@ -67,9 +71,11 @@ class Gem::BumpTask < Anvil::Task
|
|
67
71
|
end
|
68
72
|
|
69
73
|
def prepare_repo
|
70
|
-
|
71
|
-
|
72
|
-
|
74
|
+
if clean? || force?
|
75
|
+
git.pull
|
76
|
+
else
|
77
|
+
fail Anvil::RepoNotClean
|
78
|
+
end
|
73
79
|
end
|
74
80
|
|
75
81
|
def clean?
|
@@ -77,4 +83,8 @@ class Gem::BumpTask < Anvil::Task
|
|
77
83
|
git.status.deleted.empty? &&
|
78
84
|
git.status.added.empty?
|
79
85
|
end
|
86
|
+
|
87
|
+
def force?
|
88
|
+
options[:force]
|
89
|
+
end
|
80
90
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'anvil/task/projects'
|
3
|
+
|
4
|
+
describe Anvil::Task::Projects, fakefs: true do
|
5
|
+
let(:dummy_class) do
|
6
|
+
Class.new do
|
7
|
+
include Anvil::Task::Projects
|
8
|
+
end
|
9
|
+
end
|
10
|
+
let(:project) { 'anvil-core' }
|
11
|
+
let(:project_path) { Anvil::Config.base_projects_path + "/#{project}" }
|
12
|
+
subject { dummy_class.new }
|
13
|
+
|
14
|
+
before { FileUtils.mkdir_p project_path }
|
15
|
+
|
16
|
+
describe '#project_path' do
|
17
|
+
it "returns the anvil's project path" do
|
18
|
+
expect(subject.project_path(project))
|
19
|
+
.to eq(project_path)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#change_project' do
|
24
|
+
let!(:previous_dir) { Dir.getwd }
|
25
|
+
|
26
|
+
before { FileUtils.mkdir_p project_path }
|
27
|
+
after { Dir.chdir previous_dir }
|
28
|
+
|
29
|
+
it "cd's into the project's path" do
|
30
|
+
subject.change_project(project)
|
31
|
+
expect(Dir.getwd).to eq(project_path)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe '#on_project' do
|
36
|
+
before { subject.stub(:git).and_return(double('git')) }
|
37
|
+
|
38
|
+
it 'keeps the project changed inside the block' do
|
39
|
+
subject.on_project project do
|
40
|
+
expect(Dir.pwd).to eq(project_path)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'yields a git project object' do
|
45
|
+
expect { |b| subject.on_project(project, &b) }.to yield_with_args
|
46
|
+
end
|
47
|
+
end
|
48
|
+
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.2.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: 2014-05-
|
12
|
+
date: 2014-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: git
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/anvil/task/class_methods.rb
|
181
181
|
- lib/anvil/task/naming.rb
|
182
182
|
- lib/anvil/task/options.rb
|
183
|
+
- lib/anvil/task/projects.rb
|
183
184
|
- lib/anvil/task/repositories.rb
|
184
185
|
- lib/anvil/task_manager.rb
|
185
186
|
- lib/anvil/version.rb
|
@@ -199,6 +200,7 @@ files:
|
|
199
200
|
- spec/lib/anvil/parser_spec.rb
|
200
201
|
- spec/lib/anvil/task/naming_spec.rb
|
201
202
|
- spec/lib/anvil/task/options_spec.rb
|
203
|
+
- spec/lib/anvil/task/projects_spec.rb
|
202
204
|
- spec/lib/anvil/task_manager_spec.rb
|
203
205
|
- spec/lib/anvil/task_spec.rb
|
204
206
|
- spec/lib/anvil/versioner_spec.rb
|
@@ -251,6 +253,7 @@ test_files:
|
|
251
253
|
- spec/lib/anvil/parser_spec.rb
|
252
254
|
- spec/lib/anvil/task/naming_spec.rb
|
253
255
|
- spec/lib/anvil/task/options_spec.rb
|
256
|
+
- spec/lib/anvil/task/projects_spec.rb
|
254
257
|
- spec/lib/anvil/task_manager_spec.rb
|
255
258
|
- spec/lib/anvil/task_spec.rb
|
256
259
|
- spec/lib/anvil/versioner_spec.rb
|