fig 0.1.22 → 0.1.23

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 CHANGED
@@ -141,10 +141,14 @@ else
141
141
  end
142
142
 
143
143
  if options[:publish] || options[:publish_local]
144
- raise "Unexpected arguments: #{argv.join(' ')}" if !argv.empty?
144
+ if !argv.empty?
145
+ puts "Unexpected arguments: #{argv.join(' ')}"
146
+ exit 10
147
+ end
145
148
  package_name, config_name, version_name = parse_descriptor(options[:publish] || options[:publish_local])
146
149
  if package_name.nil? || version_name.nil?
147
- raise "Please specify a package name and a version name"
150
+ puts "Please specify a package name and a version name"
151
+ exit 10
148
152
  end
149
153
  if not options[:modifiers].empty?
150
154
  publish_statements = options[:resources] + options[:archives] + [Configuration.new("default", options[:modifiers])]
@@ -152,7 +156,8 @@ if options[:publish] || options[:publish_local]
152
156
  elsif not package.statements.empty?
153
157
  publish_statements = package.statements
154
158
  else
155
- fail "Nothing to publish"
159
+ puts "Nothing to publish"
160
+ exit 1
156
161
  end
157
162
  if options[:publish]
158
163
  puts "Checking status of #{package_name}/#{version_name}..."
@@ -26,7 +26,10 @@ module Fig
26
26
 
27
27
  def register_package(package)
28
28
  name = package.package_name
29
- raise "Package already exists with name: #{name}" if @packages[name]
29
+ if @packages[name]
30
+ puts "Package already exists with name: #{name}"
31
+ exit 10
32
+ end
30
33
  @packages[name] = package
31
34
  end
32
35
 
@@ -121,7 +124,8 @@ module Fig
121
124
  package = @repository.load_package(package_name, version_name || DEFAULT_VERSION_NAME)
122
125
  @packages[package_name] = package
123
126
  elsif version_name && version_name != package.version_name
124
- raise "Version mismatch: #{package_name}"
127
+ puts "Version mismatch: #{package_name}"
128
+ exit 10
125
129
  end
126
130
  package
127
131
  end
@@ -151,7 +155,10 @@ module Fig
151
155
  def expand_arg(arg)
152
156
  arg.gsub(/\@([a-zA-Z0-9\-\.]+)/) do |match|
153
157
  package = @packages[$1]
154
- raise "Package not found: #{$1}" if package.nil?
158
+ if package.nil?
159
+ puts "Package not found: #{$1}"
160
+ exit 10
161
+ end
155
162
  package.directory
156
163
  end
157
164
  end
@@ -99,7 +99,7 @@ grammar Fig
99
99
  end
100
100
 
101
101
  rule descriptor
