Class: CircleTime::BuildTime

Inherits:
Object
  • Object
show all
Defined in:
lib/circletime.rb

Instance Method Summary collapse

Constructor Details

#initialize(org) ⇒ BuildTime

Returns a new instance of BuildTime.



11
12
13
14
15
16
17
# File 'lib/circletime.rb', line 11

def initialize(org)
  Dotenv.load
  CircleCi.configure do |config|
    config.token = ENV['CIRCLE_CI_TOKEN']
  end
  @res = CircleCi.organization org
end

Instance Method Details

#monthObject



42
43
44
45
46
47
48
49
# File 'lib/circletime.rb', line 42

def month
  sum_build_time do |build_day|
    beginning_day = DateTime.now.beginning_of_month.to_date
    end_day       = DateTime.now.end_of_month.to_date

    beginning_day <= build_day && build_day  <= end_day
  end
end

#todayObject



19
20
21
22
23
24
# File 'lib/circletime.rb', line 19

def today
  sum_build_time do |build_day|
    today = DateTime.now.to_date
    build_day == today
  end
end

#weekObject



33
34
35
36
37
38
39
40
# File 'lib/circletime.rb', line 33

def week
  sum_build_time do |build_day|
    beginning_day = DateTime.now.beginning_of_week.to_date
    end_day       = DateTime.now.end_of_week.to_date

    beginning_day <= build_day && build_day  <= end_day
  end
end

#yestadayObject



26
27
28
29
30
31
# File 'lib/circletime.rb', line 26

def yestaday
  sum_build_time do |build_day|
    yestaday = DateTime.now.prev_day.to_date
    build_day == yestaday
  end
end