<commit_before>require 'bundler'
Bundler.setup

require 'grape'
require 'oj'
require 'json'

require_relative 'helpers'
require_relative '../models/customer'
require_relative '../models/service'
require_relative '../models/subscription'

module Seif
  module API
    class Service < Grape::API
      format :json
      default_format :json
      error_format :json

      helpers Helpers

      before { authorize! }

      resources :resources do
        # This should have been the default route, but grape requires a fix for this:
        # https://github.com/intridea/grape/issues/86
        desc 'The current page, showing details about all available routes'
        get do
          Service.routes.map { |route| route.instance_variable_get(:@options) }
        end
      end

      version 'v1', :using => :path do
        get '/version' do
          'v1'
        end

        resources :services do
          get '/1' do
            Oj.load(File.read(File.expand_path("../crossgrade.json", __FILE__)))
          end
        end
      end

      version 'v2', :using => :path do
        get '/version' do
          'v2'
        end
      end
    end
  end
end<commit_msg>Name-based URIs<commit_after>require 'bundler'
Bundler.setup

require 'grape'
require 'oj'
require 'json'

require_relative 'helpers'
require_relative '../models/customer'
require_relative '../models/service'
require_relative '../models/subscription'

module Seif
  module API
    class Service < Grape::API
      format :json
      default_format :json
      error_format :json

      helpers Helpers

      before { authorize! }

      resources :resources do
        # This should have been the default route, but grape requires a fix for this:
        # https://github.com/intridea/grape/issues/86
        desc 'The current page, showing details about all available routes'
        get do
          Service.routes.map { |route| route.instance_variable_get(:@options) }
        end
      end

      version 'v1', :using => :path do
        get '/version' do
          'v1'
        end

        resources :services do
          get '/crossgrade' do
            Oj.load(File.read(File.expand_path("../crossgrade.json", __FILE__)))
          end
        end
      end

      version 'v2', :using => :path do
        get '/version' do
          'v2'
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.09513742071881606, 'fraction_numerical': 0.0054968287526427064, 'mean_word_length': 2.0847457627118646, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3590125', 'n_tokens_mistral': 687, 'n_tokens_neox': 673, 'n_words': 208}