102
- ((package:[a-zA-Z0-9.-]+ ("/" version:[a-zA-Z0-9.\-]+)? (":" config:config_name)? ws) /
102
+ ((package:[a-zA-Z0-9.-]+ ("/" version:[a-zA-Z0-9_\-.]+)? (":" config:config_name)? ws) /
103
103
  (":" config:config_name ws)) {
104
104
  def get_version
105
105
  elements.each do |element|
@@ -41,7 +41,8 @@ module Fig
41
41
  begin
42
42
  uri = URI.parse(url)
43
43
  rescue
44
- raise "Unable to parse url: '#{url}'"
44
+ puts "Unable to parse url: '#{url}'"
45
+ exit 10
45
46
  end
46
47
  case uri.scheme
47
48
  when "ftp"
@@ -69,7 +70,8 @@ module Fig
69
70
  end
70
71
  packages
71
72
  else
72
- raise "Protocol not supported: #{url}"
73
+ puts "Protocol not supported: #{url}"
74
+ exit 10
73
75
  end
74
76
  end
75
77
 
@@ -107,7 +109,8 @@ module Fig
107
109
  cmd = `which fig-download`.strip + " #{timestamp} #{uri.path}"
108
110
  ssh_download(uri.user, uri.host, path, cmd)
109
111
  else
110
- raise "Unknown protocol: #{url}"
112
+ puts "Unknown protocol: #{url}"
113
+ exit 10
111
114
  end
112
115
  end
113
116
 
@@ -131,7 +134,8 @@ module Fig
131
134
  when /\.zip$/
132
135
  unpack_archive(dir, path)
133
136
  else
134
- raise "Unknown archive type: #{basename}"
137
+ puts "Unknown archive type: #{basename}"
138
+ exit 10
135
139
  end
136
140
  end
137
141
 
@@ -176,7 +180,12 @@ module Fig
176
180
  end
177
181
 
178
182
  def exec(dir,command)
179
- Dir.chdir(dir) { raise "Command failed" unless system command }
183
+ Dir.chdir(dir) {
184
+ unless system command
185
+ puts "Command failed"
186
+ exit 10
187
+ end
188
+ }
180
189
  end
181
190
 
182
191
  def copy(source, target)
@@ -277,7 +286,8 @@ module Fig
277
286
  return false
278
287
  when NOT_FOUND
279
288
  tempfile.delete
280
- raise "File not found: #{path}"
289
+ puts "File not found: #{path}"
290
+ exit 10
281
291
  when SUCCESS
282
292
  FileUtils.mv(tempfile.path, path)
283
293
  return true
@@ -13,7 +13,8 @@ module Fig
13
13
  @statements.each do |stmt|
14
14
  return stmt if stmt.is_a?(Configuration) && stmt.name == config_name
15
15
  end
16
- raise "Configuration not found: #{@package_name}/#{@version_name}:#{config_name}"
16
+ puts "Configuration not found: #{@package_name}/#{@version_name}:#{config_name}"
17
+ exit 10
17
18
  end
18
19
 
19
20
  def configs
@@ -13,7 +13,8 @@ module Fig
13
13
  input = input.gsub(/#.*$/, '')
14
14
  result = @parser.parse(" #{input} ")
15
15
  if result.nil?
16
- raise "#{directory}: #{@parser.failure_reason}"
16
+ puts "#{directory}: #{@parser.failure_reason}"
17
+ exit 10
17
18
  end
18
19
  result.to_package(package_name, version_name, directory)
19
20
  end
@@ -137,7 +137,8 @@ module Fig
137
137
  file = File.join(dir, "package.fig")
138
138
  end
139
139
  if not File.exist?(file)
140
- raise "File not found: #{file}"
140
+ puts "Fig file not found for package: #{file}"
141
+ exit 10
141
142
  end
142
143
  read_package_from_file(file, package_name, version_name)
143
144
  end
@@ -190,9 +191,9 @@ module Fig
190
191
  end
191
192
  write_local_package(package_name, version_name, package)
192
193
  rescue
193
- $stderr.puts "install failed, cleaning up"
194
+ $stderr.puts "Install failed, cleaning up"
194
195
  delete_local_package(package_name, version_name)
195
- raise
196
+ exit 10
196
197
  end
197
198
  end
198
199
 
@@ -199,6 +199,31 @@ describe "Fig" do
199
199
  File.read("tmp/lib2/foo/hello").should == "some library"
200
200
  end
201
201
 
202
+ it "retrieves resource that is a directory" do
203
+ FileUtils.rm_rf(FIG_HOME)
204
+ FileUtils.rm_rf(FIG_REMOTE_DIR)
205
+ FileUtils.rm_rf("tmp")
206
+ FileUtils.mkdir_p("tmp/lib")
207
+ File.open("tmp/lib/hello", "w") { |f| f << "some library" }
208
+ # To copy the contents of a directory, instead of the directory itself,
209
+ # use '/.' as a suffix to the directory name in 'append'.
210
+ input = <<-END
211
+ resource tmp/lib/hello
212
+ config default
213
+ append FOOPATH=@/tmp/lib/.
214
+ end
215
+ END
216
+ fig('--publish foo/1.2.3', input)
217
+ input = <<-END
218
+ retrieve FOOPATH->tmp/lib2/[package]
219
+ config default
220
+ include foo/1.2.3
221
+ end
222
+ END
223
+ fig('-m', input)
224
+ File.read("tmp/lib2/foo/hello").should == "some library"
225
+ end
226
+
202
227
  it "retrieve preserves the path after '//' when copying files into your project directory" do
203
228
  FileUtils.rm_rf(FIG_HOME)
204
229
  FileUtils.rm_rf(FIG_REMOTE_DIR)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fig
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
5
- prerelease: false
4
+ hash: 53
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 22
10
- version: 0.1.22
9
+ - 23
10
+ version: 0.1.23
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthew Foemmel
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-26 00:00:00 -06:00
18
+ date: 2011-02-25 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -186,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
186
  requirements: []
187
187
 
188
188
  rubyforge_project:
189
- rubygems_version: 1.3.7
189
+ rubygems_version: 1.5.2
190
190
  signing_key:
191
191
  specification_version: 3
192
192
  summary: Fig is a utility for configuring environments and managing dependencies across a team of developers..