learn-test 2.3.3 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b86bdac0ef9eef67c3c46c1639d72917aaf19e6
4
- data.tar.gz: 52f358796c2d48094a2c29de4fd417e707783021
3
+ metadata.gz: befbe9633e983c7302c3aa5955778b8fc38970dd
4
+ data.tar.gz: 5b84c70e6b27fc2c2cd5c2584328a613b1d5564e
5
5
  SHA512:
6
- metadata.gz: 9532e8a6730a64f43f91af741ac08229d9b8c0dbf95ab3a8694e0b8bfca97c5a1e6e7fc5659bb8b75d95d148255fccd4cc7410ec6fc4602dccff8bb6b802485e
7
- data.tar.gz: 59ee606f3370b3f39c14bbcd0c01681db9d570a09fe694291b0fd756f3681f0c5c1d5f666526d33d4417986e1eb6cadc3939872314f19756b258fd6683d36a60
6
+ metadata.gz: b820e01ce5acd8d3cc8371c6937418931a6443a891ff79c18f6fc031d41c3258d9132e9f58e7d669b33f91a6dd0f257806af53c29c4824002a5af060bbfd7b19
7
+ data.tar.gz: 658d425794585202a49bd4a7dd42282ae4e0b93b3cc80f5380e4671eb1aa551694788133cd7a0931bcff4788c5ad2a167204118ba573aba28e3356a9435d8446
@@ -8,6 +8,7 @@ require_relative 'learn_test/netrc_interactor'
8
8
  require_relative 'learn_test/github_interactor'
9
9
  require_relative 'learn_test/user_id_parser'
10
10
  require_relative 'learn_test/username_parser'
11
+ require_relative 'learn_test/learn_oauth_token_parser'
11
12
  require_relative 'learn_test/repo_parser'
12
13
  require_relative 'learn_test/file_finder'
13
14
  require_relative 'learn_test/runner'
@@ -0,0 +1,8 @@
1
+ module LearnTest
2
+ class LearnOauthTokenParser
3
+ def self.get_learn_oauth_token
4
+ parser = LearnTest::NetrcInteractor.new(machine: 'learn-config')
5
+ parser.user_id
6
+ end
7
+ end
8
+ end
@@ -2,15 +2,16 @@ require 'netrc'
2
2
 
3
3
  module LearnTest
4
4
  class NetrcInteractor
5
- attr_reader :username, :user_id, :netrc
5
+ attr_reader :username, :user_id, :netrc, :machine
6
6
 
7
- def initialize
7
+ def initialize(machine: 'flatiron-push')
8
+ @machine = machine
8
9
  @netrc = Netrc.read
9
- @username, @user_id = netrc["flatiron-push"]
10
+ @username, @user_id = netrc[machine]
10
11
  end
11
12
 
12
13
  def write(username, user_id)
13
- netrc["flatiron-push"] = username, user_id
14
+ netrc[machine] = username, user_id
14
15
  netrc.save
15
16
  end
16
17
  end
@@ -1,3 +1,5 @@
1
+ require 'yaml'
2
+
1
3
  module LearnTest
2
4
  class Runner
3
5
  attr_reader :repo, :options
@@ -33,6 +35,16 @@ module LearnTest
33
35
 
34
36
  private
35
37
 
38
+ def augment_results!(results)
39
+ if File.exist?("#{FileUtils.pwd}/.learn")
40
+ dot_learn = YAML.load(File.read("#{FileUtils.pwd}/.learn"))
41
+
42
+ if !dot_learn['github'].nil?
43
+ results[:github] = dot_learn['github']
44
+ end
45
+ end
46
+ end
47
+
36
48
  def connection
37
49
  @connection ||= Faraday.new(url: SERVICE_URL) do |faraday|
38
50
  faraday.adapter Faraday.default_adapter
@@ -53,11 +65,14 @@ module LearnTest
53
65
  end
54
66
 
55
67
  def push_results(strategy)
68
+ results = strategy.results
69
+ augment_results!(results)
70
+
56
71
  begin
57
72
  connection.post do |req|
58
73
  req.url(strategy.service_endpoint)
59
74
  req.headers['Content-Type'] = 'application/json'
