Sha256: f3b5c3c9b6405e810e25da3091cbba03e23b1874d5f8cc564ffd673c3d307a66

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

module RapiDoc
  module RapiConfig

    # following helper methods return the directory location if no file type is specified or return the file location
    # for that directory if one is supplied
    def template_dir(f = nil)
      @template_dir ||= File.join(File.dirname(__FILE__), '../../templates')
      form_file_name @template_dir, f
    end
     
    def config_dir(f = nil)
      @config_dir ||= File.join(::Rails.root.to_s, 'config/rapi_doc')
      form_file_name @config_dir, f
    end
    
    def target_dir(f = nil)
      @target_dir ||= File.join(::Rails.root.to_s, 'public/apidoc/')
      form_file_name @target_dir, f 
    end

    def controller_dir(f = nil)
      @controller_dir ||= File.join(::Rails.root.to_s, 'app/controllers/')
      form_file_name @controller_dir, f
    end

    # WARNING! - temp_dir will return different location for different runs. Use with Caution!
    def temp_dir(f = nil)
      @temp_dir ||= "#{Dir.mktmpdir("apidoc")}/"
      form_file_name @temp_dir, f
    end

    def form_file_name(dir, file)
      case file
      when NilClass then dir
      when String then File.join(dir, file)
      else raise ArgumentError, "Invalid argument #{file}"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rapi_doc-0.5.0 lib/rapi_doc/rapi_config.rb
rapi_doc-0.4.0 lib/rapi_doc/rapi_config.rb