local_pac 0.1.13 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/{LICENSE.txt → LICENSE.md} +0 -0
- data/README.DEVELOPER.md +7 -0
- data/README.md +138 -2
- data/Rakefile +16 -8
- data/app/controllers/application_controller.rb +5 -3
- data/app/controllers/assets_controller.rb +3 -2
- data/app/controllers/file_serve_controller.rb +3 -6
- data/app/controllers/lookup_controller.rb +9 -9
- data/app/locales/en.yml +1 -0
- data/app/views/application.haml +1 -1
- data/bin/local_pac +49 -64
- data/config.ru +24 -7
- data/features/initializer.feature +4 -4
- data/features/show_status.feature +2 -2
- data/files/config.yaml +2 -2
- data/files/example-config.erb +10 -12
- data/files/git-hook.erb +1 -0
- data/lib/local_pac.rb +22 -5
- data/lib/local_pac/actions/create_directory.rb +2 -2
- data/lib/local_pac/actions/create_file.rb +8 -2
- data/lib/local_pac/actions/create_repository.rb +6 -8
- data/lib/local_pac/actions/get_system_information.rb +78 -0
- data/lib/local_pac/actions/print_newline.rb +19 -0
- data/lib/local_pac/actions/print_title.rb +41 -0
- data/lib/local_pac/actions/reload_configuration.rb +21 -0
- data/lib/local_pac/actions/reload_local_storage.rb +22 -0
- data/lib/local_pac/actions/send_signal.rb +32 -0
- data/lib/local_pac/actions/show_config.rb +10 -0
- data/lib/local_pac/actions/show_process_information.rb +94 -0
- data/lib/local_pac/application_status.rb +34 -0
- data/lib/local_pac/cli/helper.rb +34 -0
- data/lib/local_pac/cli/reload.rb +36 -0
- data/lib/local_pac/config.rb +15 -13
- data/lib/local_pac/exceptions.rb +6 -0
- data/lib/local_pac/file.rb +32 -0
- data/lib/local_pac/git.rb +20 -6
- data/lib/local_pac/git_repository.rb +40 -28
- data/lib/local_pac/git_storage.rb +60 -0
- data/lib/local_pac/initializer.rb +8 -5
- data/lib/local_pac/local_storage.rb +3 -4
- data/lib/local_pac/main.rb +2 -2
- data/lib/local_pac/{null_pac_file.rb → null_file.rb} +5 -1
- data/lib/local_pac/server.rb +1 -1
- data/lib/local_pac/spec_helper_file_server.rb +6 -5
- data/lib/local_pac/template_file.rb +1 -1
- data/lib/local_pac/template_repository.rb +3 -3
- data/lib/local_pac/version.rb +1 -1
- data/local_pac.gemspec +13 -9
- data/script/console +1 -1
- data/share/archlinux/PKGBUILD +4 -1
- data/share/archlinux/config.yaml +1 -1
- data/spec/actions/create_directory_spec.rb +3 -3
- data/spec/actions/create_file_spec.rb +23 -2
- data/spec/actions/create_repository_spec.rb +3 -3
- data/spec/actions/get_system_information_spec.rb +22 -0
- data/spec/actions/print_new_line_spec.rb +36 -0
- data/spec/actions/print_title_spec.rb +50 -0
- data/spec/actions/reload_configuration_spec.rb +38 -0
- data/spec/actions/reload_repository_spec.rb +35 -0
- data/spec/actions/send_signal_spec.rb +58 -0
- data/spec/actions/show_config_spec.rb +22 -0
- data/spec/actions/show_process_information_spec.rb +45 -0
- data/spec/application_status_spec.rb +40 -0
- data/spec/config_spec.rb +11 -11
- data/spec/features/fetch_proxy_pac_spec.rb +11 -10
- data/spec/features/lookup_proxy_spec.rb +32 -40
- data/spec/file_spec.rb +56 -0
- data/spec/git_spec.rb +13 -7
- data/spec/git_storage_spec.rb +64 -0
- data/spec/initializer_spec.rb +7 -5
- data/spec/{null_pac_file_spec.rb → null_file_spec.rb} +6 -6
- data/spec/proxy_pac/pac_result_html_stylist_spec.rb +3 -2
- data/spec/runner_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/spec_helper_features.rb +2 -2
- data/spec/support/config.rb +5 -0
- data/spec/support/filesystem.rb +1 -1
- data/spec/support/git.rb +23 -2
- data/spec/support/helper_features.rb +23 -0
- data/spec/template_repository_spec.rb +2 -2
- metadata +113 -32
- data/lib/local_pac/git_file.rb +0 -18
- data/lib/local_pac/pac_file.rb +0 -27
- data/spec/git_repository_spec.rb +0 -60
- data/spec/pac_file_spec.rb +0 -44
data/lib/local_pac/git_file.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module LocalPac
|
3
|
-
class GitFile
|
4
|
-
attr_reader :path, :name, :content, :sha
|
5
|
-
|
6
|
-
def initialize(data, git_dir = nil)
|
7
|
-
data = data.split(" ")
|
8
|
-
@path = data.last
|
9
|
-
@sha = data[2]
|
10
|
-
@name = path.sub(/.pac$/, '').camelize.downcase.to_sym
|
11
|
-
@content = Git.cat_file(@sha, git_dir).join("\n")
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_s
|
15
|
-
"#{name}: #{path} (#{content})"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/local_pac/pac_file.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module LocalPac
|
3
|
-
class PacFile
|
4
|
-
attr_reader :file
|
5
|
-
attr_accessor :compressed_content
|
6
|
-
|
7
|
-
def initialize(file)
|
8
|
-
@file = file
|
9
|
-
end
|
10
|
-
|
11
|
-
def name
|
12
|
-
file.name
|
13
|
-
end
|
14
|
-
|
15
|
-
def content
|
16
|
-
file.content
|
17
|
-
end
|
18
|
-
|
19
|
-
def nil?
|
20
|
-
false
|
21
|
-
end
|
22
|
-
|
23
|
-
def prepare(handler)
|
24
|
-
handler.prepare(self)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/spec/git_repository_spec.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe GitRepository do
|
5
|
-
let(:git_repo) { 'git_repo' }
|
6
|
-
let(:compressor) do
|
7
|
-
Class.new do
|
8
|
-
def prepare(file)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:creator) do
|
14
|
-
Class.new do
|
15
|
-
attr_reader :file
|
16
|
-
attr_accessor :compressed_content
|
17
|
-
def initialize(file)
|
18
|
-
@file = file
|
19
|
-
end
|
20
|
-
|
21
|
-
def name
|
22
|
-
file.name
|
23
|
-
end
|
24
|
-
|
25
|
-
def content
|
26
|
-
file.content
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context '#files' do
|
32
|
-
it 'returns a list of files matching pattern' do
|
33
|
-
git_init(git_repo)
|
34
|
-
create_file(File.join(git_repo, 'file1.txt'))
|
35
|
-
git_add(git_repo, 'file1.txt')
|
36
|
-
|
37
|
-
file2 = create_file(File.join(git_repo, 'file2.pac'), 'data file2.pac')
|
38
|
-
git_add(git_repo, 'file2.pac')
|
39
|
-
|
40
|
-
git_commit(git_repo)
|
41
|
-
|
42
|
-
repo = GitRepository.new(File.join(working_directory, git_repo, '.git'), compressor, creator)
|
43
|
-
expect(repo[:file2].content).to eq(File.read(file2))
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'supports directories as well' do
|
47
|
-
git_init(git_repo)
|
48
|
-
create_file(File.join(git_repo, 'file1.txt'))
|
49
|
-
git_add(git_repo, 'file1.txt')
|
50
|
-
|
51
|
-
file2 = create_file(File.join(git_repo, 'dir', 'file2.pac'), 'data file2.pac')
|
52
|
-
git_add(git_repo, 'dir/file2.pac')
|
53
|
-
|
54
|
-
git_commit(git_repo)
|
55
|
-
|
56
|
-
repo = GitRepository.new(File.join(working_directory, git_repo, '.git'), compressor, creator)
|
57
|
-
expect(repo['dir::file2'.to_sym].content).to eq(File.read(file2))
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/spec/pac_file_spec.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe PacFile do
|
5
|
-
context '#name' do
|
6
|
-
it 'has a name' do
|
7
|
-
git_file = double('GitFile')
|
8
|
-
allow(git_file).to receive(:name).and_return(:file1)
|
9
|
-
|
10
|
-
file = PacFile.new(git_file)
|
11
|
-
expect(file.name).to eq(:file1)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
context '#content' do
|
16
|
-
it 'returns the content of file' do
|
17
|
-
git_file = double('GitFile')
|
18
|
-
allow(git_file).to receive(:content).and_return('asdf')
|
19
|
-
|
20
|
-
file = PacFile.new(git_file)
|
21
|
-
expect(file.content).to eq('asdf')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context '#nil?' do
|
26
|
-
it 'is always false' do
|
27
|
-
git_file = double('GitFile')
|
28
|
-
file = PacFile.new(git_file)
|
29
|
-
expect(file.nil?).to be_false
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context '#compressed_content' do
|
34
|
-
it 'uses an external handler to compress content' do
|
35
|
-
handler = double('handler')
|
36
|
-
expect(handler).to receive(:prepare)
|
37
|
-
|
38
|
-
git_file = double('GitFile')
|
39
|
-
allow(git_file).to receive(:content).and_return('asdf')
|
40
|
-
file = PacFile.new(git_file)
|
41
|
-
file.prepare(handler)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|