used_env 0.0.2
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 +7 -0
- data/lib/used_env.rb +24 -0
- metadata +49 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e9395aabec3ad2e412e2e7a46e759b6f86ff545dbf0190dead7f7ef94bf2f50c
|
|
4
|
+
data.tar.gz: 1df906c00b959a4fbf0562c330e817211672ebae21c226eea265c97ab4c58da0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 6749fd3f25c1b210e7c38a8fefce82e114bd37e14b20ea446a0c4a13fad13c32dbf31a6b8ea25b079d3beb48230b640a846e276f111d95632eea44f8bc0bb083
|
|
7
|
+
data.tar.gz: e499031fa4b058894f05c9b6fbecf5d2c2c539508a26ab1982cb86888fba5c0055bb49e6c91eaa56766052a6af4a466c3378391b450637d48c864d5fb3f518dc
|
data/lib/used_env.rb
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class UsedEnv
|
|
2
|
+
def self.find_ruby_files
|
|
3
|
+
Dir.glob("./**/**/**/*.rb")
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def self.find_env_variables
|
|
7
|
+
file_names = find_ruby_files
|
|
8
|
+
env_vars = []
|
|
9
|
+
file_names.each do |file|
|
|
10
|
+
File.foreach(file).with_index do |line,line_num|
|
|
11
|
+
next if line.strip.empty? || line.strip.start_with?('#')
|
|
12
|
+
|
|
13
|
+
# matches =line.scan(/ENV\["(.*?)"\]|ENV\['(.*?)'\]|ENV\.fetch\(["'](.*?)["']\)/)
|
|
14
|
+
matches = line.scan(/ENV\[["'](.*?)["']\]|ENV\.fetch\(["'](.*?)["']\)/)
|
|
15
|
+
|
|
16
|
+
matches.flatten.compact.each do |env_var|
|
|
17
|
+
env_vars << { variable: env_var, file: file, line: line_num + 1 }
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
env_vars
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
metadata
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: used_env
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Habi Pyatha
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2024-12-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: |
|
|
14
|
+
A gem to list all the environment variables used in a Ruby project.
|
|
15
|
+
|
|
16
|
+
Example usage:
|
|
17
|
+
results = UsedEnv.find_env_variables
|
|
18
|
+
results.each do |entry|
|
|
19
|
+
puts "ENV_Variable: #{entry[:variable]} | File_path: #{entry[:file]} | Line: #{entry[:line]}"
|
|
20
|
+
end
|
|
21
|
+
email:
|
|
22
|
+
executables: []
|
|
23
|
+
extensions: []
|
|
24
|
+
extra_rdoc_files: []
|
|
25
|
+
files:
|
|
26
|
+
- lib/used_env.rb
|
|
27
|
+
homepage:
|
|
28
|
+
licenses: []
|
|
29
|
+
metadata: {}
|
|
30
|
+
post_install_message:
|
|
31
|
+
rdoc_options: []
|
|
32
|
+
require_paths:
|
|
33
|
+
- lib
|
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
35
|
+
requirements:
|
|
36
|
+
- - ">="
|
|
37
|
+
- !ruby/object:Gem::Version
|
|
38
|
+
version: '0'
|
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
requirements: []
|
|
45
|
+
rubygems_version: 3.5.20
|
|
46
|
+
signing_key:
|
|
47
|
+
specification_version: 4
|
|
48
|
+
summary: Finds the ENV variables used in Ruby files.
|
|
49
|
+
test_files: []
|