fig 0.1.37 → 0.1.38

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -156,7 +156,7 @@ Configurations other than "default" can be specified using the "-c" option:
156
156
 
157
157
  Now let's say we want to share our little script with the rest of the team by bundling it into a package. The first thing we need to do is specify the location of the remote repository by defining the `FIG_REMOTE_URL` environment variable. If you just want to play around with fig, you can have it point to localhost:
158
158
 
159
- $ export FIG_REMOTE_URL=ssh://localhost\`pwd\`/remote
159
+ $ export FIG_REMOTE_URL=ssh://localhost$(pwd)/remote
160
160
 
161
161
  Before we publish our package, we'll need to tell fig which files we want to include. We do this by using the "resource" statement in our "package.fig" file:
162
162
 
data/bin/fig CHANGED
@@ -183,7 +183,7 @@ elsif shell_command
183
183
  env.execute_shell(shell_command) { |cmd| os.shell_exec cmd }
184
184
  elsif argv[0]
185
185
  package_name, config_name, version_name = parse_descriptor(argv.shift)
186
- env.include_config(package, package_name, config_name, version_name, nil)
186
+ env.include_config(package, package_name, config_name, version_name, {}, nil)
187
187
  env.execute_config(package, package_name, config_name, nil, argv) { |cmd| os.shell_exec cmd }
188
188
  elsif input
189
189
  env.execute_config(package, nil, options[:config], nil, argv) { |cmd| os.shell_exec cmd }
@@ -1,9 +1,12 @@
1
1
  class Backtrace
2
+ attr_reader :overrides
3
+
2
4
  def initialize(parent, package_name, version_name, config_name)
3
5
  @parent = parent
4
6
  @package_name = package_name
5
7
  @version_name = version_name
6
8
  @config_name = config_name || "default"
9
+ @overrides = {}
7
10
  end
8
11
 
9
12
  def collect(stack)
@@ -23,6 +26,16 @@ class Backtrace
23
26
  stack << elem
24
27
  end
25
28
 
29
+ def add_override(package_name, version_name)
30
+ # Don't replace an existing override on the stack
31
+ return if get_override(package_name)
32
+ @overrides[package_name] = version_name
33
+ end
34
+
35
+ def get_override(package_name)
36
+ return @overrides[package_name] || (@parent ? @parent.get_override(package_name) : nil)
37
+ end
38
+
26
39
  def dump(out)
27
40
  stack = []
28
41
  collect(stack)
@@ -41,7 +41,8 @@ module Fig
41
41
  if (@applied_configs[package.package_name] ||= []).member?(config_name)
42
42
  return
43
43
  end
44
- new_backtrace = Backtrace.new(backtrace, package.package_name, package.version_name, config_name)
44
+ new_backtrace = backtrace #Backtrace.new(backtrace, package.package_name, package.version_name, config_name)
45
+
45
46
  config = package[config_name]
46
47
  config.statements.each { |stmt| apply_config_statement(package, stmt, new_backtrace) }
47
48
  @applied_configs[package.package_name] << config_name
@@ -73,7 +74,7 @@ module Fig
73
74
  when Set
74
75
  set_variable(base_package, statement.name, statement.value)
75
76
  when Include
76
- include_config(base_package, statement.package_name, statement.config_name, statement.version_name, backtrace)
77
+ include_config(base_package, statement.package_name, statement.config_name, statement.version_name, statement.overrides, backtrace)
77
78
  when Command
78
79
  # ignore
79
80
  else
@@ -81,10 +82,20 @@ module Fig
81
82
  end
82
83
  end
83
84
 
84
- def include_config(base_package, package_name, config_name, version_name, backtrace)
85
+ def include_config(base_package, package_name, config_name, version_name, overrides, backtrace)
86
+ # Check to see if this include has been overridden
87
+ if backtrace
88
+ override = backtrace.get_override(package_name || base_package.package_name)
89
+ if override
90
+ version_name = override
91
+ end
92
+ end
85
93
  new_backtrace = Backtrace.new(backtrace, package_name, version_name, config_name)
94
+ overrides.each do |override|
95
+ new_backtrace.add_override(override.package_name, override.version_name)
96
+ end
86
97
  package = lookup_package(package_name || base_package.package_name, version_name, new_backtrace)
