]> git.openstreetmap.org Git - rails.git/commitdiff
Remove failed attempt to stop internal methods being public
authorAdam Hoyle <atomoil@gmail.com>
Wed, 25 Aug 2021 20:09:54 +0000 (21:09 +0100)
committerAdam Hoyle <atomoil@gmail.com>
Wed, 25 Aug 2021 20:12:51 +0000 (21:12 +0100)
app/models/communities.rb

index e63b801fed78cb8d1b2c7051cc5a25726e03153c..fee0b2adee1b14b7e0ff73566bf79bc698d963eb 100644 (file)
@@ -7,53 +7,49 @@ class Communities
     @local_chapters[locale] ||= local_chapter_for(locale)
   end
 
-  class << self
-    protected
-
-    def local_chapter_for(locale)
-      @local_chapters_index ||= load_local_chapters
-      locale_dict = locale_dict_for(locale)
-      localised_chapters = []
-      @local_chapters_index.each do |chapter|
-        id = chapter[:id]
-        name = locale_dict.dig(id, "name") || chapter[:name]
-        url = chapter[:url]
-        localised_chapters.push({ :id => id, :name => name, :url => url })
-      end
-      localised_chapters
+  def self.local_chapter_for(locale)
+    @local_chapters_index ||= load_local_chapters
+    locale_dict = locale_dict_for(locale)
+    localised_chapters = []
+    @local_chapters_index.each do |chapter|
+      id = chapter[:id]
+      name = locale_dict.dig(id, "name") || chapter[:name]
+      url = chapter[:url]
+      localised_chapters.push({ :id => id, :name => name, :url => url })
     end
+    localised_chapters
+  end
 
-    def load_local_chapters
-      json_file = File.expand_path("node_modules/osm-community-index/dist/resources.json", Dir.pwd)
-      community_index = JSON.parse(File.read(json_file))
-      local_chapters = []
-      community_index["resources"].each do |id, resource|
-        resource.each do |key, value|
-          next unless key == "type" && value == "osm-lc" && id != "OSMF"
+  def self.load_local_chapters
+    json_file = File.expand_path("node_modules/osm-community-index/dist/resources.json", Dir.pwd)
+    community_index = JSON.parse(File.read(json_file))
+    local_chapters = []
+    community_index["resources"].each do |id, resource|
+      resource.each do |key, value|
+        next unless key == "type" && value == "osm-lc" && id != "OSMF"
 
-          strings = resource["strings"]
-          chapter_name = strings["community"] || strings["name"]
-          url = strings["url"]
-          local_chapters.push({ :id => id, :name => chapter_name, :url => url })
-        end
+        strings = resource["strings"]
+        chapter_name = strings["community"] || strings["name"]
+        url = strings["url"]
+        local_chapters.push({ :id => id, :name => chapter_name, :url => url })
       end
-      local_chapters
     end
+    local_chapters
+  end
 
-    def locale_dict_for(locale_in)
-      locale = locale_in.to_s.tr("-", "_")
-      full_local_path = File.expand_path("node_modules/osm-community-index/i18n/#{locale}.yaml", Dir.pwd)
-      locale_dict = {}
-      if File.exist?(full_local_path)
-        locale_dict = YAML.safe_load(File.read(full_local_path))[locale]
-      else
-        shortened_locale = locale.split("_").first
-        if shortened_locale != locale
-          shortened_local_path = File.expand_path("node_modules/osm-community-index/i18n/#{shortened_locale}.yaml", Dir.pwd)
-          locale_dict = YAML.safe_load(File.read(shortened_local_path))[shortened_locale] if File.exist?(shortened_local_path)
-        end
+  def self.locale_dict_for(locale_in)
+    locale = locale_in.to_s.tr("-", "_")
+    full_local_path = File.expand_path("node_modules/osm-community-index/i18n/#{locale}.yaml", Dir.pwd)
+    locale_dict = {}
+    if File.exist?(full_local_path)
+      locale_dict = YAML.safe_load(File.read(full_local_path))[locale]
+    else
+      shortened_locale = locale.split("_").first
+      if shortened_locale != locale
+        shortened_local_path = File.expand_path("node_modules/osm-community-index/i18n/#{shortened_locale}.yaml", Dir.pwd)
+        locale_dict = YAML.safe_load(File.read(shortened_local_path))[shortened_locale] if File.exist?(shortened_local_path)
       end
-      locale_dict
     end
+    locale_dict
   end
 end