class Admin::ModuleStoreController < OrbitBackendController @@store = STORE_CONFIG[:store_settings]["url"] def index @extensions = get_extensions end def show @extension = get_extension(params[:id]) rescue nil end def download #get extension related values extension = get_extension(params[:id]) rescue nil extension_name = extension["key"].to_s git_repository_url = extension["git_url"] version = extension["version"] module_installed = File.read("downloaded_extensions.rb").include?(extension["key"]) if module_installed.eql?(false) @download_link = "gem '#{extension_name}', '#{version}', :git => '#{git_repository_url}'" File.open("downloaded_extensions.rb", 'a') do |file| file.puts @download_link end end %w(bundle install) site_restart redirect_to admin_module_store_path end protected def get_extensions JSON.parse(open("#{@@store}/api/extensions").read) end def get_extension(id) JSON.parse(open("#{@@store}/api/extensions/#{id}").read) end end