Module: PunchStats

Defined in:
lib/punch_stats.rb,
lib/punch_stats/version.rb

Defined Under Namespace

Classes: Server

Constant Summary collapse

PUNCH_PATH =
ENV['PUNCH_PATH']
PUNCH_EXECUTABLE =
File.join(PUNCH_PATH, 'punch.rb')
ROOT =
File.join(File.dirname(__FILE__), '../')
VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.json_monthsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/punch_stats.rb', line 41

def self.json_months
  months.map do |month|
    hash = {}

    hash[:name] = month.name
    hash[:year] = month.year
    hash[:number] = month.number
    hash[:total] = month.total

    hash[:days] = month.days.map do |day|
      {
        date: day.to_time.to_date,
        total: day.total,
        blocks: day.blocks.map do |b|
          { start: b.start, end: b.finish, total: b.total }
        end
      }
    end

    hash
  end.to_json
end

.monthsArray<Month>

Returns:

  • (Array<Month>)


35
36
37
38
39
# File 'lib/punch_stats.rb', line 35

def self.months
  Dir["#{Punch.config.hours_folder}/*.txt"]
    .map { |f| Month.from_file(f) }
    .reject(&:empty?)
end

.rootObject



26
27
28
# File 'lib/punch_stats.rb', line 26

def self.root
  ROOT
end

.ui_distObject



30
31
32
# File 'lib/punch_stats.rb', line 30

def self.ui_dist
  File.join(ROOT, 'ui/dist')
end