fig 0.1.7 → 0.1.8
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/bin/fig +3 -2
- data/lib/fig/environment.rb +1 -1
- data/lib/fig/grammar.treetop +1 -1
- data/lib/fig/options.rb +4 -1
- data/lib/fig/repository.rb +10 -2
- data/spec/fig_spec.rb +4 -4
- metadata +1 -1
data/bin/fig
CHANGED
@@ -39,7 +39,7 @@ vars = {}
|
|
39
39
|
ENV.each {|key,value| vars[key]=value }
|
40
40
|
|
41
41
|
remote_url = nil
|
42
|
-
if options[:update] || options[:publish]
|
42
|
+
if options[:update] || options[:publish] || options[:update_if_missing]
|
43
43
|
remote_url = ENV['FIG_REMOTE_URL']
|
44
44
|
if remote_url.nil?
|
45
45
|
$stderr.puts "Please define the FIG_REMOTE_URL environment variable"
|
@@ -57,7 +57,7 @@ if options[:publish]
|
|
57
57
|
end
|
58
58
|
|
59
59
|
os = OS.new
|
60
|
-
repos = Repository.new(os, File.expand_path(File.join(options[:home], 'repos')), remote_url, remote_user)
|
60
|
+
repos = Repository.new(os, File.expand_path(File.join(options[:home], 'repos')), remote_url, remote_user, options[:update], options[:update_if_missing])
|
61
61
|
env = Environment.new(os, repos, vars)
|
62
62
|
|
63
63
|
options[:modifiers].each do |modifier|
|
@@ -111,6 +111,7 @@ if options[:list]
|
|
111
111
|
repos.list_packages.sort.each do |item|
|
112
112
|
puts item
|
113
113
|
end
|
114
|
+
exit 0
|
114
115
|
end
|
115
116
|
|
116
117
|
def shell_exec(cmd)
|
data/lib/fig/environment.rb
CHANGED
data/lib/fig/grammar.treetop
CHANGED
@@ -88,7 +88,7 @@ grammar Fig
|
|
88
88
|
end
|
89
89
|
|
90
90
|
rule path
|
91
|
-
"append" ws name:[a-zA-Z0-9]+ "=" value:[@a-zA-Z0-9/\-\\._]+ ws {
|
91
|
+
("append" / "path" / "add") ws name:[a-zA-Z0-9]+ "=" value:[@a-zA-Z0-9/\-\\._]+ ws {
|
92
92
|
def to_config_statement
|
93
93
|
Path.new(name.text_value, value.text_value)
|
94
94
|
end
|
data/lib/fig/options.rb
CHANGED
@@ -27,6 +27,9 @@ module Fig
|
|
27
27
|
options[:update] = false
|
28
28
|
opts.on('-u', '--update', 'check remote repository for updates') { options[:update] = true; options[:retrieve] = true }
|
29
29
|
|
30
|
+
options[:update_if_missing] = false
|
31
|
+
opts.on('-m', '--update-if-missing', 'check for updates only if package is missing locally') { options[:update_if_missing] = true; options[:retrieve] = true }
|
32
|
+
|
30
33
|
options[:config] = "default"
|
31
34
|
opts.on('-c', '--config CFG', 'name of configuration to apply') { |config| options[:config] = config }
|
32
35
|
|
@@ -71,7 +74,7 @@ module Fig
|
|
71
74
|
|
72
75
|
options[:input] = nil
|
73
76
|
opts.on('--file FILE', 'fig file to read (use - for stdin)') { |path| options[:input] = path }
|
74
|
-
opts.on('--no-file', 'ignore .fig file in current directory') { |path| options[:input] = :none }
|
77
|
+
opts.on('--no-file', 'ignore package.fig file in current directory') { |path| options[:input] = :none }
|
75
78
|
|
76
79
|
options[:home] = ENV['FIG_HOME'] || File.expand_path("~/.fighome")
|
77
80
|
end
|
data/lib/fig/repository.rb
CHANGED
@@ -2,11 +2,13 @@ require 'fig/parser'
|
|
2
2
|
|
3
3
|
module Fig
|
4
4
|
class Repository
|
5
|
-
def initialize(os, local_repository_dir, remote_repository_url, remote_repository_user=nil)
|
5
|
+
def initialize(os, local_repository_dir, remote_repository_url, remote_repository_user=nil, update=false, update_if_missing=true)
|
6
6
|
@os = os
|
7
7
|
@local_repository_dir = local_repository_dir
|
8
8
|
@remote_repository_url = remote_repository_url
|
9
9
|
@remote_repository_user = remote_repository_user
|
10
|
+
@update = update
|
11
|
+
@update_if_missing = update_if_missing
|
10
12
|
@parser = Parser.new
|
11
13
|
end
|
12
14
|
|
@@ -92,7 +94,9 @@ module Fig
|
|
92
94
|
end
|
93
95
|
|
94
96
|
def load_package(package_name, version_name)
|
95
|
-
|
97
|
+
if @update || (@update_if_missing && package_missing?(package_name, version_name))
|
98
|
+
update_package(package_name, version_name)
|
99
|
+
end
|
96
100
|
read_local_package(package_name, version_name)
|
97
101
|
end
|
98
102
|
|
@@ -194,5 +198,9 @@ module Fig
|
|
194
198
|
def temp_dir_for_package(package_name, version_name)
|
195
199
|
File.join(@local_repository_dir, "tmp")
|
196
200
|
end
|
201
|
+
|
202
|
+
def package_missing?(package_name, version_name)
|
203
|
+
not File.exist?(local_fig_file_for_package(package_name, version_name))
|
204
|
+
end
|
197
205
|
end
|
198
206
|
end
|
data/spec/fig_spec.rb
CHANGED
@@ -52,16 +52,16 @@ describe "Fig" do
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "append environment variable from command line" do
|
55
|
-
fig('-p PATH=foo -g PATH').should == ["#{ENV['PATH']}
|
55
|
+
fig('-p PATH=foo -g PATH').should == ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}",""]
|
56
56
|
end
|
57
57
|
|
58
58
|
it "append environment variable from fig file" do
|
59
59
|
input = <<-END
|
60
60
|
config default
|
61
|
-
|
61
|
+
add PATH=foo
|
62
62
|
end
|
63
63
|
END
|
64
|
-
fig('-g PATH', input).should == ["#{ENV['PATH']}
|
64
|
+
fig('-g PATH', input).should == ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}",""]
|
65
65
|
end
|
66
66
|
|
67
67
|
it "append empty environment variable" do
|
@@ -140,7 +140,7 @@ describe "Fig" do
|
|
140
140
|
include foo/1.2.3
|
141
141
|
end
|
142
142
|
END
|
143
|
-
fig('-
|
143
|
+
fig('-m', input)
|
144
144
|
File.read("tmp/lib2/foo/hello").should == "some library"
|
145
145
|
end
|
146
146
|
end
|