instrumental-components 0.1.3 → 0.1.31
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.
- checksums.yaml +4 -4
- data/lib/instrumental-components.rb +14 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe12474095d5a24ed6024f13ad07fc09a1c06ff1975cc593ca1143c957b78203
|
4
|
+
data.tar.gz: be82faed7a3f4873cf1050d68b154614f3154b4b2a611a261a0385d92814694d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83d8efe650aee61417a7655a759c4010270c6caf1dff170a7db7cb29ae3c72171ae455a3fa1ace78c0a7ede0018fb205c5a894211e83ed5653388813c70099dc
|
7
|
+
data.tar.gz: 69d5beb80cf48f029ede27496e16fedb7cc96eec8a026444c4dd339bb190d1073adf382a4f6890a1ebedeb1f6cc46bc48e950e5ffc6de895d3d9b8cdad3a03f0
|
@@ -58,12 +58,15 @@ module InstrumentalComponents
|
|
58
58
|
private
|
59
59
|
|
60
60
|
def updating?
|
61
|
-
|
61
|
+
# Only consider it updating if the gem is in the current project's Gemfile
|
62
|
+
# and Gemfile.lock, not just installed system-wide
|
63
|
+
gemfile_has_gem? && gemfile_lock_has_gem? && File.exist?('Gemfile.lock')
|
62
64
|
end
|
63
65
|
|
64
66
|
def gemfile_has_gem?
|
65
67
|
return false unless File.exist?('Gemfile')
|
66
|
-
|
68
|
+
# Use a more precise regex to match the gem declaration
|
69
|
+
File.read('Gemfile').match?(/^\s*gem\s+['"]instrumental-components-library['"]/)
|
67
70
|
end
|
68
71
|
|
69
72
|
def gemfile_lock_has_gem?
|
@@ -127,11 +130,16 @@ module InstrumentalComponents
|
|
127
130
|
|
128
131
|
gemfile_content = File.read(gemfile_path)
|
129
132
|
|
130
|
-
|
133
|
+
# Check if the gem is already in any development group
|
134
|
+
unless gemfile_content.match?(/^\s*gem\s+['"]instrumental-components-library['"]/)
|
131
135
|
if gemfile_content.include?("group :development")
|
132
|
-
#
|
133
|
-
gemfile_content.gsub!(/group :development\s+do/) do |match|
|
134
|
-
|
136
|
+
# Find the last development group and add the gem there
|
137
|
+
gemfile_content.gsub!(/(group :development\s+do.*?)(?=group|$)/m) do |match|
|
138
|
+
if match.end_with?("end")
|
139
|
+
match.sub(/end\s*$/, " gem 'instrumental-components-library'\nend")
|
140
|
+
else
|
141
|
+
match + " gem 'instrumental-components-library'\n"
|
142
|
+
end
|
135
143
|
end
|
136
144
|
else
|
137
145
|
# Create new development group
|