-
Notifications
You must be signed in to change notification settings - Fork 1
/
gems.rb
48 lines (39 loc) · 1.2 KB
/
gems.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
source 'https://rubygems.org'
# Possible directories for dummy application
possible_app_dirs = [
ENV['DUMMY_PATH'],
File.join(Dir.pwd, 'test/dummy'),
Bundler.root.join('test/dummy')
]
# Find first gemfile on the possible directories
# Keep it at the end of the file (because of abort on the bottom)
gems_rb_found = false
possible_app_dirs.each do |dir|
break if gems_rb_found
next if !dir
next if !Dir.exist?(dir)
%w[Gemfile gems.rb].each do |gems_rb|
gems_rb = File.expand_path(File.join(dir, gems_rb))
if File.exist?(gems_rb)
eval_gemfile(gems_rb)
gems_rb_found = true
break
end
end
end
unless gems_rb_found
abort("Dummy application's gemfile not found")
end
# Current gem specification file
gemspec_file = Dir.glob(File.join(__dir__, '*.gemspec')).first
# Not valid gem
if gemspec_file.nil? || !File.exist?(gemspec_file)
abort('Gemspec not found')
end
# Dummy application may already include this gem
# You cannot specify the same gem twice
current_gem_spec = Bundler.load_gemspec(gemspec_file)
@dependencies.delete_if { |d| d.name == current_gem_spec.name }
# Load current gem and its dependencies
gemspec
gem "rys", github: "easysoftware/rys", branch: "devel"