Extract and store timestamps for all of the actions in the in app.
 @param [Hash] options  An options Hash passed to the generator via the command line.
 returns [Nil]
516266
def build(options = {})
      DuckMap.logger.info "\r\n\r\n====================================================================="
      DuckMap.logger.info "#{self.class.name} session begin at: #{Time.now}"
      DuckMap.logger.info "options: #{options}"

      verbose = options[:verbose].blank? ? false : true

      # always replace ALL of the existing content, so, the list is always current.
      # actions / views may have been deleted, renamed, etc.
      content = {sitemap: {}}
      grand_total = 0

      # controllers full physical path for the current app.
      base_dir = File.join(Rails.root, "app", "controllers").to_s

      # this is a little bit complex.
      # - traverse the entire directory structure for controllers.
      # - for each
      #   - inline gsub! to remove the base_dir.
      #   - inline gsub! to remove _controller.
      #   - then, prevent the application controller from making it into the list as
      #     there should not be any actions / views for the application controller.


      list = Dir["#{File.join(base_dir, "**", "*.rb")}"].each {|f| f.gsub!("#{base_dir}/", "").gsub!("_controller.rb", "")}.map.find_all {|x| x.eql?("application") ? false : true}

      DuckMap.console "Total number of controllers found within the app: #{list.length}"
      DuckMap.console "Views Controller"
      DuckMap.console "-------------------------------------------------------------"

      DuckMap.logger.show_console = verbose ? true : false

      list.each do |controller|

        file_spec = File.join("app", "views", controller)

        clazz = "#{controller}_controller".camelize.constantize

        DuckMap.console "===================================================================================="
        DuckMap.console "controller: #{controller.ljust(30)}  path: #{file_spec}"

        actions = {}
        methods = clazz.action_methods

        methods.each do |action|

          latest_timestamp = nil
          winner = nil

          DuckMap.console "    action: #{action}"

          Dir["#{File.join(file_spec, action)}.html.*"].each do |view|

            begin
              view_timestamp = File.stat(File.join(Rails.root, view)).mtime
              if view_timestamp.blank?
                DuckMap.console "          : cannot stat file: #{view}"
              else

                if latest_timestamp.blank? || view_timestamp > latest_timestamp
                  latest_timestamp = view_timestamp
                  winner = "timestamp from file"
                  DuckMap.console "          : Using    file timestamp? YES #{view}"
                  DuckMap.console "          :     file timestamp #{view_timestamp} greater than: #{latest_timestamp}"
                else
                  DuckMap.console "          : Using    file timestamp? NO #{view}"
                  DuckMap.console "          :     file timestamp #{view_timestamp} less than: #{latest_timestamp}"
                end

              end
            rescue Exception => e
              DuckMap.logger.debug "#{e}"
            end

            begin
              output = %x(git log --format='%ci' -- #{view} | head -n 1)
              if output.blank?
                DuckMap.console "          : cannot get date from GIT for file: #{view}"
              else

                view_timestamp = LastMod.to_date(output)
                if latest_timestamp.blank? || view_timestamp > latest_timestamp
                  latest_timestamp = view_timestamp
                  winner = "timestamp from GIT"
                  DuckMap.console "          : Using     GIT timestamp? YES #{view}"
                  DuckMap.console "          :     file timestamp #{view_timestamp} greater than: #{latest_timestamp}"
                else
                  DuckMap.console "          : Using     GIT timestamp? NO #{view}"
                  DuckMap.console "          :     file timestamp #{view_timestamp} less than: #{latest_timestamp}"
                end

              end
            rescue Exception => e
              DuckMap.logger.debug "#{e}"
            end

            begin
              view_timestamp = LastMod.to_date(I18n.t("#{controller.gsub("/", ".")}.#{action}", :locale => :sitemap))

              if view_timestamp.blank?
                DuckMap.console "          : cannot find item in locale sitemap.yml for file: #{view}"
              else

                view_timestamp = LastMod.to_date(output)
                if latest_timestamp.blank? || view_timestamp > latest_timestamp
                  latest_timestamp = view_timestamp
                  winner = "timestamp from locale sitemap.yml"
                  DuckMap.console "          : Using  locale timestamp? YES #{view}"
                  DuckMap.console "          :     file timestamp #{view_timestamp} greater than: #{latest_timestamp}"
                else
                  DuckMap.console "          : Using  locale timestamp? NO #{view}"
                  DuckMap.console "          :     file timestamp #{view_timestamp} less than: #{latest_timestamp}"
                end

              end

            rescue Exception => e
              DuckMap.logger.debug "#{e}"
            end

            DuckMap.console "          : winner #{winner}"

            begin
              actions.merge!(action => latest_timestamp.strftime("%m/%d/%Y %H:%M:%S"))
            rescue Exception => e
              DuckMap.logger.debug "#{e}"
            end

          end
        end

        # add all of the actions found for the current controller to the :sitemap section of the yaml file.
        if actions.length > 0
          grand_total += actions.length
          namespaces = controller.split("/")
          content[:sitemap] = merge_controller(content[:sitemap], namespaces, 0, actions)

          DuckMap.logger.show_console = true
          DuckMap.console "#{actions.length.to_s.rjust(5)} #{controller}"
          DuckMap.logger.show_console = verbose ? true : false

        end

      end

      DuckMap.logger.show_console = true
      DuckMap.console "\r\nTotal number of views synchronized: #{grand_total}\r\n"
      DuckMap.logger.info "#{self.class.name} session end at: #{Time.now}"
      DuckMap.logger.info "---------------------------------------------------------------------"

      # done.
      write_config(content)
      DuckMap.console "done."

    end
225609
def timeslot_options(
    interval=swingtime_settings.TIMESLOT_INTERVAL,
    start_time=swingtime_settings.TIMESLOT_START_TIME,
    end_delta=swingtime_settings.TIMESLOT_END_TIME_DURATION,
    fmt=swingtime_settings.TIMESLOT_TIME_FORMAT
):
    '''
    

    '''
    dt = datetime.combine(date.today(), time(0))
    dtstart = datetime.combine(dt.date(), start_time)
    dtend = dtstart + end_delta
    options = []

    while dtstart <= dtend:
        options.append((str(dtstart.time()), dtstart.strftime(fmt)))
        dtstart += interval

    return options
386582
def extract(hash, *args)
      begin
        tmp = hash
        args.each do |arg|
          tmp = tmp[arg]
        end
        tmp
      rescue
        nil
      end
    end
518221
def stringify_times(obj)
      case obj
      when Hash
        Hash[obj.map { |k,v| [k, stringify_times(v)] }]
      when Array
        obj.map { |v| stringify_times(v) }
      else
        iso_format_time(obj)
      end
    end
489619
def _get_handled_methods(self, actions_map):
        
        methods = ('OPTIONS',)

        defined_actions = []
        for action_name in actions_map.keys():
            view_method = getattr(self, action_name, None)
            method_exists = view_method is not None
            method_defined = view_method != self.not_allowed_action
            if method_exists and method_defined:
                defined_actions.append(action_name)

        for action in defined_actions:
            methods += actions_map[action]

        return methods
590181
def extract_options(names)
      options = {}
      options = names.pop if names.last.kind_of? Hash
      options = { :desc => @next_desc, 
                  :long_desc => @next_long_desc,
                  :default_value => @next_default_value,
                  :arg_name => @next_arg_name}.merge(options)
    end
507117
def reap_expired_sessions
      @timestamps.each do |session_id,stamp|
        delete_session(session_id) if (stamp + @session_ttl) < Time.now 
      end
      GC.start
    end
1296068
def parse_options options = {}, request = ''
      options.each do |opt, value|
        case opt
        when :timeout, :paging, :mode
          request += "&#{opt}=#{value}"
        when :callback, :stats
          request += "&#{opt}"
        when :fields
          request += "&#{opt}=" + value.join(',') if value.is_a?(Array)
        end
      end
      request
    end
1133514
def include? date
      result = false
      walk { |elements|
        break result = true if elements.include? date 
      }

      return result if !result || date.class == Date || times.nil?

      times.include? date
    end
26242
def _determine_scheduled_actions(scheduled_actions, scheduled_actions_from_pillar):
    '''
    
    '''
    tmp = copy.deepcopy(
        __salt__['config.option'](scheduled_actions_from_pillar, {})
    )
    # merge with data from state
    if scheduled_actions:
        tmp = dictupdate.update(tmp, scheduled_actions)
    return tmp
64171
def schedule(options)
      raise "Couldn't parse start time from attributes" if options[:at].nil?
      raise "Couldn't parse interval from attributes" unless options[:every].nil? || options[:every].is_a?(AS::Duration)

      at_ltz = Time.parse(options[:at]) || Time.now
      at_utc = Time.utc(*at_ltz) || Date.today.to_time.utc

      @metadata[:schedule] = {
        at:    at_utc,
        every: options[:every]
      }
    end
1062786
def action_options
      # Attempt resolution to outputs of monitor
      return @action_options unless @monitor_class.outputs.length > 0
      action_options = @action_options.clone
      @monitor_class.outputs.each do |output, _type|
        action_options.each do |option_key, option_value|
          action_options[option_key] =
            option_value.gsub("{{#{output}}}", @monitor.send(output).to_s)
        end
      end
      action_options
    end
386682
def timestamp(args):
    
    p = OptionParser(timestamp.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    path, = args
    for root, dirs, files in os.walk(path):
        for f in files:
            filename = op.join(root, f)
            atime, mtime = get_times(filename)
            print(filename, atime, mtime)
538174
def transform(options)
      options.map do |key, value|
        [key, ({
          real_time: ->(x) { "-#{x}" },
        }[key] || proc { |x| x }).call(value)]
      end.to_h
    end
929038
def parse_options
      super do |opts|

        opts.on("--list MODE", "Listing mode.  ALL, NAME, SHORT, PATH") do |u|
          options[:list] = u
          options[:list].upcase!
          unless ["ALL", "NAME", "SHORT", "PATH"].include?(options[:list])
            raise "invalid list mode '#{options[:list]}' for '--list' option"
          end
        end

        opts.on("--short", "List summary status only, alias for '--list=SHORT'") do |s|
          options[:list] = 'SHORT'
        end

        # Most decendants of BaseAction will only handle one type of asset, the
        # list action is unique in that you can specify the type of asset to list
        opts.on("--type ASSET_TYPE", "Asset type to list:  app_asset (default)") do |t|
          options[:type] = t
          unless ["app_asset"].include?(options[:type])
            raise "unknown asset type '#{options[:type]}' for '--type' option"
          end
        end

      end
    end
1114410
def resources_by_date(klass_name)
      klass       = klass_name.to_s.constantize
      created_ats = klass.order(:created_at).pluck(:created_at).compact
      steps       = date_range.step(date_steps).map(&:end_of_day)
      index       = 0
      counts      = created_ats.reduce(Hash.new(0)) do |counts, timestamp|
        cutoff = steps[index]

        # As long as timestamps have not exceeded the last date step
        if cutoff.present?
          if timestamp < cutoff
            counts[cutoff] += 1
          else
            index               += 1
            next_cutoff          = steps[index]
            counts[next_cutoff] += (counts[cutoff] + 1) if next_cutoff.present?
          end
        end

        counts
      end

      counts.values.to_s
    end
3301
def options
      Hash[
        DeskApi::Configuration.keys.map do |key|
          [key, instance_variable_get(:"@#{key}")]
        end
      ]
    end