local_pac 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -9,9 +9,9 @@ module LocalPac
9
9
  public
10
10
 
11
11
  def initialize(path, options = {}, fs_engine = FileUtils)
12
- @path = path
13
- @options = options
14
- @fs_engine = fs_engine
12
+ @path = File.expand_path(path)
13
+ @options = options
14
+ @fs_engine = fs_engine
15
15
  end
16
16
 
17
17
  def run
@@ -10,7 +10,7 @@ module LocalPac
10
10
 
11
11
  def initialize(name, destination, data, options = {}, engine = ErbGenerator, repository = TemplateRepository.new)
12
12
  @name = name
13
- @destination = destination
13
+ @destination = File.expand_path(destination)
14
14
  @data = data
15
15
  @options = options
16
16
  @engine = engine
@@ -9,7 +9,7 @@ module LocalPac
9
9
  public
10
10
 
11
11
  def initialize(path, options = {}, vcs_engine = LocalPac::Git)
12
- @path = path
12
+ @path = File.expand_path(path)
13
13
  @options = options
14
14
  @vcs_engine = vcs_engine
15
15
  end
@@ -37,16 +37,14 @@ module LocalPac
37
37
  end
38
38
 
39
39
  def pac_files
40
- Dir.chdir(storage_path) do
41
- LocalPac.ui_logger.debug "I'm using the following storage path: \"#{storage_path}\"."
40
+ LocalPac.ui_logger.debug "I'm using the following storage path: \"#{storage_path}\"."
42
41
 
43
- files = Git.ls_tree(storage_path).collect do |l|
44
- GitFile.new(l)
45
- end
46
-
47
- LocalPac.ui_logger.debug "Found the following files: \"#{files.join(", ")}\"."
48
- files
42
+ files = Git.ls_tree(storage_path).collect do |l|
43
+ GitFile.new(l, storage_path)
49
44
  end
45
+
46
+ LocalPac.ui_logger.debug "Found the following files: \"#{files.join(", ")}\"."
47
+ files
50
48
  end
51
49
  end
52
50
  end
@@ -5,8 +5,6 @@ module LocalPac
5
5
 
6
6
  attr_reader :config, :vcs, :options
7
7
 
8
- include Fileable
9
-
10
8
  public
11
9
 
12
10
  def initialize(options = {}, config = LocalPac.config)
@@ -1,7 +1,6 @@
1
1
  module LocalPac
2
2
  class Logger
3
3
  def initialize(path)
4
- FileUtils.mkdir_p File.dirname(path)
5
4
  @logger = ::Logger.new(path)
6
5
  end
7
6
 
@@ -1,4 +1,4 @@
1
1
  #main LocalPac
2
2
  module LocalPac
3
- VERSION = '0.1.9'
3
+ VERSION = '0.1.10'
4
4
  end
data/lib/local_pac.rb CHANGED
@@ -23,7 +23,6 @@ require 'local_pac/git'
23
23
  require 'local_pac/git_file'
24
24
  require 'local_pac/git_repository'
25
25
  require 'local_pac/config'
26
- require 'local_pac/fileable'
27
26
  require 'local_pac/runner'
28
27
  require 'local_pac/exceptions'
29
28
  require 'local_pac/erb_generator'
@@ -43,5 +43,17 @@ describe Actions::CreateDirectory do
43
43
 
44
44
  expect(result).to include('Creating repository')
45
45
  end
46
+
47
+ it 'resolves ~' do
48
+ action = with_environment 'HOME' => working_directory do
49
+ Actions::CreateDirectory.new('~/file')
50
+ end
51
+
52
+ silence(:stderr) do
53
+ action.run
54
+ end
55
+
56
+ expect(path_exists?('file')).to be_true
57
+ end
46
58
  end
47
59
  end
@@ -91,5 +91,30 @@ describe Actions::CreateFile do
91
91
 
92
92
  expect(result).to include('Creating file')
93
93
  end
94
+
95
+ it 'resolves ~' do
96
+ repository = double('TemplateRepository')
97
+ expect(repository).to receive(:find).with(:template)
98
+
99
+ data = double('Data')
100
+
101
+ engine_klass = Class.new do
102
+ def initialize(data)
103
+ end
104
+
105
+ def compile(template, destination)
106
+ end
107
+ end
108
+
109
+ action = with_environment 'HOME' => working_directory do
110
+ Actions::CreateFile.new(:template, '~/file', data, { force: true }, engine_klass, repository)
111
+ end
112
+
113
+ silence(:stderr) do
114
+ action.run
115
+ end
116
+
117
+ expect(path_exists?('file')).to be_true
118
+ end
94
119
  end
95
120
  end
@@ -43,5 +43,17 @@ describe Actions::CreateRepository do
43
43
 
44
44
  expect(result).to include('Creating repository')
45
45
  end
46
+
47
+ it 'resolves ~' do
48
+ action = with_environment 'HOME' => working_directory do
49
+ Actions::CreateRepository.new('~/repo')
50
+ end
51
+
52
+ silence(:stderr) do
53
+ action.run
54
+ end
55
+
56
+ expect(path_exists?('repo')).to be_true
57
+ end
46
58
  end
47
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: local_pac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -165,6 +165,7 @@ files:
165
165
  - features/fetch_proxy_pac.feature
166
166
  - features/initializer.feature
167
167
  - features/show_config.feature
168
+ - features/show_known_pacfiles.feature
168
169
  - features/support/env.rb
169
170
  - files/config.yaml
170
171
  - files/git-hook.erb
@@ -178,7 +179,6 @@ files:
178
179
  - lib/local_pac/erb_generator.rb
179
180
  - lib/local_pac/exceptions.rb
180
181
  - lib/local_pac/file_server.rb
181
- - lib/local_pac/fileable.rb
182
182
  - lib/local_pac/git.rb
183
183
  - lib/local_pac/git_file.rb
184
184
  - lib/local_pac/git_repository.rb
@@ -262,6 +262,7 @@ test_files:
262
262
  - features/fetch_proxy_pac.feature
263
263
  - features/initializer.feature
264
264
  - features/show_config.feature
265
+ - features/show_known_pacfiles.feature
265
266
  - features/support/env.rb
266
267
  - spec/actions/create_directory_spec.rb
267
268
  - spec/actions/create_file_spec.rb
@@ -1,12 +0,0 @@
1
- # encoding: utf-8
2
- module LocalPac
3
- module Fileable
4
- def mkdir_p(*args)
5
- FileUtils.mkdir_p(*args)
6
- end
7
-
8
- def exist?(*args)
9
- File.exist?(*args)
10
- end
11
- end
12
- end