rubocop:disable Metrics/AbcSize
555413
def pretty_response_for(hash)
      JSON
        .pretty_generate(hash)
        .gsub('[', (' ' * 12) + '[')
        .gsub(']', (' ' * 12) + ']')
        .gsub('{', (' ' * 14) + '{')
        .gsub('}', (' ' * 14) + '}')
        .gsub(/\ {2}\"/, (' ' * 16) + '"')
    end
45923
def result
      @task = 'rubocop'
      @path = discover_path

      return unless temp_config(@task) && path_exists?(@path)

      rubo = `rubocop #{@path} --require #{reporter_path('rubocop')} --config #{temp_config(@task)} --format RuboCop::Formatter::MaximusRuboFormatter #{'-R' if is_rails?}`

      @output[:files_inspected] ||= files_inspected('rb', ' ')
      refine rubo
    end
584210
def index
      if defined?(ActiveRecord)
        @ar_error_messages = params[:app] ? RailsExceptionHandler::ActiveRecord::ErrorMessage.where(app_name: params[:app]).order('created_at DESC') : RailsExceptionHandler::ActiveRecord::ErrorMessage.order('created_at DESC')
      end
      if defined?(Mongoid)
        @mg_error_messages = params[:app] ? RailsExceptionHandler::Mongoid::ErrorMessage.where(app_name: params[:app]).order(created_at: 'desc') : RailsExceptionHandler::Mongoid::ErrorMessage.order_by(created_at: 'desc')
      end
      if defined?(WillPaginate)
        @ar_error_messages = @ar_error_messages.paginate(page: params[:page] || 1, per_page: params[:per_page] || 100)
      elsif defined?(Kaminari)
        @ar_error_messages = @ar_error_messages.page(params[:page] || 1).per(params[:per_page] || 100)
      end

      respond_to do |format|
        format.html # index.html.erb
        format.json {
          if @ar_error_messages.present? && @mg_error_messages.present?
            json = {active_record: @ar_error_messages, mongoid: @mg_error_messages}
          elsif @ar_error_messages.present? && @mg_error_messages.blank?
            json = @ar_error_messages
          elsif @ar_error_messages.blank? && @mg_error_messages.present?
            json = @mg_error_messages
          end
          render json: json
        }
      end
    end
1304174
def new
      @yml_file = Cmtool::YmlFile.new

      respond_to do |format|
        format.html # new.html.erb
        format.xml  { render :xml => @yml_file }
      end
    end
1244951
def fix_cdata(body)
      # <![CDATA[ = &lt;![CDATA[
      # ]]> =  ]]&gt;
      if !body.nil? && body.include?('&lt;![CDATA[')
        body.gsub! '&lt;![CDATA[', '<![CDATA['
        body.gsub! ']]&gt', ']]>'
      end
      body
    end
133881
def configure(options = {})
      dimentions = options.values_at(:height, :width).collect(&:to_i)
      begin
        @input.winsize = dimentions
      rescue TypeError
        @input.winsize = [*dimentions, 0, 0]
      end if dimentions.none?(&:zero?)
    end
1367158
def enable_apis
      dir = "/app/apis/#{@project_name}/#{@scaffold_name}s/base_apis.rb"
      base_dir = "#{Dir.pwd}/app/apis/#{@project_name}/#{@scaffold_name}s"
      unless File.exists?(File.join(Dir.pwd,dir))
        FileUtils.mkdir base_dir unless File.exists?(base_dir)
        source = "#{@gem_path}/lib/modules/scaffold/base_apis.rb"
        FileUtils.cp(source,File.join(Dir.pwd,dir))
        config_apis
        $stdout.puts "\e[1;32m \tcreate\e[0m\t#{dir}"
        mount_apis
      end
    end
237926
def [](attr)
      return nil unless instance_variable_defined?(:@attributes) and @attributes.is_a?(Hash)
      @attributes[attr] or (attr.is_a?(String) ? @attributes[attr.to_sym] : @attributes[attr.to_s])
    end
61831
def to_a
      @size_dep.depend
      array = []
      Volt.run_in_mode(:no_model_promises) do
        attributes.size.times do |index|
          array << deep_unwrap(self[index])
        end
      end
      array
    end
563292
def set?
      case value.class
      when Array
        value.size == 0 ? false : true
      else
        value.nil? ? false : true
      end
    end
132989
def stretch!(*arys)
      max_size = (arys + [self]).collect { |a| a.length }.max
      self[max_size - 1] = nil unless self.length == max_size
      return self
    end
1033396
def unpack(&bl)
      dir = nil
      pkg = ::Gem::Installer.new gem_path, :unpack => true

      if bl
        Dir.mktmpdir do |tmpdir|
          pkg.unpack tmpdir
          bl.call tmpdir
        end
      else
        dir = Dir.mktmpdir
        pkg.unpack dir
      end

      dir
    end
1232787
def _init_parser
      @parser ||= OptionParser.new do |opts|
        opts.banner = "Usage: barcodes [OPTIONS] symbology target"
        opts.separator ""
        opts.on('-D', '--data [DATA]', 'The barcode data to encode (0123456789)')                           { |v| @options[:data] = v ||= '0123456789' }
        opts.on('-s', '--start_character [START_CHARACTER]', 'The barcode start character if applicable')   { |v| @options[:start_character] = v ||= '' }
        opts.on('-e', '--stop_character [STOP_CHARACTER]', 'The barcode stop character if applicable')      { |v| @options[:stop_character] = v ||= '' }
        opts.on('-W', '--bar_width [BAR_WIDTH]', 'The barcode bar width in mils (20)')                      { |v| @options[:bar_width] = v.to_i ||= 20 }
        opts.on('-H', '--bar_height [BAR_HEIGHT]', 'The barcode bar height in mils (1000)')                 { |v| @options[:bar_height] = v.to_i ||= 1000 }
        opts.on('-c', '--caption_height [CAPTION_HEIGHT]', 'The barcode caption height in mils (180)')      { |v| @options[:caption_height] = v.to_i ||= 180 }
        opts.on('-p', '--caption_size [CAPTION_SIZE]', 'The caption font size in mils (167)')               { |v| @options[:font_size] = v.to_f ||= 167 }
        opts.on('-A', '--alpha [ALPHA]', 'The barcode transparency (1.0)')                                  { |v| @options[:alpha] = v.to_f ||= 1.0 }
        opts.on('-O', '--color [COLOR]', 'The barcode color in hex (000000)')                               { |v| @options[:color] = v ||= '000000' }
        opts.on('-a', '--captioned', 'Render barcode caption (true)')                                       { |v| @options[:captioned] = v ||= true }
        opts.on('-i', '--ascii', 'Render barcode as ASCII string (false)')                                  { |v| @options[:ascii] = v ||= false }
        opts.on('-v', '--version')                                                                          { puts self._version; exit }
        opts.on('-h', '--help')                                                                             { puts opts; exit }
        opts.separator ""
      end
    end
69807
def load_config
      @log.debug "loading validator-specific configuration"
      config = Autosign::Config.new

      if config.settings.to_hash[self.name].nil?
        @log.warn "Unable to load validator-specific configuration"
        @log.warn "Cannot load configuration section named '#{self.name}'"
        return {}
      else
        @log.debug "Set validator-specific settings from config file: " + config.settings.to_hash[self.name].to_s
        return config.settings.to_hash[self.name]
      end
    end
698531
def update
      param_key = ActiveModel::Naming.param_key(@content)

      respond_to do |format|
        if @content.update_attributes(params[param_key])
          format.json { render json: @content }
        else
          format.json { render json: @content.errors, status: :unprocessable_entity }
        end
      end
    end
681873
def new
      @keyword = Cmtool::Keyword.new

      respond_to do |format|
        format.html # new.html.erb
        format.xml  { render :xml => @keyword }
      end
    end
177019
def size(ref = nil)
      tree_map_for(ref || @ref).inject(0) do |num, entry|
        num + (@page_class.valid_page_name?(entry.name) ? 1 : 0)
      end
    rescue Gollum::Git::NoSuchShaFound
      0
    end