<commit_before>require 'grape'
#require 'rack/contrib'

Dir["#{Rails.root}/lib/noosfero/api/*.rb"].each {|file| require file unless file =~ /api\.rb/}
module Noosfero
  module API
    class API < Grape::API
      use Rack::JSONP

      logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log"))
      logger.formatter = GrapeLogging::Formatters::Default.new
      use GrapeLogging::Middleware::RequestLogger, { logger: logger }

      rescue_from :all do |e|
        logger.error e
      end

      @@NOOSFERO_CONF = nil
      
      def self.NOOSFERO_CONF
        if @@NOOSFERO_CONF 
          @@NOOSFERO_CONF
        else
          file = Rails.root.join('config', 'noosfero.yml')
          @@NOOSFERO_CONF = File.exists?(file) ? YAML.load_file(file)[Rails.env] || {} : {}
        end    
      end

      before { setup_multitenancy }
      before { detect_stuff_by_domain }
      after { set_session_cookie }

      version 'v1'
      prefix "api"
      format :json
      content_type :txt, "text/plain"
      
      helpers APIHelpers

      mount V1::Articles
      mount V1::Comments
      mount V1::Users
      mount V1::Communities
      mount V1::People
      mount V1::Enterprises
      mount V1::Categories
      mount V1::Tasks
      mount V1::Environments
      mount Session

      # hook point which allow plugins to add Grape::API extensions to API::API<commit_msg>API: adding tag endpoint<commit_after>require 'grape'
#require 'rack/contrib'

Dir["#{Rails.root}/lib/noosfero/api/*.rb"].each {|file| require file unless file =~ /api\.rb/}
module Noosfero
  module API
    class API < Grape::API
      use Rack::JSONP

      logger = Logger.new(File.join(Rails.root, 'log', "#{ENV['RAILS_ENV'] || 'production'}_api.log"))
      logger.formatter = GrapeLogging::Formatters::Default.new
      use GrapeLogging::Middleware::RequestLogger, { logger: logger }

      rescue_from :all do |e|
        logger.error e
      end

      @@NOOSFERO_CONF = nil
      
      def self.NOOSFERO_CONF
        if @@NOOSFERO_CONF 
          @@NOOSFERO_CONF
        else
          file = Rails.root.join('config', 'noosfero.yml')
          @@NOOSFERO_CONF = File.exists?(file) ? YAML.load_file(file)[Rails.env] || {} : {}
        end    
      end

      before { setup_multitenancy }
      before { detect_stuff_by_domain }
      after { set_session_cookie }

      version 'v1'
      prefix "api"
      format :json
      content_type :txt, "text/plain"
      
      helpers APIHelpers

      mount V1::Articles
      mount V1::Comments
      mount V1::Users
      mount V1::Communities
      mount V1::People
      mount V1::Enterprises
      mount V1::Categories
      mount V1::Tasks
      mount V1::Tags
      mount V1::Environments
      mount Session

      # hook point which allow plugins to add Grape::API extensions to API::API
{'fraction_non_alphanumeric': 0.11447459986082116, 'fraction_numerical': 0.007306889352818371, 'mean_word_length': 2.4307875894988067, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '4002686', 'n_tokens_mistral': 966, 'n_tokens_neox': 921, 'n_words': 208}