87
- apply_config(package, config_name || "default", backtrace)
98
+ apply_config(package, config_name || "default", new_backtrace)
88
99
  end
89
100
 
90
101
  def direct_retrieve(package_name, source_path, target_path)
@@ -60,12 +60,20 @@ grammar Fig
60
60
  end
61
61
 
62
62
  rule include
63
- "include" ws descriptor {
63
+ "include" ws descriptor overrides:(override*) {
64
64
  def to_config_statement
65
65
  package = descriptor.respond_to?(:package) ? descriptor.package.text_value : nil
66
66
  config = descriptor.get_config
67
67
  version = descriptor.get_version
68
- Include.new(package, config, version)
68
+ Include.new(package, config, version, overrides.elements.map{ |e| e.to_override })
69
+ end
70
+ }
71
+ end
72
+
73
+ rule override
74
+ "override" ws package_name "/" version_name ws {
75
+ def to_override
76
+ return Override.new(package_name.text_value, version_name.text_value)
69
77
  end
70
78
  }
71
79
  end
@@ -99,7 +107,7 @@ grammar Fig
99
107
  end
100
108
 
101
109
  rule descriptor
102
- ((package:[a-zA-Z0-9.-]+ ("/" version:[a-zA-Z0-9_\-.]+)? (":" config:config_name)? ws) /
110
+ ((package:package_name ("/" version:version_name)? (":" config:config_name)? ws) /
103
111
  (":" config:config_name ws)) {
104
112
  def get_version
105
113
  elements.each do |element|
@@ -121,6 +129,14 @@ grammar Fig
121
129
  }
122
130
  end
123
131
 
132
+ rule package_name
133
+ [a-zA-Z0-9.-]+
134
+ end
135
+
136
+ rule version_name
137
+ [a-zA-Z0-9_\-.]+
138
+ end
139
+
124
140
  rule config_name
125
141
  [a-zA-Z0-9_\-.]+
126
142
  end
@@ -74,9 +74,14 @@ module Fig
74
74
 
75
75
  opts.on('-i', '--include PKG', 'include package in environment') do |descriptor|
76
76
  package_name, config_name, version_name = parse_descriptor(descriptor)
77
- options[:modifiers] << Include.new(package_name, config_name, version_name)
77
+ options[:modifiers] << Include.new(package_name, config_name, version_name, {})
78
78
  end
79
79
 
80
+ # opts.on('-o', '--override PKG', 'override version of included package') do |descriptor|
81
+ # package_name, config_name, version_name = parse_descriptor(descriptor)
82
+ # options[:modifiers] << Include.new(package_name, config_name, version_name, {})
83
+ # end
84
+
80
85
  opts.on('-s', '--set VAR=VAL', 'set environment variable') do |var_val|
81
86
  var, val = var_val.split('=')
82
87
  options[:modifiers] << Set.new(var, val)
@@ -165,12 +165,13 @@ module Fig
165
165
  end
166
166
 
167
167
  class Include
168
- attr_reader :package_name, :config_name, :version_name
168
+ attr_reader :package_name, :config_name, :version_name, :overrides
169
169
 
170
- def initialize(package_name, config_name, version_name)
170
+ def initialize(package_name, config_name, version_name, overrides)
171
171
  @package_name = package_name
172
172
  @config_name = config_name
173
173
  @version_name = version_name
174
+ @overrides = overrides
174
175
  end
175
176
 
176
177
  def unparse(indent)
@@ -178,7 +179,23 @@ module Fig
178
179
  descriptor += @package_name if @package_name
179
180
  descriptor += "/#{@version_name}" if @version_name
180
181
  descriptor += ":#{@config_name}" if @config_name
181
- "#{indent}include #{descriptor}"
182
+ @overrides.each do |override|
183
+ descriptor += override.unparse
184
+ end
185
+ return "#{indent}include #{descriptor}"
186
+ end
187
+ end
188
+
189
+ class Override
190
+ attr_reader :package_name, :version_name
191
+
192
+ def initialize(package_name, version_name)
193
+ @package_name = package_name
194
+ @version_name = version_name
195
+ end
196
+
197
+ def unparse()
198
+ return " override " + @package_name + "/" + @version_name
182
199
  end
183
200
  end
184
201
 
@@ -99,7 +99,7 @@ private
99
99
  if !File.exist?(target) || File.mtime(source) > File.mtime(target)
100
100
  $stderr.puts "\033[32m+ [#{@config.name}/#{@config.version}] #{relpath}\033[0m"
101
101
  FileUtils.mkdir_p(File.dirname(target))
102
- FileUtils.cp(source, target)
102
+ FileUtils.cp(source, target, :preserve => true)
103
103
  end
104
104
  @config.files << relpath if @config
105
105
  end
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fig
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.37
4
+ prerelease:
5
+ version: 0.1.38
5
6
  platform: ruby
6
7
  authors:
7
8
  - Matthew Foemmel
@@ -9,99 +10,229 @@ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2011-09-09 00:00:00 -05:00
13
+ date: 2011-10-06 00:00:00 -05:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
- name: libarchive
17
+ name: libarchive-static
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - "="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.0
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: libarchive-static
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - "="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.0.0
17
36
  type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: net-ssh
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
20
43
  requirements:
21
44
  - - ">="
22
45
  - !ruby/object:Gem::Version
23
- version: 0.1.1
24
- version:
46
+ version: 2.0.15
47
+ type: :runtime
48
+ version_requirements: *id003
25
49
  - !ruby/object:Gem::Dependency
26
- name: net-ssh
50
+ name: net-sftp
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 2.0.5
27
58
  type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: net-netrc
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.2.2
69
+ type: :runtime
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: polyglot
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: 0.2.9
80
+ type: :runtime
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: treetop
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: 1.4.2
91
+ type: :runtime
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: highline
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: 1.6.2
102
+ type: :runtime
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: rspec
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: "1.3"
113
+ type: :development
114
+ version_requirements: *id009
115
+ - !ruby/object:Gem::Dependency
116
+ name: open4
117
+ prerelease: false
118
+ requirement: &id010 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 1.0.1
124
+ type: :development
125
+ version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: libarchive-static
128
+ prerelease: false
129
+ requirement: &id011 !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - "="
133
+ - !ruby/object:Gem::Version
134
+ version: 1.0.0
135
+ type: :development
136
+ version_requirements: *id011
137
+ - !ruby/object:Gem::Dependency
138
+ name: libarchive-static
139
+ prerelease: false
140
+ requirement: &id012 !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - "="
144
+ - !ruby/object:Gem::Version
145
+ version: 1.0.0
146
+ type: :runtime
147
+ version_requirements: *id012
148
+ - !ruby/object:Gem::Dependency
149
+ name: net-ssh
150
+ prerelease: false
151
+ requirement: &id013 !ruby/object:Gem::Requirement
152
+ none: false
30
153
  requirements:
31
154
  - - ">="
32
155
  - !ruby/object:Gem::Version
33
156
  version: 2.0.15
34
- version:
157
+ type: :runtime
158
+ version_requirements: *id013
35
159
  - !ruby/object:Gem::Dependency
36
160
  name: net-sftp
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
161
+ prerelease: false
162
+ requirement: &id014 !ruby/object:Gem::Requirement
163
+ none: false
40
164
  requirements:
41
165
  - - ">="
42
166
  - !ruby/object:Gem::Version
43
167
  version: 2.0.5
44
- version:
168
+ type: :runtime
169
+ version_requirements: *id014
45
170
  - !ruby/object:Gem::Dependency
46
171
  name: net-netrc
47
- type: :runtime
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
172
+ prerelease: false
173
+ requirement: &id015 !ruby/object:Gem::Requirement
174
+ none: false
50
175
  requirements:
51
176
  - - ">="
52
177
  - !ruby/object:Gem::Version
53
178
  version: 0.2.2
54
- version:
179
+ type: :runtime
180
+ version_requirements: *id015
55
181
  - !ruby/object:Gem::Dependency
56
182
  name: polyglot
57
- type: :runtime
58
- version_requirement:
59
- version_requirements: !ruby/object:Gem::Requirement
183
+ prerelease: false
184
+ requirement: &id016 !ruby/object:Gem::Requirement
185
+ none: false
60
186
  requirements:
61
187
  - - ">="
62
188
  - !ruby/object:Gem::Version
63
189
  version: 0.2.9
64
- version:
190
+ type: :runtime
191
+ version_requirements: *id016
65
192
  - !ruby/object:Gem::Dependency
66
193
  name: treetop
67
- type: :runtime
68
- version_requirement:
69
- version_requirements: !ruby/object:Gem::Requirement
194
+ prerelease: false
195
+ requirement: &id017 !ruby/object:Gem::Requirement
196
+ none: false
70
197
  requirements:
71
198
  - - ">="
72
199
  - !ruby/object:Gem::Version
73
200
  version: 1.4.2
74
- version:
201
+ type: :runtime
202
+ version_requirements: *id017
75
203
  - !ruby/object:Gem::Dependency
76
204
  name: highline
77
- type: :runtime
78
- version_requirement:
79
- version_requirements: !ruby/object:Gem::Requirement
205
+ prerelease: false
206
+ requirement: &id018 !ruby/object:Gem::Requirement
207
+ none: false
80
208
  requirements:
81
209
  - - ">="
82
210
  - !ruby/object:Gem::Version
83
211
  version: 1.6.2
84
- version:
212
+ type: :runtime
213
+ version_requirements: *id018
85
214
  - !ruby/object:Gem::Dependency
86
215
  name: rspec
87
- type: :development
88
- version_requirement:
89
- version_requirements: !ruby/object:Gem::Requirement
216
+ prerelease: false
217
+ requirement: &id019 !ruby/object:Gem::Requirement
218
+ none: false
90
219
  requirements:
91
220
  - - ~>
92
221
  - !ruby/object:Gem::Version
93
222
  version: "1.3"
94
- version:
223
+ type: :development
224
+ version_requirements: *id019
95
225
  - !ruby/object:Gem::Dependency
96
226
  name: open4
97
- type: :development
98
- version_requirement:
99
- version_requirements: !ruby/object:Gem::Requirement
227
+ prerelease: false
228
+ requirement: &id020 !ruby/object:Gem::Requirement
229
+ none: false
100
230
  requirements:
101
231
  - - ">="
102
232
  - !ruby/object:Gem::Version
103
233
  version: 1.0.1
104
- version:
234
+ type: :development
235
+ version_requirements: *id020
105
236
  description: Fig is a utility for configuring environments and managing dependencies across a team of developers. You give it a list of packages and a shell command to run; it creates an environment that includes those packages, then executes the shell command in it (the caller's environment is not affected).
106
237
  email: git@foemmel.com
107
238
  executables:
@@ -133,31 +264,28 @@ homepage: http://github.com/mfoemmel/fig
133
264
  licenses: []
134
265
 
135
266
  post_install_message:
136
- rdoc_options:
137
- - --charset=UTF-8
267
+ rdoc_options: []
268
+
138
269
  require_paths:
139
270
  - lib
140
271
  required_ruby_version: !ruby/object:Gem::Requirement
272
+ none: false
141
273
  requirements:
142
274
  - - ">="
143
275
  - !ruby/object:Gem::Version
144
276
  version: "0"
145
- version:
146
277
  required_rubygems_version: !ruby/object:Gem::Requirement
278
+ none: false
147
279
  requirements:
148
280
  - - ">="
149
281
  - !ruby/object:Gem::Version
150
282
  version: "0"
151
- version:
152
283
  requirements: []
153
284
 
154
285
  rubyforge_project:
155
- rubygems_version: 1.3.5
286
+ rubygems_version: 1.5.3
156
287
  signing_key:
157
288
  specification_version: 3
158
289
  summary: Fig is a utility for configuring environments and managing dependencies across a team of developers..
159
- test_files:
160
- - spec/fig_spec.rb
161
- - spec/retriever_spec.rb
162
- - spec/spec_helper.rb
163
- - spec/win_spec.rb
290
+ test_files: []
291
+
@@ -1,331 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- require 'rubygems'
4
- require 'fig/os'
5
- require 'rake'
6
- require 'fileutils'
7
-
8
- class Popen
9
- if Fig::OS.windows?
10
- require 'win32/open3'
11
- def self.popen(*cmd)
12
- Open3.popen3(*cmd) { |stdin,stdout,stderr|
13
- yield stdin, stdout, stderr
14
- }
15
- end
16
- elsif Fig::OS.java?
17
- require 'open3'
18
- def self.popen(*cmd)
19
- Open3.popen3(*cmd) { |stdin,stdout,stderr|
20
- yield stdin, stdout, stderr
21
- }
22
- end
23
- else
24
- require 'open4'
25
- def self.popen(*cmd)
26
- Open4::popen4(*cmd) { |pid, stdin, stdout, stderr|
27
- yield stdin, stdout, stderr
28
- }
29
- end
30
- end
31
- end
32
-
33
- FIG_HOME = File.expand_path(File.dirname(__FILE__) + '/../tmp/fighome')
34
- FileUtils.mkdir_p(FIG_HOME)
35
- ENV['FIG_HOME'] = FIG_HOME
36
-
37
- FIG_REMOTE_DIR = File.expand_path(File.dirname(__FILE__) + '/../tmp/remote')
38
- FileUtils.mkdir_p(FIG_REMOTE_DIR)
39
- ENV['FIG_REMOTE_URL'] = "ssh://#{ENV['USER']}@localhost#{FIG_REMOTE_DIR}"
40
-
41
- FIG_EXE = File.expand_path(File.dirname(__FILE__) + '/../bin/fig')
42
-
43
- def fig(args, input=nil)
44
- args = "--file - #{args}" if input
45
- out = nil
46
- err = nil
47
- Popen.popen("#{RUBY} #{FIG_EXE} #{args}") do |stdin, stdout, stderr|
48
- if input
49
- stdin.puts input
50
- stdin.close
51
- end
52
- err = stderr.read.strip
53
- out = stdout.read.strip
54
- if err != ""
55
- $stderr.puts err
56
- end
57
- end
58
- return out, err, $?.exitstatus
59
- end
60
-
61
- describe "Fig" do
62
- it "set environment variable from command line" do
63
- fig('-s FOO=BAR -g FOO')[0].should == 'BAR'
64
- fig('--set FOO=BAR -g FOO')[0].should == 'BAR'
65
- end
66
-
67
- it "set environment variable from fig file" do
68
- input = <<-END
69
- config default
70
- set FOO=BAR
71
- end
72
- END
73
- fig('-g FOO', input)[0].should == 'BAR'
74
- end
75
-
76
- it "append environment variable from command line" do
77
- fig('-p PATH=foo -g PATH').should == ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}","",0]
78
- end
79
-
80
- it "append environment variable from fig file" do
81
- input = <<-END
82
- config default
83
- add PATH=foo
84
- end
85
- END
86
- fig('-g PATH', input).should == ["foo#{File::PATH_SEPARATOR}#{ENV['PATH']}","",0]
87
- end
88
-
89
- it "append empty environment variable" do
90
- fig('-p XYZZY=foo -g XYZZY').should == ["foo","",0]
91
- end
92
-
93
- it "should ignore comments" do
94
- input = <<-END
95
- #/usr/bin/env fig
96
-
97
- # Some comment
98
- config default
99
- set FOO=BAR # Another comment
100
- end
101
- END
102
- fig('-g FOO', input)[0].should == 'BAR'
103
- end
104
-
105
- it "publish to remote repository" do
106
- FileUtils.rm_rf(FIG_HOME)
107
- FileUtils.rm_rf(FIG_REMOTE_DIR)
108
- input = <<-END
109
- config default
110
- set FOO=BAR
111
- end
112
- END
113
- fig('--publish foo/1.2.3', input)
114
- fail unless File.exists? FIG_HOME + "/repos/foo/1.2.3/.fig"
115
- fail unless File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
116
- fig('-u -i foo/1.2.3 -g FOO')[0].should == 'BAR'
117
- end
118
-
119
- it "publish resource to remote repository" do
120
- FileUtils.rm_rf(FIG_HOME)
121
- FileUtils.rm_rf(FIG_REMOTE_DIR)
122
- FileUtils.mkdir_p("tmp/bin")
123
- File.open("tmp/bin/hello", "w") { |f| f << "echo bar" }
124
- fail unless system "chmod +x tmp/bin/hello"
125
- input = <<-END
126
- resource tmp/bin/hello
127
- config default
128
- append PATH=@/tmp/bin
129
- end
130
- END
131
- fig('--publish foo/1.2.3', input)
132
- fail unless File.exists? FIG_HOME + "/repos/foo/1.2.3/.fig"
133
- fail unless File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
134
- fig('-u -i foo/1.2.3 -- hello')[0].should == 'bar'
135
- end
136
-
137
- it "publish resource to remote repository using command line" do
138
- FileUtils.rm_rf(FIG_HOME)
139
- FileUtils.rm_rf(FIG_REMOTE_DIR)
140
- FileUtils.mkdir_p("tmp/bin")
141
- File.open("tmp/bin/hello", "w") { |f| f << "echo bar" }
142
- fail unless system "chmod +x tmp/bin/hello"
143
- fig('--publish foo/1.2.3 --resource tmp/bin/hello --append PATH=@/tmp/bin')
144
- fail unless File.exists? FIG_HOME + "/repos/foo/1.2.3/.fig"
145
- fail unless File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
146
- fig('-u -i foo/1.2.3 -- hello')[0].should == 'bar'
147
- end
148
-
149
- it "refuses to overwrite existing version in remote repository without being forced" do
150
- FileUtils.rm_rf(FIG_HOME)
151
- FileUtils.rm_rf(FIG_REMOTE_DIR)
152
- input = <<-END
153
- config default
154
- set FOO=SHEEP
155
- end
156
- END
157
- fig('--publish foo/1.2.3', input)
158
- fail unless File.exists? FIG_HOME + "/repos/foo/1.2.3/.fig"
159
- fail unless File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
160
- fig('-u -i foo/1.2.3 -g FOO')[0].should == 'SHEEP'
161
-
162
- input = <<-END
163
- config default
164
- set FOO=CHEESE
165
- end
166
- END
167
- (out, err, exitstatus) = fig('--publish foo/1.2.3', input)
168
- exitstatus.should == 1
169
- fig('-u -i foo/1.2.3 -g FOO')[0].should == 'SHEEP'
170
-
171
- (out, err, exitstatus) = fig('--publish foo/1.2.3 --force', input)
172
- exitstatus.should == 0
173
- fig('-u -i foo/1.2.3 -g FOO')[0].should == 'CHEESE'
174
- end
175
-
176
- it "publishes to the local repo only when told to" do
177
- FileUtils.rm_rf(FIG_HOME)
178
- FileUtils.rm_rf(FIG_REMOTE_DIR)
179
- FileUtils.mkdir_p("tmp/bin")
180
- File.open("tmp/bin/hello", "w") { |f| f << "echo bar" }
181
- fail unless system "chmod +x tmp/bin/hello"
182
- fig('--publish-local foo/1.2.3 --resource tmp/bin/hello --append PATH=@/tmp/bin')
183
- fail if File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
184
- fig('-m -i foo/1.2.3 -- hello')[0].should == 'bar'
185
- end
186
-
187
- it "retrieve resource" do
188
- FileUtils.rm_rf(FIG_HOME)
189
- FileUtils.rm_rf(FIG_REMOTE_DIR)
190
- FileUtils.rm_rf("tmp")
191
- FileUtils.mkdir_p("tmp/lib")
192
- File.open("tmp/lib/hello", "w") { |f| f << "some library" }
193
- input = <<-END
194
- resource tmp/lib/hello
195
- config default
196
- append FOOPATH=@/tmp/lib/hello
197
- end
198
- END
199
- fig('--publish foo/1.2.3', input)
200
- input = <<-END
201
- retrieve FOOPATH->tmp/lib2/[package]
202
- config default
203
- include foo/1.2.3
204
- end
205
- END
206
- fig('-m', input)
207
- File.read("tmp/lib2/foo/hello").should == "some library"
208
- end
209
-
210
- it "retrieves resource that is a directory" do
211
- FileUtils.rm_rf(FIG_HOME)
212
- FileUtils.rm_rf(FIG_REMOTE_DIR)
213
- FileUtils.rm_rf("tmp")
214
- FileUtils.mkdir_p("tmp/lib")
215
- File.open("tmp/lib/hello", "w") { |f| f << "some library" }
216
- # To copy the contents of a directory, instead of the directory itself,
217
- # use '/.' as a suffix to the directory name in 'append'.
218
- input = <<-END
219
- resource tmp/lib/hello
220
- config default
221
- append FOOPATH=@/tmp/lib/.
222
- end
223
- END
224
- fig('--publish foo/1.2.3', input)
225
- input = <<-END
226
- retrieve FOOPATH->tmp/lib2/[package]
227
- config default
228
- include foo/1.2.3
229
- end
230
- END
231
- fig('-m', input)
232
- File.read("tmp/lib2/foo/hello").should == "some library"
233
- end
234
-
235
- it "retrieve preserves the path after '//' when copying files into your project directory" do
236
- FileUtils.rm_rf(FIG_HOME)
237
- FileUtils.rm_rf(FIG_REMOTE_DIR)
238
- FileUtils.rm_rf("tmp")
239
- FileUtils.mkdir_p("tmp/include")
240
- File.open("tmp/include/hello.h", "w") { |f| f << "a header file" }
241
- File.open("tmp/include/hello2.h", "w") { |f| f << "another header file" }
242
- input = <<-END
243
- resource tmp/include/hello.h
244
- resource tmp/include/hello2.h
245
- config default
246
- append INCLUDE=@/tmp//include/hello.h
247
- append INCLUDE=@/tmp//include/hello2.h
248
- end
249
- END
250
- fig('--publish foo/1.2.3', input)
251
-
252
- input = <<-END
253
- retrieve INCLUDE->tmp/include2/[package]
254
- config default
255
- include foo/1.2.3
256
- end
257
- END
258
- fig('-u', input)
259
-
260
- File.read("tmp/include2/foo/include/hello.h").should == "a header file"
261
- File.read("tmp/include2/foo/include/hello2.h").should == "another header file"
262
- end
263
-
264
- it "package multiple resources" do
265
- FileUtils.rm_rf(FIG_HOME)
266
- FileUtils.rm_rf(FIG_REMOTE_DIR)
267
- FileUtils.rm_rf("tmp")
268
- FileUtils.mkdir_p("tmp/lib")
269
- File.open("tmp/lib/hello", "w") { |f| f << "some library" }
270
- File.open("tmp/lib/hello2", "w") { |f| f << "some other library" }
271
- input = <<-END
272
- resource tmp/lib/hello
273
- resource tmp/lib/hello2
274
- config default
275
- append FOOPATH=@/tmp/lib/hello
276
- append FOOPATH=@/tmp/lib/hello2
277
- end
278
- END
279
- fig('--publish foo/1.2.3', input)
280
- input = <<-END
281
- retrieve FOOPATH->tmp/lib2/[package]
282
- config default
283
- include foo/1.2.3
284
- end
285
- END
286
- fig('-m', input)
287
- File.read("tmp/lib2/foo/hello").should == "some library"
288
- File.read("tmp/lib2/foo/hello2").should == "some other library"
289
- end
290
-
291
- it "packages multiple resources with wildcards" do
292
- FileUtils.rm_rf(FIG_HOME)
293
- FileUtils.rm_rf(FIG_REMOTE_DIR)
294
- FileUtils.rm_rf("tmp")
295
- FileUtils.mkdir_p("tmp/lib")
296
- File.open("tmp/lib/foo.jar", "w") { |f| f << "some library" }
297
- File.open("tmp/lib/bar.jar", "w") { |f| f << "some other library" }
298
- input = <<-END
299
- resource tmp/**/*.jar
300
- config default
301
- append FOOPATH=@/tmp/lib/foo.jar
302
- end
303
- END
304
- fig('--publish foo/1.2.3', input)
305
- input = <<-END
306
- retrieve FOOPATH->tmp/lib2/[package]
307
- config default
308
- include foo/1.2.3
309
- end
310
- END
311
- fig('-m', input)
312
- File.read("tmp/lib2/foo/foo.jar").should == "some library"
313
- end
314
-
315
- it "update local packages if they already exist" do
316
- FileUtils.rm_rf(FIG_HOME)
317
- FileUtils.rm_rf(FIG_REMOTE_DIR)
318
- FileUtils.mkdir_p("tmp/bin")
319
- File.open("tmp/bin/hello", "w") { |f| f << "echo sheep" }
320
- fail unless system "chmod +x tmp/bin/hello"
321
- fig('--publish-local foo/1.2.3 --resource tmp/bin/hello --append PATH=@/tmp/bin')
322
- fail if File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
323
- fig('-m -i foo/1.2.3 -- hello')[0].should == 'sheep'
324
-
325
- File.open("tmp/bin/hello", "w") { |f| f << "echo cheese" }
326
- fail unless system "chmod +x tmp/bin/hello"
327
- fig('--publish-local foo/1.2.3 --resource tmp/bin/hello --append PATH=@/tmp/bin')
328
- fail if File.exists? FIG_REMOTE_DIR + "/foo/1.2.3/.fig"
329
- fig('-m -i foo/1.2.3 -- hello')[0].should == 'cheese'
330
- end
331
- end
@@ -1,47 +0,0 @@
1
- require 'fig/retriever'
2
-
3
- describe "Retriever" do
4
- it "retrieves single file" do
5
-
6
- # Set up some test files
7
- test_dir = "tmp/retrieve-test"
8
- FileUtils.rm_rf(test_dir)
9
- FileUtils.mkdir_p(test_dir)
10
-
11
- File.open("tmp/foo.txt", 'w') {|f| f << "FOO"}
12
- File.open("tmp/bar.txt", 'w') {|f| f << "BAR"}
13
- File.open("tmp/baz.txt", 'w') {|f| f << "BAZ"}
14
-
15
- # Retrieve files A and B
16
- r = Retriever.new(test_dir)
17
- r.with_config("foo", "1.2.3") do
18
- r.retrieve("tmp/foo.txt", "foo.txt")
19
- r.retrieve("tmp/bar.txt", "bar.txt")
20
- File.read(File.join(test_dir, "foo.txt")).should == "FOO"
21
- File.read(File.join(test_dir, "bar.txt")).should == "BAR"
22
- end
23
-
24
- # Retrieve files B and C for a different version
25
- r.with_config("foo", "4.5.6") do
26
- r.retrieve("tmp/bar.txt", "bar.txt")
27
- r.retrieve("tmp/baz.txt", "baz.txt")
28
- File.read(File.join(test_dir, "bar.txt")).should == "BAR"
29
- File.read(File.join(test_dir, "baz.txt")).should == "BAZ"
30
- File.exist?(File.join(test_dir, "foo.txt")).should == false
31
- end
32
-
33
- # Save and reload
34
- r.save
35
- r = Retriever.new(test_dir)
36
-
37
- # Switch back to original version
38
- r.with_config("foo", "1.2.3") do
39
- r.retrieve("tmp/foo.txt", "foo.txt")
40
- r.retrieve("tmp/bar.txt", "bar.txt")
41
-
42
- File.read(File.join(test_dir, "foo.txt")).should == "FOO"
43
- File.read(File.join(test_dir, "bar.txt")).should == "BAR"
44
- File.exist?(File.join(test_dir, "baz.txt")).should == false
45
- end
46
- end
47
- end
@@ -1,9 +0,0 @@
1
- $LOAD_PATH.unshift(File.dirname(__FILE__))
2
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
- require 'fig'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
9
- end
@@ -1,21 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
- require 'fig/os'
3
- require 'fig/windows'
4
-
5
-
6
- # Only run on Windows...
7
- if Fig::OS.windows?
8
- describe "Fig on Windows" do
9
- it "batch script should exist" do
10
- Fig::Windows.with_generated_batch_script(["echo", "Hello World"]) do |filename|
11
- File.exist?(filename).should == true
12
- end
13
- end
14
-
15
- it "batch script should say 'Hello World' when executed" do
16
- Fig::Windows.with_generated_batch_script(["echo", "Hello World"]) do |filename|
17
- %x[#{filename}].should == "Hello World\n"
18
- end
19
- end
20
- end
21
- end