librarian 0.0.26 → 0.1.0.beta.1
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.
- data/.gitignore +0 -3
- data/.travis.yml +7 -0
- data/Gemfile +1 -1
- data/{MIT-LICENSE → LICENSE.txt} +2 -0
- data/README.md +13 -363
- data/lib/librarian/chef/version.rb +5 -0
- data/lib/librarian/cli.rb +1 -0
- data/lib/librarian/environment.rb +8 -2
- data/lib/librarian/mock/environment.rb +6 -1
- data/lib/librarian/mock/version.rb +5 -0
- data/lib/librarian/rspec/support/cli_macro.rb +120 -0
- data/lib/librarian/source/git.rb +1 -1
- data/lib/librarian/source/git/repository.rb +10 -2
- data/lib/librarian/version.rb +1 -1
- data/librarian.gemspec +15 -22
- data/spec/functional/cli_spec.rb +27 -0
- data/spec/functional/source/git/repository_spec.rb +2 -0
- metadata +69 -100
- data/lib/librarian/chef.rb +0 -1
- data/lib/librarian/chef/cli.rb +0 -47
- data/lib/librarian/chef/dsl.rb +0 -16
- data/lib/librarian/chef/environment.rb +0 -27
- data/lib/librarian/chef/extension.rb +0 -9
- data/lib/librarian/chef/integration/knife.rb +0 -46
- data/lib/librarian/chef/manifest_reader.rb +0 -59
- data/lib/librarian/chef/source.rb +0 -4
- data/lib/librarian/chef/source/git.rb +0 -25
- data/lib/librarian/chef/source/github.rb +0 -27
- data/lib/librarian/chef/source/local.rb +0 -69
- data/lib/librarian/chef/source/path.rb +0 -12
- data/lib/librarian/chef/source/site.rb +0 -442
- data/lib/librarian/chef/templates/Cheffile +0 -15
- data/spec/functional/chef/cli_spec.rb +0 -194
- data/spec/functional/chef/source/site_spec.rb +0 -266
- data/spec/integration/chef/source/git_spec.rb +0 -441
- data/spec/integration/chef/source/site_spec.rb +0 -217
- data/spec/support/cli_macro.rb +0 -114
data/spec/support/cli_macro.rb
DELETED
@@ -1,114 +0,0 @@
|
|
1
|
-
require "json"
|
2
|
-
require "pathname"
|
3
|
-
require "securerandom"
|
4
|
-
require "stringio"
|
5
|
-
require "thor"
|
6
|
-
|
7
|
-
require "librarian/helpers"
|
8
|
-
|
9
|
-
module CliMacro
|
10
|
-
|
11
|
-
class FakeShell < Thor::Shell::Basic
|
12
|
-
def stdout
|
13
|
-
@stdout ||= StringIO.new
|
14
|
-
end
|
15
|
-
def stderr
|
16
|
-
@stderr ||= StringIO.new
|
17
|
-
end
|
18
|
-
def stdin
|
19
|
-
raise "unsupported"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class FileMatcher
|
24
|
-
attr_accessor :rel_path, :content, :type, :base_path
|
25
|
-
def initialize(rel_path, content, options = { })
|
26
|
-
self.rel_path = rel_path
|
27
|
-
self.content = content
|
28
|
-
self.type = options[:type]
|
29
|
-
end
|
30
|
-
def full_path
|
31
|
-
@full_path ||= base_path + rel_path
|
32
|
-
end
|
33
|
-
def actual_content
|
34
|
-
@actual_content ||= begin
|
35
|
-
s = full_path.read
|
36
|
-
s = JSON.parse(s) if type == :json
|
37
|
-
s
|
38
|
-
end
|
39
|
-
end
|
40
|
-
def matches?(base_path)
|
41
|
-
base_path = Pathname(base_path) unless Pathname === base_path
|
42
|
-
self.base_path = base_path
|
43
|
-
|
44
|
-
full_path.file? && (!content || actual_content == content)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.included(base)
|
49
|
-
base.instance_exec do
|
50
|
-
let(:project_path) do
|
51
|
-
project_path = Pathname.new(__FILE__).expand_path
|
52
|
-
project_path = project_path.dirname until project_path.join("Rakefile").exist?
|
53
|
-
project_path
|
54
|
-
end
|
55
|
-
let(:tmp) { project_path.join("tmp/spec/cli") }
|
56
|
-
let(:pwd) { tmp + SecureRandom.hex(8) }
|
57
|
-
|
58
|
-
before { tmp.mkpath }
|
59
|
-
before { pwd.mkpath }
|
60
|
-
|
61
|
-
after { tmp.rmtree }
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def cli!(*args)
|
66
|
-
@shell = FakeShell.new
|
67
|
-
@exit_status = Dir.chdir(pwd) do
|
68
|
-
described_class.with_environment do
|
69
|
-
described_class.returning_status do
|
70
|
-
described_class.start args, :shell => @shell
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
def write_file!(path, content)
|
77
|
-
path = pwd.join(path)
|
78
|
-
path.dirname.mkpath
|
79
|
-
path.open("wb"){|f| f.write(content)}
|
80
|
-
end
|
81
|
-
|
82
|
-
def write_json_file!(path, content)
|
83
|
-
write_file! path, JSON.dump(content)
|
84
|
-
end
|
85
|
-
|
86
|
-
def strip_heredoc(text)
|
87
|
-
Librarian::Helpers.strip_heredoc(text)
|
88
|
-
end
|
89
|
-
|
90
|
-
def shell
|
91
|
-
@shell
|
92
|
-
end
|
93
|
-
|
94
|
-
def stdout
|
95
|
-
shell.stdout.string
|
96
|
-
end
|
97
|
-
|
98
|
-
def stderr
|
99
|
-
shell.stderr.string
|
100
|
-
end
|
101
|
-
|
102
|
-
def exit_status
|
103
|
-
@exit_status
|
104
|
-
end
|
105
|
-
|
106
|
-
def have_file(rel_path, content = nil)
|
107
|
-
FileMatcher.new(rel_path, content)
|
108
|
-
end
|
109
|
-
|
110
|
-
def have_json_file(rel_path, content)
|
111
|
-
FileMatcher.new(rel_path, content, :type => :json)
|
112
|
-
end
|
113
|
-
|
114
|
-
end
|