aruba 0.7.4 → 0.8.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.nav +12 -0
- data/.rspec +1 -0
- data/.rubocop.yml +12 -0
- data/.simplecov +2 -0
- data/.travis.yml +5 -6
- data/Gemfile +53 -26
- data/History.md +17 -0
- data/LICENSE +1 -1
- data/README.md +45 -19
- data/Rakefile +12 -2
- data/TODO.md +3 -0
- data/aruba.gemspec +19 -8
- data/cucumber.yml +1 -1
- data/features/api/cd.feature +119 -0
- data/features/api/command/run.feature +37 -0
- data/features/api/command/which.feature +37 -0
- data/features/api/environment/append_environment_variable.feature +118 -0
- data/features/api/environment/prepend_environment_variable.feature +118 -0
- data/features/api/environment/set_environment_variable.feature +252 -0
- data/features/configuration/exit_timeout.feature +51 -0
- data/features/configuration/fixtures_directories.feature +31 -0
- data/features/configuration/fixtures_path_prefix.feature +24 -0
- data/features/configuration/io_timeout.feature +31 -0
- data/features/configuration/keep_ansi.feature +31 -0
- data/features/configuration/root_directory.feature +31 -0
- data/features/configuration/working_directory.feature +32 -0
- data/features/fixtures/cli-app/.gitignore +9 -0
- data/features/fixtures/cli-app/.rspec +2 -0
- data/features/fixtures/cli-app/README.md +34 -0
- data/features/fixtures/cli-app/Rakefile +1 -0
- data/features/fixtures/cli-app/bin/cli +6 -0
- data/features/fixtures/cli-app/cli-app.gemspec +26 -0
- data/features/fixtures/cli-app/features/support/env.rb +1 -0
- data/features/fixtures/cli-app/lib/cli/app.rb +13 -0
- data/features/fixtures/cli-app/lib/cli/app/version.rb +5 -0
- data/features/fixtures/cli-app/script/console +14 -0
- data/features/fixtures/cli-app/spec/cli/app_spec.rb +7 -0
- data/features/fixtures/cli-app/spec/spec_helper.rb +10 -0
- data/features/fixtures/copy/file.txt +1 -1
- data/features/hooks/after/command.feature +34 -0
- data/features/hooks/before/command.feature +61 -0
- data/features/matchers/directory/have_sub_directory.feature +110 -0
- data/features/matchers/file/be_existing_file.feature +82 -0
- data/features/matchers/file/have_file_content.feature +123 -0
- data/features/matchers/file/have_file_size.feature +107 -0
- data/features/matchers/path/be_an_absolute_path.feature +74 -0
- data/features/matchers/path/be_an_existing_path.feature +97 -0
- data/features/matchers/path/have_permissions.feature +118 -0
- data/features/matchers/timeouts.feature +48 -0
- data/features/step_definitions/aruba_dev_steps.rb +69 -1
- data/features/steps/commands/exit_statuses.feature +136 -0
- data/features/steps/commands/in_process.feature +129 -0
- data/features/steps/commands/run.feature +36 -0
- data/features/steps/environment/home_variable.feature +49 -0
- data/features/steps/environment/set_environment_variable.feature +34 -0
- data/features/support/aruba.rb +5 -0
- data/features/support/env.rb +8 -4
- data/lib/aruba.rb +20 -8
- data/lib/aruba/announcer.rb +1 -0
- data/lib/aruba/api.rb +18 -1179
- data/lib/aruba/api/command.rb +351 -0
- data/lib/aruba/api/core.rb +141 -0
- data/lib/aruba/api/deprecated.rb +549 -0
- data/lib/aruba/api/environment.rb +61 -0
- data/lib/aruba/api/filesystem.rb +305 -0
- data/lib/aruba/api/rvm.rb +39 -0
- data/lib/aruba/aruba_path.rb +75 -0
- data/lib/aruba/basic_configuration.rb +208 -0
- data/lib/aruba/basic_configuration/option.rb +25 -0
- data/lib/aruba/config.rb +43 -30
- data/lib/aruba/config/jruby.rb +14 -0
- data/lib/aruba/config_wrapper.rb +17 -0
- data/lib/aruba/contracts/relative_path.rb +13 -0
- data/lib/aruba/creators/aruba_file_creator.rb +32 -0
- data/lib/aruba/creators/aruba_fixed_size_file_creator.rb +32 -0
- data/lib/aruba/cucumber.rb +87 -53
- data/lib/aruba/cucumber/hooks.rb +65 -10
- data/lib/aruba/environment.rb +121 -0
- data/lib/aruba/errors.rb +3 -0
- data/lib/aruba/extensions/string/strip.rb +24 -0
- data/lib/aruba/hooks.rb +54 -0
- data/lib/aruba/jruby.rb +4 -9
- data/lib/aruba/matchers/command.rb +1 -79
- data/lib/aruba/matchers/command/be_successfully_executed.rb +30 -0
- data/lib/aruba/matchers/command/have_exit_status.rb +47 -0
- data/lib/aruba/matchers/command/have_finished_in_time.rb +42 -0
- data/lib/aruba/matchers/directory.rb +1 -59
- data/lib/aruba/matchers/directory/be_an_existing_directory.rb +34 -0
- data/lib/aruba/matchers/directory/have_sub_directory.rb +49 -0
- data/lib/aruba/matchers/file.rb +1 -177
- data/lib/aruba/matchers/file/be_an_existing_file.rb +34 -0
- data/lib/aruba/matchers/file/have_file_content.rb +58 -0
- data/lib/aruba/matchers/file/have_file_size.rb +43 -0
- data/lib/aruba/matchers/file/have_same_file_content.rb +44 -0
- data/lib/aruba/matchers/path.rb +1 -99
- data/lib/aruba/matchers/path/a_path_matching_pattern.rb +21 -0
- data/lib/aruba/matchers/path/be_an_absolute_path.rb +32 -0
- data/lib/aruba/matchers/path/be_an_existing_path.rb +33 -0
- data/lib/aruba/matchers/path/have_permissions.rb +60 -0
- data/lib/aruba/matchers/path/match_path_pattern.rb +41 -0
- data/lib/aruba/matchers/rspec.rb +0 -0
- data/lib/aruba/matchers/rspec_matcher_include_regexp.rb +1 -1
- data/lib/aruba/platform.rb +230 -0
- data/lib/aruba/process_monitor.rb +23 -5
- data/lib/aruba/processes/basic_process.rb +35 -1
- data/lib/aruba/processes/debug_process.rb +26 -15
- data/lib/aruba/processes/in_process.rb +21 -9
- data/lib/aruba/processes/spawn_process.rb +29 -19
- data/lib/aruba/reporting.rb +2 -0
- data/lib/aruba/rspec.rb +61 -13
- data/lib/aruba/runtime.rb +33 -0
- data/script/bootstrap +4 -6
- data/spec/aruba/api/runtime_spec.rb +28 -0
- data/spec/aruba/api_spec.rb +129 -126
- data/spec/aruba/aruba_path_spec.rb +65 -0
- data/spec/aruba/basic_configuration_spec.rb +5 -0
- data/spec/aruba/config_wrapper_spec.rb +25 -0
- data/spec/aruba/configuration_spec.rb +5 -0
- data/spec/aruba/jruby_spec.rb +34 -18
- data/spec/aruba/matchers/directory_spec.rb +6 -7
- data/spec/aruba/matchers/file_spec.rb +16 -20
- data/spec/aruba/matchers/path_spec.rb +14 -11
- data/spec/aruba/rspec_spec.rb +15 -0
- data/spec/aruba/runtime_spec.rb +29 -0
- data/spec/aruba/spawn_process_spec.rb +2 -2
- data/spec/spec_helper.rb +10 -2
- data/spec/support/configs/rspec.rb +1 -1
- data/spec/support/matchers/option.rb +35 -0
- data/spec/support/shared_contexts/aruba.rb +10 -8
- data/spec/support/shared_examples/configuration.rb +116 -0
- metadata +182 -33
- data/.rvmrc +0 -1
- data/features/before_cmd_hooks.feature +0 -61
- data/features/command_environment_variables.feature +0 -31
- data/features/custom_ruby_process.feature +0 -12
- data/features/exit_statuses.feature +0 -30
- data/features/support/custom_main.rb +0 -28
- data/lib/aruba/matchers/mode.rb +0 -52
- data/lib/aruba/utils.rb +0 -21
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'aruba/platform'
|
2
|
+
|
3
|
+
Aruba::Platform.require_matching_files('../matchers/environment/*.rb', __FILE__)
|
4
|
+
|
5
|
+
module Aruba
|
6
|
+
module Api
|
7
|
+
# Environment methods of aruba
|
8
|
+
module Environment
|
9
|
+
# Set environment variable
|
10
|
+
#
|
11
|
+
# @param [String] key
|
12
|
+
# The name of the environment variable as string, e.g. 'HOME'
|
13
|
+
#
|
14
|
+
# @param [String] value
|
15
|
+
# The value of the environment variable. Needs to be a string.
|
16
|
+
def set_environment_variable(name, value)
|
17
|
+
name = name.to_s
|
18
|
+
value = value.to_s
|
19
|
+
|
20
|
+
announcer.announce(:environment, name, value)
|
21
|
+
aruba.environment[name] = value
|
22
|
+
|
23
|
+
self
|
24
|
+
end
|
25
|
+
|
26
|
+
# Append environment variable
|
27
|
+
#
|
28
|
+
# @param [String] key
|
29
|
+
# The name of the environment variable as string, e.g. 'HOME'
|
30
|
+
#
|
31
|
+
# @param [String] value
|
32
|
+
# The value of the environment variable. Needs to be a string.
|
33
|
+
def append_environment_variable(name, value)
|
34
|
+
name = name.to_s
|
35
|
+
value = value.to_s
|
36
|
+
|
37
|
+
aruba.environment.append name, value
|
38
|
+
announcer.announce(:environment, name, aruba.environment[name])
|
39
|
+
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
# Prepend environment variable
|
44
|
+
#
|
45
|
+
# @param [String] key
|
46
|
+
# The name of the environment variable as string, e.g. 'HOME'
|
47
|
+
#
|
48
|
+
# @param [String] value
|
49
|
+
# The value of the environment variable. Needs to be a string.
|
50
|
+
def prepend_environment_variable(name, value)
|
51
|
+
name = name.to_s
|
52
|
+
value = value.to_s
|
53
|
+
|
54
|
+
aruba.environment.prepend name, value
|
55
|
+
announcer.announce(:environment, name, aruba.environment[name])
|
56
|
+
|
57
|
+
self
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,305 @@
|
|
1
|
+
require 'aruba/platform'
|
2
|
+
require 'aruba/extensions/string/strip'
|
3
|
+
require 'aruba/creators/aruba_file_creator'
|
4
|
+
require 'aruba/creators/aruba_fixed_size_file_creator'
|
5
|
+
|
6
|
+
Aruba::Platform.require_matching_files('../matchers/file/*.rb', __FILE__)
|
7
|
+
Aruba::Platform.require_matching_files('../matchers/directory/*.rb', __FILE__)
|
8
|
+
Aruba::Platform.require_matching_files('../matchers/path/*.rb', __FILE__)
|
9
|
+
|
10
|
+
module Aruba
|
11
|
+
module Api
|
12
|
+
module Filesystem
|
13
|
+
# Check if file or directory exist
|
14
|
+
#
|
15
|
+
# @param [String] file_or_directory
|
16
|
+
# The file/directory which should exist
|
17
|
+
def exist?(file_or_directory)
|
18
|
+
Aruba::Platform.exist? expand_path(file_or_directory)
|
19
|
+
end
|
20
|
+
|
21
|
+
# Check if file exist and is file
|
22
|
+
#
|
23
|
+
# @param [String] file
|
24
|
+
# The file/directory which should exist
|
25
|
+
def file?(file)
|
26
|
+
Aruba::Platform.file? expand_path(file)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Check if directory exist and is directory
|
30
|
+
#
|
31
|
+
# @param [String] file
|
32
|
+
# The file/directory which should exist
|
33
|
+
def directory?(file)
|
34
|
+
Aruba::Platform.directory? expand_path(file)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Check if path is absolute
|
38
|
+
#
|
39
|
+
# @return [TrueClass, FalseClass]
|
40
|
+
# Result of check
|
41
|
+
def absolute?(path)
|
42
|
+
ArubaPath.new(path).absolute?
|
43
|
+
end
|
44
|
+
|
45
|
+
# Check if path is relative
|
46
|
+
#
|
47
|
+
# @return [TrueClass, FalseClass]
|
48
|
+
# Result of check
|
49
|
+
def relative?(path)
|
50
|
+
ArubaPath.new(path).relative?
|
51
|
+
end
|
52
|
+
|
53
|
+
# Return all existing paths (directories, files) in current dir
|
54
|
+
#
|
55
|
+
# @return [Array]
|
56
|
+
# List of files and directories
|
57
|
+
def all_paths
|
58
|
+
list('.').map { |p| expand_path(p) }
|
59
|
+
end
|
60
|
+
|
61
|
+
# Return all existing files in current directory
|
62
|
+
#
|
63
|
+
# @return [Array]
|
64
|
+
# List of files
|
65
|
+
def all_files
|
66
|
+
list('.').select { |p| file? p }.map { |p| expand_path(p) }
|
67
|
+
end
|
68
|
+
|
69
|
+
# Return all existing directories in current directory
|
70
|
+
#
|
71
|
+
# @return [Array]
|
72
|
+
# List of files
|
73
|
+
def all_directories
|
74
|
+
list('.').select { |p| directory? p }.map { |p| expand_path(p) }
|
75
|
+
end
|
76
|
+
|
77
|
+
# Create directory object
|
78
|
+
#
|
79
|
+
# @return [Dir]
|
80
|
+
# The directory object
|
81
|
+
def directory(path)
|
82
|
+
fail ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
|
83
|
+
|
84
|
+
Dir.new(expand_path(path))
|
85
|
+
end
|
86
|
+
|
87
|
+
# Return content of directory
|
88
|
+
#
|
89
|
+
# @return [Array]
|
90
|
+
# The content of directory
|
91
|
+
def list(name)
|
92
|
+
fail ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
|
93
|
+
fail ArgumentError, %(Only directories are supported. Path "#{name}" is not a directory.) unless directory? name
|
94
|
+
|
95
|
+
existing_files = Dir.glob(expand_path(File.join(name, '**', '*')))
|
96
|
+
current_working_directory = ArubaPath.new(expand_path('.'))
|
97
|
+
|
98
|
+
existing_files.map { |d| ArubaPath.new(d).relative_path_from(current_working_directory).to_s }
|
99
|
+
end
|
100
|
+
|
101
|
+
# Return content of file
|
102
|
+
#
|
103
|
+
# @return [Array]
|
104
|
+
# The content of file, without "\n" or "\r\n" at the end. To rebuild the file use `content.join("\n")`
|
105
|
+
def read(name)
|
106
|
+
fail ArgumentError, %(Path "#{name}" does not exist.) unless exist? name
|
107
|
+
fail ArgumentError, %(Only files are supported. Path "#{name}" is not a file.) unless file? name
|
108
|
+
|
109
|
+
File.readlines(expand_path(name)).map(&:chomp)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Create a file with given content
|
113
|
+
#
|
114
|
+
# The method does not check if file already exists. If the file name is a
|
115
|
+
# path the method will create all neccessary directories.
|
116
|
+
#
|
117
|
+
# @param [String] file_name
|
118
|
+
# The name of the file
|
119
|
+
#
|
120
|
+
# @param [String] file_content
|
121
|
+
# The content which should be written to the file
|
122
|
+
def write_file(name, content)
|
123
|
+
Creators::ArubaFileCreator.new.write(expand_path(name), content, false)
|
124
|
+
|
125
|
+
self
|
126
|
+
end
|
127
|
+
|
128
|
+
# Create an empty file
|
129
|
+
#
|
130
|
+
# @param [String] file_name
|
131
|
+
# The name of the file
|
132
|
+
def touch(*args)
|
133
|
+
args = args.flatten
|
134
|
+
|
135
|
+
options = if args.last.kind_of? Hash
|
136
|
+
args.pop
|
137
|
+
else
|
138
|
+
{}
|
139
|
+
end
|
140
|
+
|
141
|
+
args.each { |p| create_directory(File.dirname(p)) }
|
142
|
+
|
143
|
+
Aruba::Platform.touch(args.map { |p| expand_path(p) }, options)
|
144
|
+
|
145
|
+
self
|
146
|
+
end
|
147
|
+
|
148
|
+
# Copy a file and/or directory
|
149
|
+
#
|
150
|
+
# @param [String, Array] source
|
151
|
+
# A single file or directory, multiple files or directories or multiple
|
152
|
+
# files and directories. If multiple sources are given the destination
|
153
|
+
# needs to be a directory
|
154
|
+
#
|
155
|
+
# @param [String] destination
|
156
|
+
# A file or directory name. If multiple sources are given the destination
|
157
|
+
# needs to be a directory
|
158
|
+
#
|
159
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
160
|
+
# def copy(*source, destination)
|
161
|
+
def copy(*args)
|
162
|
+
args = args.flatten
|
163
|
+
destination = args.pop
|
164
|
+
source = args
|
165
|
+
|
166
|
+
source.each do |s|
|
167
|
+
raise ArgumentError, %(The following source "#{s}" does not exist.) unless exist? s
|
168
|
+
end
|
169
|
+
|
170
|
+
raise ArgumentError, "Using a fixture as destination (#{destination}) is not supported" if destination.start_with? aruba.config.fixtures_path_prefix
|
171
|
+
raise ArgumentError, "Multiples sources can only be copied to a directory" if source.count > 1 && exist?(destination) && !directory?(destination)
|
172
|
+
|
173
|
+
source_paths = source.map { |f| expand_path(f) }
|
174
|
+
destination_path = expand_path(destination)
|
175
|
+
|
176
|
+
if source_paths.count > 1
|
177
|
+
Aruba::Platform.mkdir(destination_path)
|
178
|
+
else
|
179
|
+
Aruba::Platform.mkdir(File.dirname(destination_path))
|
180
|
+
source_paths = source_paths.first
|
181
|
+
end
|
182
|
+
|
183
|
+
Aruba::Platform.cp source_paths, destination_path
|
184
|
+
|
185
|
+
self
|
186
|
+
end
|
187
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
188
|
+
|
189
|
+
# Create a file with the given size
|
190
|
+
#
|
191
|
+
# The method does not check if file already exists. If the file name is a
|
192
|
+
# path the method will create all neccessary directories.
|
193
|
+
#
|
194
|
+
# @param [String] file_name
|
195
|
+
# The name of the file
|
196
|
+
#
|
197
|
+
# @param [Integer] file_size
|
198
|
+
# The size of the file
|
199
|
+
def write_fixed_size_file(name, size)
|
200
|
+
Creators::ArubaFixedSizeFileCreator.new.write(expand_path(name), size, false)
|
201
|
+
|
202
|
+
self
|
203
|
+
end
|
204
|
+
|
205
|
+
# Create a file with given content
|
206
|
+
#
|
207
|
+
# The method does check if file already exists and fails if the file is
|
208
|
+
# missing. If the file name is a path the method will create all neccessary
|
209
|
+
# directories.
|
210
|
+
def overwrite_file(name, content)
|
211
|
+
Creators::ArubaFileCreator.new.write(expand_path(name), content, true)
|
212
|
+
|
213
|
+
self
|
214
|
+
end
|
215
|
+
|
216
|
+
# Change file system permissions of file
|
217
|
+
#
|
218
|
+
# @param [Octal] mode
|
219
|
+
# File system mode, eg. 0755
|
220
|
+
#
|
221
|
+
# @param [String] file_name
|
222
|
+
# Name of file to be modified. This file needs to be present to succeed
|
223
|
+
def chmod(*args)
|
224
|
+
args = args.flatten
|
225
|
+
|
226
|
+
options = if args.last.kind_of? Hash
|
227
|
+
args.pop
|
228
|
+
else
|
229
|
+
{}
|
230
|
+
end
|
231
|
+
|
232
|
+
mode = args.shift
|
233
|
+
mode = if mode.kind_of? String
|
234
|
+
mode.to_i(8)
|
235
|
+
else
|
236
|
+
mode
|
237
|
+
end
|
238
|
+
|
239
|
+
args.each { |p| raise "Expected #{p} to be present" unless exist?(p) }
|
240
|
+
paths = args.map { |p| expand_path(p) }
|
241
|
+
|
242
|
+
Aruba::Platform.chmod(mode, paths, options)
|
243
|
+
|
244
|
+
self
|
245
|
+
end
|
246
|
+
|
247
|
+
# Append data to file
|
248
|
+
#
|
249
|
+
# @param [String] file_name
|
250
|
+
# The name of the file to be used
|
251
|
+
#
|
252
|
+
# @param [String] file_content
|
253
|
+
# The content which should be appended to file
|
254
|
+
def append_to_file(file_name, file_content)
|
255
|
+
file_name = expand_path(file_name)
|
256
|
+
|
257
|
+
Aruba::Platform.mkdir(File.dirname(file_name))
|
258
|
+
File.open(file_name, 'a') { |f| f << file_content }
|
259
|
+
end
|
260
|
+
|
261
|
+
# Create a directory in current directory
|
262
|
+
#
|
263
|
+
# @param [String] directory_name
|
264
|
+
# The name of the directory which should be created
|
265
|
+
def create_directory(directory_name)
|
266
|
+
Aruba::Platform.mkdir expand_path(directory_name)
|
267
|
+
|
268
|
+
self
|
269
|
+
end
|
270
|
+
|
271
|
+
# Remove file or directory
|
272
|
+
#
|
273
|
+
# @param [Array, String] name
|
274
|
+
# The name of the file / directory which should be removed
|
275
|
+
def remove(*args)
|
276
|
+
args = args.flatten
|
277
|
+
|
278
|
+
options = if args.last.kind_of? Hash
|
279
|
+
args.pop
|
280
|
+
else
|
281
|
+
{}
|
282
|
+
end
|
283
|
+
|
284
|
+
args = args.map { |p| expand_path(p) }
|
285
|
+
|
286
|
+
Aruba::Platform.rm(args, options)
|
287
|
+
end
|
288
|
+
|
289
|
+
# Read content of file and yield the content to block
|
290
|
+
#
|
291
|
+
# @param [String) file
|
292
|
+
# The name of file which should be read from
|
293
|
+
#
|
294
|
+
# @yield
|
295
|
+
# Pass the content of the given file to this block
|
296
|
+
def with_file_content(file, &block)
|
297
|
+
stop_processes!
|
298
|
+
|
299
|
+
content = read(file).join("\n")
|
300
|
+
|
301
|
+
yield(content)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'aruba/api/environment'
|
2
|
+
require 'aruba/api/command'
|
3
|
+
|
4
|
+
module Aruba
|
5
|
+
module Api
|
6
|
+
module Rvm
|
7
|
+
# Use a clean rvm gemset
|
8
|
+
#
|
9
|
+
# Please make sure that you've got [rvm](http://rvm.io/) installed.
|
10
|
+
#
|
11
|
+
# @param [String] gemset
|
12
|
+
# The name of the gemset to be used
|
13
|
+
def use_clean_gemset(gemset)
|
14
|
+
run_simple(%{rvm gemset create "#{gemset}"}, true)
|
15
|
+
if all_stdout =~ /'#{gemset}' gemset created \((.*)\)\./
|
16
|
+
gem_home = Regexp.last_match[1]
|
17
|
+
set_environment_variable('GEM_HOME', gem_home)
|
18
|
+
set_environment_variable('GEM_PATH', gem_home)
|
19
|
+
set_environment_variable('BUNDLE_PATH', gem_home)
|
20
|
+
|
21
|
+
paths = (ENV['PATH'] || "").split(File::PATH_SEPARATOR)
|
22
|
+
paths.unshift(File.join(gem_home, 'bin'))
|
23
|
+
set_environment_variable('PATH', paths.uniq.join(File::PATH_SEPARATOR))
|
24
|
+
|
25
|
+
run_simple("gem install bundler", true)
|
26
|
+
else
|
27
|
+
raise "I didn't understand rvm's output: #{all_stdout}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Unset variables used by bundler
|
32
|
+
def unset_bundler_env_vars
|
33
|
+
%w[RUBYOPT BUNDLE_PATH BUNDLE_BIN_PATH BUNDLE_GEMFILE].each do |key|
|
34
|
+
set_environment_variable(key, nil)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'delegate'
|
3
|
+
|
4
|
+
module Aruba
|
5
|
+
class ArubaPath < SimpleDelegator
|
6
|
+
def initialize(path)
|
7
|
+
if path.is_a? Array
|
8
|
+
__setobj__ Pathname.new(File.join(*path))
|
9
|
+
else
|
10
|
+
__setobj__ Pathname.new(path)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Add directory/file to path
|
15
|
+
#
|
16
|
+
# @param [String] p
|
17
|
+
# The path to be added
|
18
|
+
#
|
19
|
+
# @example
|
20
|
+
# path = ArubaPath.new 'path/to/dir.d'
|
21
|
+
# path << 'subdir.d
|
22
|
+
# # or path.push 'subdir.d
|
23
|
+
# puts path
|
24
|
+
# # => path/to/dir.d/subdir.d
|
25
|
+
def push(p)
|
26
|
+
__setobj__(File.join(__getobj__, p))
|
27
|
+
end
|
28
|
+
alias_method :<<, :push
|
29
|
+
|
30
|
+
# Remove last component of path
|
31
|
+
#
|
32
|
+
# @example
|
33
|
+
# path = ArubaPath.new 'path/to/dir.d'
|
34
|
+
# path.pop
|
35
|
+
# puts path
|
36
|
+
# # => path/to
|
37
|
+
def pop
|
38
|
+
if RUBY_VERSION < '1.9'
|
39
|
+
dirs = []
|
40
|
+
__getobj__.each_filename { |f| dirs << f }
|
41
|
+
else
|
42
|
+
dirs = __getobj__.each_filename.to_a
|
43
|
+
end
|
44
|
+
|
45
|
+
dirs.pop
|
46
|
+
|
47
|
+
__setobj__ Pathname.new(File.join(*dirs))
|
48
|
+
end
|
49
|
+
|
50
|
+
if RUBY_VERSION < '1.9'
|
51
|
+
def to_s
|
52
|
+
__getobj__.to_s
|
53
|
+
end
|
54
|
+
|
55
|
+
def relative?
|
56
|
+
!(%r{\A/} === __getobj__)
|
57
|
+
end
|
58
|
+
|
59
|
+
def absolute?
|
60
|
+
(%r{\A/} === __getobj__)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Return string at index
|
65
|
+
#
|
66
|
+
# @param [Integer, Range] index
|
67
|
+
def [](index)
|
68
|
+
if RUBY_VERSION < '1.9'
|
69
|
+
to_s.chars.to_a[index].to_a.join('')
|
70
|
+
else
|
71
|
+
to_s[index]
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|