9
9
10
10
class GemfileProcessor
11
11
SPECIAL_CASES = {
12
- "opensearch" => "OpenSearch" # special case because opensearch = OpenSearch not Opensearch
12
+ "opensearch" => "OpenSearch" , # special case because opensearch = OpenSearch not Opensearch
13
13
} . freeze
14
14
EXCLUDED_INTEGRATIONS = [ "configuration" , "propagation" , "utils" ] . freeze
15
15
@@ -37,32 +37,13 @@ def parse_gemfiles(directory = 'gemfiles/')
37
37
runtime = File . basename ( gemfile_name ) . split ( '_' ) . first # ruby or jruby
38
38
next unless %w[ ruby jruby ] . include? ( runtime )
39
39
# parse the gemfile
40
- if gemfile_name . end_with? ( ".gemfile" )
41
- process_gemfile ( gemfile_name , runtime )
42
- elsif gemfile_name . end_with? ( '.gemfile.lock' )
40
+ if gemfile_name . end_with? ( '.gemfile.lock' )
43
41
process_lockfile ( gemfile_name , runtime )
44
42
end
45
43
end
46
44
47
45
end
48
46
49
- def process_gemfile ( gemfile_name , runtime )
50
- begin
51
- definition = Bundler ::Definition . build ( gemfile_name , nil , nil )
52
- definition . dependencies . each do |dependency |
53
- gem_name = dependency . name
54
- version = dependency . requirement . to_s
55
- unspecified = version . strip == '' || version == ">= 0"
56
- if unspecified
57
- puts "#{ gem_name } uses latest"
58
- end
59
- update_gem_versions ( runtime , gem_name , version , unspecified )
60
- end
61
- rescue Bundler ::GemfileError => e
62
- puts "Error reading Gemfile: #{ e . message } "
63
- end
64
- end
65
-
66
47
def process_lockfile ( gemfile_name , runtime )
67
48
lockfile_contents = File . read ( gemfile_name )
68
49
parser = Bundler ::LockfileParser . new ( lockfile_contents )
@@ -86,7 +67,6 @@ def update_gem_versions(runtime, gem_name, version, unspecified)
86
67
87
68
# Update maximum gems
88
69
if unspecified
89
- puts "Setting gem #{ gem_name } to infinity"
90
70
@max_gems [ runtime ] [ gem_name ] = Float ::INFINITY
91
71
else
92
72
if @max_gems [ runtime ] [ gem_name ] . nil? || ( @max_gems [ runtime ] [ gem_name ] != Float ::INFINITY && gem_version > Gem ::Version . new ( @max_gems [ runtime ] [ gem_name ] ) )
@@ -102,6 +82,7 @@ def version_valid?(version, unspecified)
102
82
Gem ::Version . new ( version )
103
83
true
104
84
rescue ArgumentError
85
+ puts "#{ version } is invalid format."
105
86
false
106
87
end
107
88
@@ -125,18 +106,18 @@ def process_integrations
125
106
def include_hardcoded_versions
126
107
# `httpx` is maintained externally
127
108
@integration_json_mapping [ 'httpx' ] = [
128
- '0.11' , # Min version Ruby
129
- nil , # Max version Ruby
130
- '0.11' , # Min version JRuby
131
- nil # Max version JRuby
109
+ '0.11' , # Min version Ruby
110
+ 'infinity' , # Max version Ruby
111
+ '0.11' , # Min version JRuby
112
+ 'infinity' # Max version JRuby
132
113
]
133
114
134
115
# `makara` is part of `activerecord`
135
116
@integration_json_mapping [ 'makara' ] = [
136
- '0.3.5' , # Min version Ruby
137
- nil , # Max version Ruby
138
- '0.3.5' , # Min version JRuby
139
- nil # Max version JRuby
117
+ '0.3.5' , # Min version Ruby
118
+ 'infinity' , # Max version Ruby
119
+ '0.3.5' , # Min version JRuby
120
+ 'infinity' # Max version JRuby
140
121
]
141
122
end
142
123
@@ -152,9 +133,6 @@ def resolve_integration_name(integration)
152
133
153
134
def write_output
154
135
@integration_json_mapping = @integration_json_mapping . sort . to_h
155
- @integration_json_mapping . each do |integration , versions |
156
- versions . map! { |v | v == Float ::INFINITY ? 'infinity' : v }
157
- end
158
136
File . write ( "gem_output.json" , JSON . pretty_generate ( @integration_json_mapping ) )
159
137
end
160
138
end
0 commit comments