Class: XCPretty::Learn

Inherits:
Object
  • Object
show all
Includes:
FormatMethods
Defined in:
lib/xcpretty/reporters/learn.rb

Constant Summary collapse

SERVICE_URL =
'http://ironbroker.flatironschool.com'
SERVICE_ENDPOINT =
'/e/flatiron_xcpretty'

Constants included from FormatMethods

FormatMethods::EMPTY

Instance Method Summary collapse

Methods included from FormatMethods

#format_analyze, #format_build_target, #format_check_dependencies, #format_clean, #format_clean_remove, #format_clean_target, #format_codesign, #format_compile, #format_compile_command, #format_compile_error, #format_compile_xib, #format_copy_strings_file, #format_cpresource, #format_duplicate_symbols, #format_error, #format_generate_dsym, #format_libtool, #format_linking, #format_pbxcp, #format_pending_test, #format_phase_script_execution, #format_preprocess, #format_process_info_plist, #format_process_pch, #format_test_run_finished, #format_test_run_started, #format_test_suite_started, #format_test_summary, #format_tiffutil, #format_touch, #format_undefined_symbols

Constructor Details

#initialize(options) ⇒ Learn

Returns a new instance of Learn.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/xcpretty/reporters/learn.rb', line 21

def initialize(options)
  load_dependencies
  @formatted_output = {
    username: UsernameParser.get_username,
    github_user_id: UserIdParser.get_user_id,
    repo_name: RepoParser.get_repo,
    build: {
      test_suite: [{
        framework: 'xcpretty',
        formatted_output: [],
        duration: 0.0,
        build_output: [],
      }]
    },
    total_count: 0,
    passing_count: 0,
    failure_count: 0
  }

  @parser = Parser.new(self)

  @connection = Faraday.new(url: SERVICE_URL) do |faraday|
    faraday.adapter  Faraday.default_adapter
  end
end

Instance Method Details

#finishObject



65
66
67
# File 'lib/xcpretty/reporters/learn.rb', line 65

def finish
  write_report_file
end

#format_failing_test(classname, test_case, reason, file) ⇒ Object



58
59
60
61
62
63
# File 'lib/xcpretty/reporters/learn.rb', line 58

def format_failing_test(classname, test_case, reason, file)
  failure = {classname: classname, name: test_case, file: file, reason: reason}
  @formatted_output[:build][:test_suite][0][:formatted_output] << failure
  @formatted_output[:total_count] += 1
  @formatted_output[:failure_count] += 1
end

#format_passing_test(classname, test_case, time) ⇒ Object



51
52
53
54
55
56
# File 'lib/xcpretty/reporters/learn.rb', line 51

def format_passing_test(classname, test_case, time)
  pass = {classname: classname, name: test_case, time: time}
  @formatted_output[:build][:test_suite][0][:formatted_output] << pass
  @formatted_output[:total_count] += 1
  @formatted_output[:passing_count] += 1
end

#handle(line) ⇒ Object



47
48
49
# File 'lib/xcpretty/reporters/learn.rb', line 47

def handle(line)
  @parser.parse(line)
end

#load_dependenciesObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/xcpretty/reporters/learn.rb', line 8

def load_dependencies
  unless @@loaded ||= false
    require 'fileutils'
    require 'pathname'
    require 'json'
    require 'faraday'
    require 'netrc'
    require 'git'
    require 'oj'
    @@loaded = true
  end
end