Skip to content

Commit

Permalink
Generate from local path (#55)
Browse files Browse the repository at this point in the history
* Generate from local path

* Rubocop bribery
  • Loading branch information
phallobst committed Aug 30, 2023
1 parent 03ca997 commit 81db3c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
3 changes: 2 additions & 1 deletion scripts/generate_entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
require 'json'
require 'uri'

response = Net::HTTP.get URI('https://api.2fa.directory/v3/all.json')
path = ENV['LOCAL_2FA_PATH']
response = path ? File.read("#{path}/api/v3/all.json") : Net::HTTP.get(URI('https://api.2fa.directory/v3/all.json'))
entries = {}

JSON.parse(response).each do |name, website|
Expand Down
11 changes: 9 additions & 2 deletions scripts/generate_regions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ def self.fetch(uri)
end

categories = JSON.parse(File.read('./data/categories.json'))
regions = API.fetch('https://api.2fa.directory/v3/regions.json')
entries = API.fetch('https://api.2fa.directory/v3/all.json')

path = ENV['LOCAL_2FA_PATH']
if path
regions = JSON.parse(File.read("#{path}/api/v3/regions.json"))
entries = JSON.parse(File.read("#{path}/api/v3/all.json"))
else
regions = API.fetch('https://api.2fa.directory/v3/regions.json')
entries = API.fetch('https://api.2fa.directory/v3/all.json')
end

used_regions = []
regions.each do |id, region|
Expand Down

0 comments on commit 81db3c8

Please sign in to comment.