ronin-repos 0.1.0.beta1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -0
- data/.yardopts +1 -1
- data/README.md +2 -1
- data/bin/ronin-repos +1 -1
- data/gemspec.yml +2 -2
- data/lib/ronin/repos/cache_dir.rb +1 -1
- data/lib/ronin/repos/class_dir.rb +1 -1
- data/lib/ronin/repos/cli/command.rb +1 -1
- data/lib/ronin/repos/cli/commands/install.rb +1 -1
- data/lib/ronin/repos/cli/commands/list.rb +1 -1
- data/lib/ronin/repos/cli/commands/new.rb +1 -1
- data/lib/ronin/repos/cli/commands/purge.rb +1 -1
- data/lib/ronin/repos/cli/commands/remove.rb +1 -1
- data/lib/ronin/repos/cli/commands/update.rb +1 -1
- data/lib/ronin/repos/cli.rb +6 -1
- data/lib/ronin/repos/exceptions.rb +1 -1
- data/lib/ronin/repos/repository.rb +1 -1
- data/lib/ronin/repos/root.rb +1 -1
- data/lib/ronin/repos/version.rb +2 -2
- data/lib/ronin/repos.rb +1 -1
- data/ronin-repos.gemspec +2 -1
- metadata +6 -26
- data/spec/cache_dir_spec.rb +0 -272
- data/spec/class_dir_spec.rb +0 -97
- data/spec/fixtures/cache/repo1/dir/file1.txt +0 -0
- data/spec/fixtures/cache/repo1/file1.txt +0 -0
- data/spec/fixtures/cache/repo1/file2.txt +0 -0
- data/spec/fixtures/cache/repo2/dir/file1.txt +0 -0
- data/spec/fixtures/cache/repo2/dir/file2.txt +0 -0
- data/spec/fixtures/cache/repo2/file1.txt +0 -0
- data/spec/fixtures/cache/repo2/file2.txt +0 -0
- data/spec/fixtures/cache/repo2/only-exists-in-repo2.txt +0 -0
- data/spec/fixtures/class_dir/file1.rb +0 -0
- data/spec/fixtures/class_dir/file2.rb +0 -0
- data/spec/fixtures/class_dir/only_in_class_dir.rb +0 -0
- data/spec/repos_spec.rb +0 -67
- data/spec/repository_spec.rb +0 -415
- data/spec/spec_helper.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30c76d7743b473b4df8d834209051aa7643aafade9edcc3e3f12e8b344741e7f
|
4
|
+
data.tar.gz: a4c58c0869e1b44a4c5da6589760f86cf261af3dcfe6478a8cff01efe1bab9c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92a8b69b652f962de02fd63b9fbc8e71636c669126e0ab96e769e4aa9894aa70689bc275001e6ddfe214606977618b003daf3de8dfb7966c1feff4e96a910221
|
7
|
+
data.tar.gz: fa460921d3bf47e09714d3fdfeb01d392739ef96366df19f2f6262df1c8df4d37f8eef05bc6f7ac56f0815b76fc8e0c6efd37e23111b788c29db4c3fdc5aa651
|
data/.github/workflows/ruby.yml
CHANGED
data/.yardopts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
--markup markdown --title 'Ronin
|
1
|
+
--markup markdown --title 'Ronin::Repos Documentation' --protected
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![CI](https://github.com/ronin-rb/ronin-repos/actions/workflows/ruby.yml/badge.svg)](https://github.com/ronin-rb/ronin-repos/actions/workflows/ruby.yml)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/ronin-rb/ronin-repos.svg)](https://codeclimate.com/github/ronin-rb/ronin-repos)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/ronin-repos.svg)](https://badge.fury.io/rb/ronin-repos)
|
5
6
|
|
6
7
|
* [Website](https://ronin-rb.dev)
|
7
8
|
* [Source](https://github.com/ronin-rb/ronin-repos)
|
@@ -137,7 +138,7 @@ gem 'ronin-repos', '~> 0.1'
|
|
137
138
|
|
138
139
|
## License
|
139
140
|
|
140
|
-
Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
141
|
+
Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
141
142
|
|
142
143
|
ronin-repos is free software: you can redistribute it and/or modify
|
143
144
|
it under the terms of the GNU Lesser General Public License as published
|
data/bin/ronin-repos
CHANGED
data/gemspec.yml
CHANGED
@@ -11,7 +11,7 @@ homepage: https://ronin-rb.dev
|
|
11
11
|
has_yard: true
|
12
12
|
|
13
13
|
metadata:
|
14
|
-
documentation_uri: https://
|
14
|
+
documentation_uri: https://ronin-rb.dev/docs/ronin-repos
|
15
15
|
source_code_uri: https://github.com/ronin-rb/ronin-repos
|
16
16
|
bug_tracker_uri: https://github.com/ronin-rb/ronin-repos/issues
|
17
17
|
changelog_uri: https://github.com/ronin-rb/ronin-repos/blob/main/ChangeLog.md
|
@@ -30,7 +30,7 @@ required_ruby_version: ">= 3.0.0"
|
|
30
30
|
|
31
31
|
dependencies:
|
32
32
|
# Library dependencies:
|
33
|
-
ronin-core: ~> 0.1
|
33
|
+
ronin-core: ~> 0.1
|
34
34
|
|
35
35
|
development_dependencies:
|
36
36
|
bundler: ~> 2.0
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
data/lib/ronin/repos/cli.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -16,8 +16,11 @@
|
|
16
16
|
# along with ronin-repos. If not, see <https://www.gnu.org/licenses/>.
|
17
17
|
#
|
18
18
|
|
19
|
+
require 'ronin/repos/version'
|
20
|
+
|
19
21
|
require 'command_kit/commands'
|
20
22
|
require 'command_kit/commands/auto_load'
|
23
|
+
require 'command_kit/options/version'
|
21
24
|
|
22
25
|
module Ronin
|
23
26
|
module Repos
|
@@ -33,8 +36,10 @@ module Ronin
|
|
33
36
|
dir: "#{__dir__}/cli/commands",
|
34
37
|
namespace: "#{self}::Commands"
|
35
38
|
)
|
39
|
+
include CommandKit::Options::Version
|
36
40
|
|
37
41
|
command_name 'ronin-repos'
|
42
|
+
version Ronin::Repos::VERSION
|
38
43
|
|
39
44
|
command_aliases['ls'] = 'list'
|
40
45
|
command_aliases['up'] = 'update'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
data/lib/ronin/repos/root.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
data/lib/ronin/repos/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
@@ -19,6 +19,6 @@
|
|
19
19
|
module Ronin
|
20
20
|
module Repos
|
21
21
|
# ronin-repos version
|
22
|
-
VERSION = '0.1.0
|
22
|
+
VERSION = '0.1.0'
|
23
23
|
end
|
24
24
|
end
|
data/lib/ronin/repos.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
#
|
3
|
-
# Copyright (c) 2021 Hal Brodigan (postmodern.mod3 at gmail.com)
|
3
|
+
# Copyright (c) 2021-2023 Hal Brodigan (postmodern.mod3 at gmail.com)
|
4
4
|
#
|
5
5
|
# ronin-repos is free software: you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as published
|
data/ronin-repos.gemspec
CHANGED
@@ -27,6 +27,8 @@ Gem::Specification.new do |gem|
|
|
27
27
|
gem.files = `git ls-files`.split($/)
|
28
28
|
gem.files = glob[gemspec['files']] if gemspec['files']
|
29
29
|
gem.files += Array(gemspec['generated_files'])
|
30
|
+
# exclude test files from the packages gem
|
31
|
+
gem.files -= glob[gemspec['test_files'] || 'spec/{**/}*']
|
30
32
|
|
31
33
|
gem.executables = gemspec.fetch('executables') do
|
32
34
|
glob['bin/*'].map { |path| File.basename(path) }
|
@@ -34,7 +36,6 @@ Gem::Specification.new do |gem|
|
|
34
36
|
gem.default_executable = gem.executables.first if Gem::VERSION < '1.7.'
|
35
37
|
|
36
38
|
gem.extensions = glob[gemspec['extensions'] || 'ext/**/extconf.rb']
|
37
|
-
gem.test_files = glob[gemspec['test_files'] || 'spec/{**/}*_spec.rb']
|
38
39
|
gem.extra_rdoc_files = glob[gemspec['extra_doc_files'] || '*.{txt,md}']
|
39
40
|
|
40
41
|
gem.require_paths = Array(gemspec.fetch('require_paths') {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ronin-repos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Postmodern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ronin-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.1
|
19
|
+
version: '0.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1
|
26
|
+
version: '0.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,27 +92,11 @@ files:
|
|
92
92
|
- man/ronin-repos.1
|
93
93
|
- man/ronin-repos.1.md
|
94
94
|
- ronin-repos.gemspec
|
95
|
-
- spec/cache_dir_spec.rb
|
96
|
-
- spec/class_dir_spec.rb
|
97
|
-
- spec/fixtures/cache/repo1/dir/file1.txt
|
98
|
-
- spec/fixtures/cache/repo1/file1.txt
|
99
|
-
- spec/fixtures/cache/repo1/file2.txt
|
100
|
-
- spec/fixtures/cache/repo2/dir/file1.txt
|
101
|
-
- spec/fixtures/cache/repo2/dir/file2.txt
|
102
|
-
- spec/fixtures/cache/repo2/file1.txt
|
103
|
-
- spec/fixtures/cache/repo2/file2.txt
|
104
|
-
- spec/fixtures/cache/repo2/only-exists-in-repo2.txt
|
105
|
-
- spec/fixtures/class_dir/file1.rb
|
106
|
-
- spec/fixtures/class_dir/file2.rb
|
107
|
-
- spec/fixtures/class_dir/only_in_class_dir.rb
|
108
|
-
- spec/repos_spec.rb
|
109
|
-
- spec/repository_spec.rb
|
110
|
-
- spec/spec_helper.rb
|
111
95
|
homepage: https://ronin-rb.dev
|
112
96
|
licenses:
|
113
97
|
- LGPL-3.0
|
114
98
|
metadata:
|
115
|
-
documentation_uri: https://
|
99
|
+
documentation_uri: https://ronin-rb.dev/docs/ronin-repos
|
116
100
|
source_code_uri: https://github.com/ronin-rb/ronin-repos
|
117
101
|
bug_tracker_uri: https://github.com/ronin-rb/ronin-repos/issues
|
118
102
|
changelog_uri: https://github.com/ronin-rb/ronin-repos/blob/main/ChangeLog.md
|
@@ -136,8 +120,4 @@ rubygems_version: 3.3.26
|
|
136
120
|
signing_key:
|
137
121
|
specification_version: 4
|
138
122
|
summary: Third-party git repository support for ronin.
|
139
|
-
test_files:
|
140
|
-
- spec/cache_dir_spec.rb
|
141
|
-
- spec/class_dir_spec.rb
|
142
|
-
- spec/repos_spec.rb
|
143
|
-
- spec/repository_spec.rb
|
123
|
+
test_files: []
|
data/spec/cache_dir_spec.rb
DELETED
@@ -1,272 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/repos/cache_dir'
|
3
|
-
|
4
|
-
describe Ronin::Repos::CacheDir do
|
5
|
-
let(:fixtures_dir) { File.expand_path(File.join(__dir__,'fixtures')) }
|
6
|
-
let(:cache_dir) { File.join(fixtures_dir,'cache') }
|
7
|
-
|
8
|
-
describe "PATH" do
|
9
|
-
subject { described_class::PATH }
|
10
|
-
|
11
|
-
it "must default to ~/.cache/ronin-repos" do
|
12
|
-
expect(subject).to eq(File.join(ENV['HOME'],'.cache','ronin-repos'))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
subject { described_class.new(cache_dir) }
|
17
|
-
|
18
|
-
describe "#initialize" do
|
19
|
-
context "when no arguments are given" do
|
20
|
-
subject { described_class.new }
|
21
|
-
|
22
|
-
it "must set #path to PATH" do
|
23
|
-
expect(subject.path).to eq(described_class::PATH)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when given a path argument" do
|
28
|
-
subject { described_class.new(cache_dir) }
|
29
|
-
|
30
|
-
it "must set #path" do
|
31
|
-
expect(subject.path).to eq(cache_dir)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "#[]" do
|
37
|
-
context "when a repository with the given name exists in the cache dir" do
|
38
|
-
let(:name) { 'repo2' }
|
39
|
-
|
40
|
-
it "must return a Repository object with the matching name" do
|
41
|
-
repo = subject[name]
|
42
|
-
|
43
|
-
expect(repo).to be_kind_of(Repository)
|
44
|
-
expect(repo.name).to eq(name)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
context "when given an unknown repository name" do
|
49
|
-
let(:name) { 'does_not_exist' }
|
50
|
-
|
51
|
-
it do
|
52
|
-
expect {
|
53
|
-
subject[name]
|
54
|
-
}.to raise_error(RepositoryNotFound,"repository not found: #{name.inspect}")
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe "#each" do
|
60
|
-
context "when given a block" do
|
61
|
-
it "must yield each Repository object" do
|
62
|
-
yielded_repos = []
|
63
|
-
|
64
|
-
subject.each do |repo|
|
65
|
-
yielded_repos << repo
|
66
|
-
end
|
67
|
-
|
68
|
-
expect(yielded_repos.length).to eq(2)
|
69
|
-
expect(yielded_repos[0]).to be_kind_of(Repository)
|
70
|
-
expect(yielded_repos[0].name).to eq("repo1")
|
71
|
-
|
72
|
-
expect(yielded_repos[1]).to be_kind_of(Repository)
|
73
|
-
expect(yielded_repos[1].name).to eq("repo2")
|
74
|
-
end
|
75
|
-
|
76
|
-
context "when #path does not exist" do
|
77
|
-
subject { described_class.new('/does/not/exist') }
|
78
|
-
|
79
|
-
it "must not yield anything" do
|
80
|
-
expect { |b|
|
81
|
-
subject.each(&b)
|
82
|
-
}.to_not yield_control
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
context "when no block is given" do
|
88
|
-
it "must return an Enumerator object" do
|
89
|
-
yielded_repos = subject.each.to_a
|
90
|
-
|
91
|
-
expect(yielded_repos.length).to eq(2)
|
92
|
-
expect(yielded_repos[0]).to be_kind_of(Repository)
|
93
|
-
expect(yielded_repos[0].name).to eq("repo1")
|
94
|
-
|
95
|
-
expect(yielded_repos[1]).to be_kind_of(Repository)
|
96
|
-
expect(yielded_repos[1].name).to eq("repo2")
|
97
|
-
end
|
98
|
-
|
99
|
-
context "when #path does not exist" do
|
100
|
-
subject { described_class.new('/does/not/exist') }
|
101
|
-
|
102
|
-
it "the Enumerator must not return anything" do
|
103
|
-
expect(subject.each.to_a).to be_empty
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "#install" do
|
110
|
-
let(:name) { 'new_repo' }
|
111
|
-
let(:uri) { "https://github.com/example/#{name}.git" }
|
112
|
-
let(:path) { File.join(cache_dir,name) }
|
113
|
-
|
114
|
-
let(:new_repo) { double('Repository') }
|
115
|
-
|
116
|
-
it "must `git clone` the given URI into the cache directory" do
|
117
|
-
expect(Repository).to receive(:system).with(
|
118
|
-
'git', 'clone', uri, path
|
119
|
-
).and_return(true)
|
120
|
-
|
121
|
-
expect(Repository).to receive(:new).and_return(new_repo)
|
122
|
-
|
123
|
-
expect(subject.install(uri)).to be(new_repo)
|
124
|
-
end
|
125
|
-
|
126
|
-
context "when a custom name is given" do
|
127
|
-
let(:custom_name) { 'custom-repo' }
|
128
|
-
let(:path) { File.join(cache_dir,custom_name) }
|
129
|
-
|
130
|
-
it "must use the custom name instead of deriving the repository's name" do
|
131
|
-
expect(Repository).to receive(:system).with(
|
132
|
-
'git', 'clone', uri, path
|
133
|
-
).and_return(true)
|
134
|
-
|
135
|
-
expect(Repository).to receive(:new).and_return(new_repo)
|
136
|
-
|
137
|
-
expect(subject.install(uri,custom_name)).to be(new_repo)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe "#update" do
|
143
|
-
it "must call #update on each repository in the cache directory"
|
144
|
-
|
145
|
-
context "but system() returns nil" do
|
146
|
-
it do
|
147
|
-
expect_any_instance_of(Repository).to receive(:system).and_return(nil)
|
148
|
-
|
149
|
-
expect {
|
150
|
-
subject.update
|
151
|
-
}.to raise_error(CommandNotInstalled,"git is not installed")
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
describe "#remove" do
|
157
|
-
let(:name) { 'repo2' }
|
158
|
-
|
159
|
-
it "must call #delete on the Repository" do
|
160
|
-
expect_any_instance_of(Repository).to receive(:delete)
|
161
|
-
|
162
|
-
subject.remove(name)
|
163
|
-
end
|
164
|
-
|
165
|
-
context "when given an unknown repository name" do
|
166
|
-
let(:name) { 'does-not-exist' }
|
167
|
-
|
168
|
-
it do
|
169
|
-
expect {
|
170
|
-
subject.remove(name)
|
171
|
-
}.to raise_error(RepositoryNotFound,"repository not found: #{name.inspect}")
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
describe "#purge" do
|
177
|
-
it "must call #delete on every repository in the cache directory" do
|
178
|
-
expect(FileUtils).to receive(:rm_rf).with(File.join(cache_dir,'repo1'))
|
179
|
-
expect(FileUtils).to receive(:rm_rf).with(File.join(cache_dir,'repo2'))
|
180
|
-
|
181
|
-
subject.purge
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
describe "#find_file" do
|
186
|
-
let(:relative_path) { 'only-exists-in-repo2.txt' }
|
187
|
-
|
188
|
-
it "must return the first file that matches the given relative path" do
|
189
|
-
expect(subject.find_file(relative_path)).to eq(
|
190
|
-
File.join(cache_dir,'repo2',relative_path)
|
191
|
-
)
|
192
|
-
end
|
193
|
-
|
194
|
-
context "when the relative path does not exist within any repository" do
|
195
|
-
let(:relative_path) { 'does/not/exist.txt' }
|
196
|
-
|
197
|
-
it "must return nil" do
|
198
|
-
expect(subject.find_file(relative_path)).to be(nil)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
202
|
-
|
203
|
-
describe "#glob" do
|
204
|
-
context "when the pattern matches files within all repositories" do
|
205
|
-
let(:pattern) { 'dir/*.txt' }
|
206
|
-
|
207
|
-
let(:expected_paths) do
|
208
|
-
Dir[File.join(cache_dir,'*',pattern)]
|
209
|
-
end
|
210
|
-
|
211
|
-
it "must return the absolute paths that matches the pattern, in order" do
|
212
|
-
expect(subject.glob(pattern)).to eq(expected_paths.sort)
|
213
|
-
end
|
214
|
-
|
215
|
-
context "when a block is given" do
|
216
|
-
it "must yield the matching absolute paths" do
|
217
|
-
expect { |b|
|
218
|
-
subject.glob(pattern,&b)
|
219
|
-
}.to yield_successive_args(*expected_paths.sort)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
context "when the relative path does not exist within any repository" do
|
225
|
-
let(:pattern) { 'does/not/exist/*.txt' }
|
226
|
-
|
227
|
-
it "must return []" do
|
228
|
-
expect(subject.glob(pattern)).to eq([])
|
229
|
-
end
|
230
|
-
|
231
|
-
context "when a block is given" do
|
232
|
-
it "must not yield" do
|
233
|
-
expect { |b|
|
234
|
-
subject.glob(pattern,&b)
|
235
|
-
}.to_not yield_control
|
236
|
-
end
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
describe "#list_files" do
|
242
|
-
context "when given no arguments" do
|
243
|
-
it "must list every unique file within each repository" do
|
244
|
-
expect(subject.list_files).to eq(
|
245
|
-
Set.new(
|
246
|
-
%w[
|
247
|
-
dir/file1.txt
|
248
|
-
dir/file2.txt
|
249
|
-
file1.txt
|
250
|
-
file2.txt
|
251
|
-
only-exists-in-repo2.txt
|
252
|
-
]
|
253
|
-
)
|
254
|
-
)
|
255
|
-
end
|
256
|
-
end
|
257
|
-
|
258
|
-
context "when given a glob pattern" do
|
259
|
-
it "must list only the files that match the glob pattern" do
|
260
|
-
expect(subject.list_files('dir/*.txt')).to eq(
|
261
|
-
Set.new(%w[dir/file1.txt dir/file2.txt])
|
262
|
-
)
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
describe "#to_s" do
|
268
|
-
it "must return the cache directory path" do
|
269
|
-
expect(subject.to_s).to eq(cache_dir)
|
270
|
-
end
|
271
|
-
end
|
272
|
-
end
|
data/spec/class_dir_spec.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/repos/class_dir'
|
3
|
-
|
4
|
-
describe Ronin::Repos::ClassDir do
|
5
|
-
let(:fixtures_dir) { File.expand_path(File.join(__dir__,'fixtures')) }
|
6
|
-
|
7
|
-
describe ".repo_class_dir" do
|
8
|
-
context "when a repo_class_dir has been defined" do
|
9
|
-
module TestClassDir
|
10
|
-
module WithReposClassDirSet
|
11
|
-
include Ronin::Repos::ClassDir
|
12
|
-
|
13
|
-
repo_class_dir "dir"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
subject { TestClassDir::WithReposClassDirSet }
|
18
|
-
|
19
|
-
it "must return the previously set .repo_class_dir" do
|
20
|
-
expect(subject.repo_class_dir).to eq("dir")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "but when no repo_class_dir has been defined" do
|
25
|
-
module TestReposDir
|
26
|
-
module WithoutReposDirSet
|
27
|
-
include Ronin::Repos::ClassDir
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
subject { TestReposDir::WithoutReposDirSet }
|
32
|
-
|
33
|
-
it do
|
34
|
-
expect {
|
35
|
-
subject.repo_class_dir
|
36
|
-
}.to raise_error(NotImplementedError,"#{subject} did not define a repo_class_dir")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
module TestReposDir
|
42
|
-
module ExampleNamespace
|
43
|
-
include Ronin::Core::ClassRegistry
|
44
|
-
include Ronin::Repos::ClassDir
|
45
|
-
|
46
|
-
class_dir "#{__dir__}/fixtures/class_dir"
|
47
|
-
repo_class_dir 'dir'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
subject { TestReposDir::ExampleNamespace }
|
52
|
-
|
53
|
-
describe ".list_files" do
|
54
|
-
before do
|
55
|
-
expect(Ronin::Repos).to receive(:list_files).and_return(
|
56
|
-
Set.new(
|
57
|
-
%w[
|
58
|
-
file1.rb
|
59
|
-
file2.rb
|
60
|
-
]
|
61
|
-
)
|
62
|
-
)
|
63
|
-
end
|
64
|
-
|
65
|
-
it "must list the modules in the .class_dir and in all .repo_class_dir" do
|
66
|
-
expect(subject.list_files).to eq(
|
67
|
-
%w[
|
68
|
-
file1
|
69
|
-
file2
|
70
|
-
only_in_class_dir
|
71
|
-
]
|
72
|
-
)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe ".path_for" do
|
77
|
-
context "when the module name exists in the .class_dir" do
|
78
|
-
it "must return the path to the module file in .class_dir" do
|
79
|
-
expect(subject.path_for('only_in_class_dir')).to eq(
|
80
|
-
File.join(subject.class_dir,'only_in_class_dir.rb')
|
81
|
-
)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "when the module name exists in one of the installed repos" do
|
86
|
-
it "must call Repos.find_file with the .repo_class_dir and module file name" do
|
87
|
-
expect(Ronin::Repos).to receive(:find_file).with(
|
88
|
-
File.join(subject.repo_class_dir,'file.rb')
|
89
|
-
).and_return("/path/to/#{subject.repo_class_dir}/file.rb")
|
90
|
-
|
91
|
-
expect(subject.path_for('file')).to eq(
|
92
|
-
"/path/to/#{subject.repo_class_dir}/file.rb"
|
93
|
-
)
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/spec/repos_spec.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/repos'
|
3
|
-
|
4
|
-
describe Ronin::Repos do
|
5
|
-
it "should have a version" do
|
6
|
-
expect(subject.const_defined?('VERSION')).to be(true)
|
7
|
-
end
|
8
|
-
|
9
|
-
let(:cache_dir) { described_class.class_variable_get('@@cache_dir') }
|
10
|
-
|
11
|
-
describe "@@cache_dir" do
|
12
|
-
subject { cache_dir }
|
13
|
-
|
14
|
-
it "must be a CacheDir pointing to ~/.cache/ronin-repos" do
|
15
|
-
expect(subject).to be_kind_of(CacheDir)
|
16
|
-
expect(subject.path).to eq(File.expand_path("~/.cache/ronin-repos"))
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ".find_file" do
|
21
|
-
let(:relative_path) { 'file.txt' }
|
22
|
-
let(:matches) do
|
23
|
-
[
|
24
|
-
"/path/to/repo1/file.txt",
|
25
|
-
"/path/to/repo2/file.txt"
|
26
|
-
]
|
27
|
-
end
|
28
|
-
|
29
|
-
it "must call @@cache_dir.find_file" do
|
30
|
-
expect(cache_dir).to receive(:find_file).with(relative_path).and_return(matches)
|
31
|
-
|
32
|
-
expect(subject.find_file(relative_path)).to be(matches)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe ".glob" do
|
37
|
-
let(:pattern) { 'dir/*.txt' }
|
38
|
-
let(:matches) do
|
39
|
-
[
|
40
|
-
"/path/to/repo1/dir/file.txt",
|
41
|
-
"/path/to/repo2/dir/file.txt"
|
42
|
-
]
|
43
|
-
end
|
44
|
-
|
45
|
-
it "must call @@cache_dir.glob" do
|
46
|
-
expect(cache_dir).to receive(:glob).with(pattern).and_return(matches)
|
47
|
-
|
48
|
-
expect(subject.glob(pattern)).to be(matches)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe ".list_files" do
|
53
|
-
let(:pattern) { 'dir/*.txt' }
|
54
|
-
let(:files) do
|
55
|
-
Set[
|
56
|
-
"dir/file.txt",
|
57
|
-
"dir/file.txt"
|
58
|
-
]
|
59
|
-
end
|
60
|
-
|
61
|
-
it "must call @@cache_dir.list_files" do
|
62
|
-
expect(cache_dir).to receive(:list_files).with(pattern).and_return(files)
|
63
|
-
|
64
|
-
expect(subject.list_files(pattern)).to be(files)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
data/spec/repository_spec.rb
DELETED
@@ -1,415 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'ronin/repos/repository'
|
3
|
-
|
4
|
-
describe Ronin::Repos::Repository do
|
5
|
-
let(:fixtures_dir) { File.expand_path(File.join(__dir__,'fixtures')) }
|
6
|
-
|
7
|
-
let(:name) { 'repo1' }
|
8
|
-
let(:path) { File.join(fixtures_dir,'cache',name) }
|
9
|
-
|
10
|
-
subject { described_class.new(path) }
|
11
|
-
|
12
|
-
describe "#initialize" do
|
13
|
-
it "must set #path" do
|
14
|
-
expect(subject.path).to eq(path)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "must set #name based on #path" do
|
18
|
-
expect(subject.name).to eq(File.basename(path))
|
19
|
-
end
|
20
|
-
|
21
|
-
context "when the path does not exist" do
|
22
|
-
let(:path) { '/path/does/not/exist' }
|
23
|
-
|
24
|
-
it do
|
25
|
-
expect {
|
26
|
-
described_class.new(path)
|
27
|
-
}.to raise_error(RepositoryNotFound,"repository does not exist: #{path.inspect}")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when the path is not a directory" do
|
32
|
-
let(:path) { __FILE__ }
|
33
|
-
|
34
|
-
it do
|
35
|
-
expect {
|
36
|
-
described_class.new(path)
|
37
|
-
}.to raise_error(RepositoryNotFound,"path is not a directory: #{path.inspect}")
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ".clone" do
|
43
|
-
let(:uri) { 'https://github.com/example/repo.git' }
|
44
|
-
|
45
|
-
subject { described_class }
|
46
|
-
|
47
|
-
it "must call `git clone` the URI to the given path and return a Repository" do
|
48
|
-
expect(subject).to receive(:system).with(
|
49
|
-
'git', 'clone', uri, path
|
50
|
-
).and_return(true)
|
51
|
-
|
52
|
-
repo = subject.clone(uri,path)
|
53
|
-
|
54
|
-
expect(repo).to be_kind_of(described_class)
|
55
|
-
expect(repo.path).to eq(path)
|
56
|
-
end
|
57
|
-
|
58
|
-
context "when a depth: keyword argument is given" do
|
59
|
-
let(:depth) { 1 }
|
60
|
-
|
61
|
-
it "must `git clone --depth` with the given depth and URI to the given path)" do
|
62
|
-
expect(subject).to receive(:system).with(
|
63
|
-
'git', 'clone', '--depth', depth.to_s, uri, path
|
64
|
-
).and_return(true)
|
65
|
-
|
66
|
-
subject.clone(uri,path, depth: depth)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context "when system() returns nil" do
|
71
|
-
it do
|
72
|
-
allow(subject).to receive(:system).and_return(nil)
|
73
|
-
|
74
|
-
expect {
|
75
|
-
subject.clone(uri,path)
|
76
|
-
}.to raise_error(CommandNotInstalled,"git is not installed")
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context "when system() returns false" do
|
81
|
-
it do
|
82
|
-
allow(subject).to receive(:system).and_return(false)
|
83
|
-
|
84
|
-
expect {
|
85
|
-
subject.clone(uri,path)
|
86
|
-
}.to raise_error(CommandFailed,"command failed: git clone #{uri} #{path}")
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
describe ".install" do
|
92
|
-
let(:uri) { 'https://github.com/example/repo.git' }
|
93
|
-
|
94
|
-
subject { described_class }
|
95
|
-
|
96
|
-
it "must `git clone` the URI and the given path and return a Repository" do
|
97
|
-
expect(subject).to receive(:system).with(
|
98
|
-
'git', 'clone', uri, path
|
99
|
-
).and_return(true)
|
100
|
-
|
101
|
-
repo = subject.install(uri,path)
|
102
|
-
|
103
|
-
expect(repo).to be_kind_of(described_class)
|
104
|
-
expect(repo.path).to eq(path)
|
105
|
-
end
|
106
|
-
|
107
|
-
context "when the branch: keyword argument is given" do
|
108
|
-
let(:branch) { 'foo' }
|
109
|
-
|
110
|
-
it "must `git clone` the URI to the given path and then `git checkout` the branch)" do
|
111
|
-
expect(subject).to receive(:system).with(
|
112
|
-
'git', 'clone', uri, path
|
113
|
-
).and_return(true)
|
114
|
-
|
115
|
-
expect_any_instance_of(described_class).to receive(:system).with(
|
116
|
-
'git', 'checkout', branch
|
117
|
-
).and_return(true)
|
118
|
-
|
119
|
-
subject.install(uri,path, branch: branch)
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context "when the tag: keyword argument is given" do
|
124
|
-
let(:tag) { 'v1.0.0' }
|
125
|
-
|
126
|
-
it "must `git clone` the URI to the given path and then `git checkout` the tag" do
|
127
|
-
expect(subject).to receive(:system).with(
|
128
|
-
'git', 'clone', uri, path
|
129
|
-
).and_return(true)
|
130
|
-
|
131
|
-
expect_any_instance_of(described_class).to receive(:system).with(
|
132
|
-
'git', 'checkout', tag
|
133
|
-
).and_return(true)
|
134
|
-
|
135
|
-
subject.install(uri,path, tag: tag)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
describe "#pull" do
|
141
|
-
it "must `git pull` from 'origin'" do
|
142
|
-
expect(subject).to receive(:system).with(
|
143
|
-
'git', 'pull', 'origin'
|
144
|
-
).and_return(true)
|
145
|
-
|
146
|
-
subject.pull
|
147
|
-
end
|
148
|
-
|
149
|
-
context "when the remote: keyword argument is given" do
|
150
|
-
let(:remote) { :backup }
|
151
|
-
|
152
|
-
it "must `git pull` from the given remote" do
|
153
|
-
expect(subject).to receive(:system).with(
|
154
|
-
'git', 'pull', remote.to_s
|
155
|
-
).and_return(true)
|
156
|
-
|
157
|
-
subject.pull(remote: remote)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
context "when the branch: keyword argument is given" do
|
162
|
-
let(:branch) { 'foo' }
|
163
|
-
|
164
|
-
it "must `git pull` from 'origin' and the given branch" do
|
165
|
-
expect(subject).to receive(:system).with(
|
166
|
-
'git', 'pull', 'origin', branch
|
167
|
-
).and_return(true)
|
168
|
-
|
169
|
-
subject.pull(branch: branch)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
context "when the `tags: true` is given" do
|
174
|
-
it "must `git pull` from 'origin' and pull down any tags" do
|
175
|
-
expect(subject).to receive(:system).with(
|
176
|
-
'git', 'pull', '--tags', 'origin'
|
177
|
-
).and_return(true)
|
178
|
-
|
179
|
-
subject.pull(tags: true)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
context "when system() returns nil" do
|
184
|
-
it do
|
185
|
-
allow(subject).to receive(:system).and_return(nil)
|
186
|
-
|
187
|
-
expect {
|
188
|
-
subject.pull
|
189
|
-
}.to raise_error(CommandNotInstalled,"git is not installed")
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
context "when system() returns false" do
|
194
|
-
it do
|
195
|
-
allow(subject).to receive(:system).and_return(false)
|
196
|
-
|
197
|
-
expect {
|
198
|
-
subject.pull
|
199
|
-
}.to raise_error(CommandFailed,"command failed: git pull origin")
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
describe "#checkout" do
|
205
|
-
let(:branch) { 'foo' }
|
206
|
-
|
207
|
-
it "must `git checkout` the given branch" do
|
208
|
-
expect(subject).to receive(:system).with(
|
209
|
-
'git', 'checkout', branch
|
210
|
-
).and_return(true)
|
211
|
-
|
212
|
-
subject.checkout(branch)
|
213
|
-
end
|
214
|
-
|
215
|
-
context "when system() returns nil" do
|
216
|
-
it do
|
217
|
-
allow(subject).to receive(:system).and_return(nil)
|
218
|
-
|
219
|
-
expect {
|
220
|
-
subject.checkout(branch)
|
221
|
-
}.to raise_error(CommandNotInstalled,"git is not installed")
|
222
|
-
end
|
223
|
-
end
|
224
|
-
|
225
|
-
context "when system() returns false" do
|
226
|
-
it do
|
227
|
-
allow(subject).to receive(:system).and_return(false)
|
228
|
-
|
229
|
-
expect {
|
230
|
-
subject.checkout(branch)
|
231
|
-
}.to raise_error(CommandFailed,"command failed: git checkout #{branch}")
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
|
-
describe "#update" do
|
237
|
-
it "must `git pull` from 'origin' and pull down any tags" do
|
238
|
-
expect(subject).to receive(:system).with(
|
239
|
-
'git', 'pull', '--tags', 'origin'
|
240
|
-
).and_return(true)
|
241
|
-
|
242
|
-
subject.update
|
243
|
-
end
|
244
|
-
|
245
|
-
context "when the branch: keyword argument is given" do
|
246
|
-
let(:branch) { 'foo' }
|
247
|
-
|
248
|
-
it "must `git pull` from 'origin' and the given branch and then `git checkout` the branch" do
|
249
|
-
expect(subject).to receive(:system).with(
|
250
|
-
'git', 'pull', 'origin', branch
|
251
|
-
).and_return(true)
|
252
|
-
|
253
|
-
expect(subject).to receive(:system).with(
|
254
|
-
'git', 'checkout', branch
|
255
|
-
).and_return(true)
|
256
|
-
|
257
|
-
subject.update(branch: branch)
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
context "when the tag: keyword argument is given" do
|
262
|
-
let(:tag) { 'v1.0.0' }
|
263
|
-
|
264
|
-
it "must `git pull --tags` from 'origin' and then `git checkout` the given tag" do
|
265
|
-
expect(subject).to receive(:system).with(
|
266
|
-
'git', 'pull', '--tags', 'origin'
|
267
|
-
).and_return(true)
|
268
|
-
|
269
|
-
expect(subject).to receive(:system).with(
|
270
|
-
'git', 'checkout', tag
|
271
|
-
).and_return(true)
|
272
|
-
|
273
|
-
subject.update(tag: tag)
|
274
|
-
end
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
describe "#delete" do
|
279
|
-
it "must call FileUtils.rm_rf on the path" do
|
280
|
-
expect(FileUtils).to receive(:rm_rf).with(path)
|
281
|
-
|
282
|
-
subject.delete
|
283
|
-
end
|
284
|
-
end
|
285
|
-
|
286
|
-
describe "#join" do
|
287
|
-
let(:relative_path) { 'file1.txt' }
|
288
|
-
|
289
|
-
it "must return the absolute path with respect to the repository" do
|
290
|
-
expect(subject.join(relative_path)).to eq(
|
291
|
-
File.join(path,relative_path)
|
292
|
-
)
|
293
|
-
end
|
294
|
-
end
|
295
|
-
|
296
|
-
describe "#has_file?" do
|
297
|
-
context "when the repository contains the file" do
|
298
|
-
let(:relative_path) { 'file1.txt' }
|
299
|
-
|
300
|
-
it "must return the absolute path to the file" do
|
301
|
-
expect(subject.has_file?(relative_path)).to be(true)
|
302
|
-
end
|
303
|
-
end
|
304
|
-
|
305
|
-
context "when the relative path does not exist within the repository" do
|
306
|
-
let(:relative_path) { 'does/not/exist.txt' }
|
307
|
-
|
308
|
-
it "must return false" do
|
309
|
-
expect(subject.has_file?(relative_path)).to be(false)
|
310
|
-
end
|
311
|
-
end
|
312
|
-
end
|
313
|
-
|
314
|
-
describe "#has_directory?" do
|
315
|
-
context "when the repository contains the directory" do
|
316
|
-
let(:relative_path) { 'dir' }
|
317
|
-
|
318
|
-
it "must return the absolute path to the directory" do
|
319
|
-
expect(subject.has_directory?(relative_path)).to be(true)
|
320
|
-
end
|
321
|
-
end
|
322
|
-
|
323
|
-
context "when the relative path does not exist within the repository" do
|
324
|
-
let(:relative_path) { 'does/not/exist' }
|
325
|
-
|
326
|
-
it "must return false" do
|
327
|
-
expect(subject.has_directory?(relative_path)).to be(false)
|
328
|
-
end
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
describe "#find_file" do
|
333
|
-
context "when the relative path exists within the repository" do
|
334
|
-
let(:relative_path) { 'file1.txt' }
|
335
|
-
|
336
|
-
it "must return the absolute path to the file" do
|
337
|
-
expect(subject.find_file(relative_path)).to eq(
|
338
|
-
File.join(path,relative_path)
|
339
|
-
)
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
context "when the relative path does not exist within the repository" do
|
344
|
-
let(:relative_path) { 'does/not/exist.txt' }
|
345
|
-
|
346
|
-
it "must return nil" do
|
347
|
-
expect(subject.find_file(relative_path)).to be(nil)
|
348
|
-
end
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
describe "#glob" do
|
353
|
-
context "when the pattern matches files within the repository" do
|
354
|
-
let(:pattern) { 'dir/*.txt' }
|
355
|
-
|
356
|
-
it "must return the absolute path to the file" do
|
357
|
-
expect(subject.glob(pattern)).to eq(
|
358
|
-
Dir[File.join(path,pattern)]
|
359
|
-
)
|
360
|
-
end
|
361
|
-
|
362
|
-
context "when a block is given" do
|
363
|
-
it "must yield the matching absolute paths" do
|
364
|
-
expect { |b|
|
365
|
-
subject.glob(pattern,&b)
|
366
|
-
}.to yield_successive_args(
|
367
|
-
*Dir[File.join(path,pattern)]
|
368
|
-
)
|
369
|
-
end
|
370
|
-
end
|
371
|
-
end
|
372
|
-
|
373
|
-
context "when the relative path does not exist within the repository" do
|
374
|
-
let(:pattern) { 'does/not/exist/*.txt' }
|
375
|
-
|
376
|
-
it "must return []" do
|
377
|
-
expect(subject.glob(pattern)).to eq([])
|
378
|
-
end
|
379
|
-
|
380
|
-
context "when a block is given" do
|
381
|
-
it "must not yield" do
|
382
|
-
expect { |b|
|
383
|
-
subject.glob(pattern,&b)
|
384
|
-
}.to_not yield_control
|
385
|
-
end
|
386
|
-
end
|
387
|
-
end
|
388
|
-
end
|
389
|
-
|
390
|
-
describe "#list_files" do
|
391
|
-
context "when given no arguments" do
|
392
|
-
it "must list every file within the repository's directory" do
|
393
|
-
expect(subject.list_files).to eq(
|
394
|
-
%w[
|
395
|
-
dir/file1.txt
|
396
|
-
file1.txt
|
397
|
-
file2.txt
|
398
|
-
]
|
399
|
-
)
|
400
|
-
end
|
401
|
-
end
|
402
|
-
|
403
|
-
context "when given a glob pattern" do
|
404
|
-
it "must list only the files that match the glob pattern" do
|
405
|
-
expect(subject.list_files('dir/*.txt')).to eq(%w[dir/file1.txt])
|
406
|
-
end
|
407
|
-
end
|
408
|
-
end
|
409
|
-
|
410
|
-
describe "#to_s" do
|
411
|
-
it "must return the repository name" do
|
412
|
-
expect(subject.to_s).to eq(name)
|
413
|
-
end
|
414
|
-
end
|
415
|
-
end
|