Sha256: cd948830980136421756e354a1362aab9719434c3ce537ac5dbe74bd3181fbb5

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module DeployLog
  module Github
    class Deploys
      def initialize
        @github = Helper.new(ARGV.first)
        @calendar = DeployLog::Calendar.new
      end

      def merged_between(start, finish = nil)
        return Notify.error 'Start (--start=) is a required argument' if start.nil?

        finish = Date.today.to_time + (24 * 60 * 60) - 1 if finish.nil?

        render @github.pulls_in_timeframe(start, finish)
      end

      def merged_today
        start = Date.today.to_time # 12:00AM this morning
        finish = Date.today.to_time + (24 * 60 * 60) - 1 # 11:59PM tonight

        render @github.pulls_in_timeframe(start, finish)
      end

      def merged_on(start)
        return Notify.error 'Start (--start=) is a required argument' if start.nil?

        finish = start + 24 * 60 * 60 - 1

        render @github.pulls_in_timeframe(start, finish)
      end

      def merged_during_week(week_num)
        return Notify.error 'Week number (--week|-w) is a required argument' if week_num.nil?

        week = @calendar.week(week_num.to_i)

        render @github.pulls_in_timeframe(week[:first], week[:last])
      end

      def pr_title(title)
        render @github.search_pulls_by(title, :title)
      end

      def pr_for_branch(branch)
        render @github.search_pulls_by(branch, :ref)
      end

      private

      def render(data)
        puts data
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
deploy_log-0.2.6 lib/deploy_log/github/deploys.rb