60
- req.body = Oj.dump(strategy.results, mode: :compat)
75
+ req.body = Oj.dump(results, mode: :compat)
61
76
  end
62
77
  rescue Faraday::ConnectionFailed
63
78
  puts 'There was a problem connecting to Learn. Not pushing test results.'.red
@@ -34,6 +34,7 @@ module LearnTest
34
34
  @results ||= {
35
35
  username: username,
36
36
  github_user_id: user_id,
37
+ learn_oauth_token: learn_oauth_token,
37
38
  repo_name: runner.repo,
38
39
  build: {
39
40
  test_suite: [{
@@ -68,6 +69,10 @@ module LearnTest
68
69
  options[:skip] ? "none" : super
69
70
  end
70
71
 
72
+ def learn_oauth_token
73
+ options[:skip] ? nil : super
74
+ end
75
+
71
76
  private
72
77
 
73
78
  def set_up_runner
@@ -27,6 +27,7 @@ module LearnTest
27
27
  @results ||= {
28
28
  username: username,
29
29
  github_user_id: user_id,
30
+ learn_oauth_token: learn_oauth_token,
30
31
  repo_name: runner.repo,
31
32
  build: {
32
33
  test_suite: [{
@@ -31,6 +31,7 @@ module LearnTest
31
31
  @results ||= {
32
32
  username: username,
33
33
  github_user_id: user_id,
34
+ learn_oauth_token: learn_oauth_token,
34
35
  repo_name: runner.repo,
35
36
  build: {
36
37
  test_suite: [{
@@ -40,6 +40,7 @@ module LearnTest
40
40
  @results ||= {
41
41
  username: username,
42
42
  github_user_id: user_id,
43
+ learn_oauth_token: learn_oauth_token,
43
44
  repo_name: runner.repo,
44
45
  build: {
45
46
  test_suite: [{
@@ -65,6 +65,7 @@ module LearnTest
65
65
  @results ||= {
66
66
  username: username,
67
67
  github_user_id: user_id,
68
+ learn_oauth_token: learn_oauth_token,
68
69
  repo_name: runner.repo,
69
70
  build: {
70
71
  test_suite: [{
@@ -29,6 +29,7 @@ module LearnTest
29
29
  {
30
30
  username: username,
31
31
  github_user_id: user_id,
32
+ learn_oauth_token: learn_oauth_token,
32
33
  repo_name: runner.repo,
33
34
  build: {
34
35
  test_suite: [{
@@ -44,6 +44,7 @@ module LearnTest
44
44
  {
45
45
  username: username,
46
46
  github_user_id: user_id,
47
+ learn_oauth_token: learn_oauth_token,
47
48
  repo_name: runner.repo,
48
49
  build: {
49
50
  test_suite: [{
@@ -44,6 +44,10 @@ module LearnTest
44
44
  @user_id ||= LearnTest::UserIdParser.get_user_id
45
45
  end
46
46
 
47
+ def learn_oauth_token
48
+ @learn_oauth_token ||= LearnTest::LearnOauthTokenParser.get_learn_oauth_token
49
+ end
50
+
47
51
  def argv
48
52
  options[:argv]
49
53
  end
@@ -5,7 +5,7 @@ module LearnTest
5
5
  username = parser.username
6
6
  user_id = parser.user_id
7
7
 
8
- if !username || user_id == 'none'
8
+ if !LearnTest::LearnOauthTokenParser.get_learn_oauth_token && (!username || user_id == 'none')
9
9
  print "Enter your github username: "
10
10
  username = gets.strip
11
11
  user_id = LearnTest::GithubInteractor.get_user_id_for(username)
@@ -1,3 +1,3 @@
1
1
  module LearnTest
2
- VERSION = '2.3.3'
2
+ VERSION = '2.4.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.3
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flatiron School
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-27 00:00:00.000000000 Z
11
+ date: 2016-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -222,6 +222,7 @@ files:
222
222
  - lib/learn_test/dependency.rb
223
223
  - lib/learn_test/file_finder.rb
224
224
  - lib/learn_test/github_interactor.rb
225
+ - lib/learn_test/learn_oauth_token_parser.rb
225
226
  - lib/learn_test/netrc_interactor.rb
226
227
  - lib/learn_test/repo_parser.rb
227
228
  - lib/learn_test/runner.rb