<commit_before>require 'grape-roaster'
require 'logger'
require 'active_model'
require 'active_record'

def wutz
  ActiveRecord::Base.establish_connection(
    :adapter => "sqlite3", :database => ':memory:'
  )

  if ENV['DEBUG'] || true
    ActiveRecord::Base.logger = Logger.new(STDOUT)
  end

  ActiveRecord::Migration.class_eval do
    create_table :tracks do |t|
      t.string  :title
      t.string  :index
      t.belongs_to :album
    end
  end

  ActiveRecord::Migration.class_eval do
    create_table :bands do |t|
      t.string  :name
    end
  end

  ActiveRecord::Migration.class_eval do
    create_table :albums do |t|
      t.string  :title
      t.string  :dafuq
      t.belongs_to :band
    end
  end

  b = Band.create!(name: 'The Fugees')
  album = Album.create!(title: 'The Score', dafuq: 'yes sir')
  album.tracks << Track.create!(title: 'Ready or Not', index: 0)
  album.tracks << Track.create!(title: 'Killing Me Softly', index: 1)
end

class Track < ActiveRecord::Base

  belongs_to :album
end

class Band < ActiveRecord::Base
end

class Album < ActiveRecord::Base
  belongs_to :band
  has_many :tracks
end

require 'byebug'

class TrackMapping
  #property :index
end

class AlbumMapping < Roaster::JsonApi::Mapping
  property :title
  property :dafuq

  collection :tracks
  #collection_representer class: Album
end


module Test
  class API < Grape::API
    version 'v1', using: :path
    format :json

    before do
      wutz()
    end

    include GrapeRoaster
    
    expose_resource AlbumMapping,
      adapter_class: Roaster::Adapters::ActiveRecord, 
      methods: [
        :get, :post,
        resource: [
          :get, :put, :delete,
          tracks: [
            :post, :delete
          ]
        ]
      ]
  end
end

def print_routes(api_class)<commit_msg>Final without option example<commit_after>require 'grape-roaster'
require 'logger'
require 'active_model'
require 'active_record'

def wutz
  ActiveRecord::Base.establish_connection(
    :adapter => "sqlite3", :database => ':memory:'
  )

  if ENV['DEBUG'] || true
    ActiveRecord::Base.logger = Logger.new(STDOUT)
  end

  ActiveRecord::Migration.class_eval do
    create_table :tracks do |t|
      t.string  :title
      t.string  :index
      t.belongs_to :album
    end
  end

  ActiveRecord::Migration.class_eval do
    create_table :bands do |t|
      t.string  :name
    end
  end

  ActiveRecord::Migration.class_eval do
    create_table :albums do |t|
      t.string  :title
      t.string  :dafuq
      t.belongs_to :band
    end
  end

  b = Band.create!(name: 'The Fugees')
  album = Album.create!(title: 'The Score', dafuq: 'yes sir')
  album.tracks << Track.create!(title: 'Ready or Not', index: 0)
  album.tracks << Track.create!(title: 'Killing Me Softly', index: 1)
end

class Track < ActiveRecord::Base

  belongs_to :album
end

class Band < ActiveRecord::Base
end

class Album < ActiveRecord::Base
  belongs_to :band
  has_many :tracks
end

require 'byebug'

class TrackMapping
  #property :index
end

class AlbumMapping < Roaster::JsonApi::Mapping
  property :title
  property :dafuq

  collection :tracks
  #collection_representer class: Album
end


module Test
  class API < Grape::API
    version 'v1', using: :path
    format :json

    before do
      wutz()
    end

    include GrapeRoaster
    
    expose_resource AlbumMapping,
      adapter_class: Roaster::Adapters::ActiveRecord,
      without: [
        :get,
        id_scope: [
          :delete,
          tracks: [
            :post,
            id_scope: [
              :delete
            ]
          ],
          band: false
        ]
      ]
  end
end

def print_routes(api_class)
{'fraction_non_alphanumeric': 0.1015242242787153, 'fraction_numerical': 0.002177463255307567, 'mean_word_length': 2.7538304392236976, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 7, 'https://': 0, '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': '6759230', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1200, 'n_words': 318}