commit-live-cli 0.0.13 → 0.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47eab11485d97b319cfe86b06681d66c474bdc88
4
- data.tar.gz: cf16223e13c52a45422f4a90c66f46660b605cae
3
+ metadata.gz: e7d087ed2ece99b39781fc88a31f6ad778b9d51e
4
+ data.tar.gz: 034efbe8861b7d13f59da283418f29639e976734
5
5
  SHA512:
6
- metadata.gz: d167094a0053f99a311445cf3723dd2aa2d662514882ece1f873b439b09e4c838c6d9f25d021e34a0a953c0380a501abcb5af8b5bdec66a4939300988f35c3e0
7
- data.tar.gz: 61561352d2902a28f543e346677a3a3b35018f1a0ba975b5b5e2889626a9092352636e69fd98535682887ffd1327089651259ca32e4e743e5b5be16b7632f54e
6
+ metadata.gz: 07d52777b0fa3e9cef684f37fded154bb8ebe4c1c6f25dccc08088c9ba7f8a516d2cd1c2c7bd8da7a4890ef7796701edf15e49156c90989acd3e6eb0db168205
7
+ data.tar.gz: 163bb38d935af132654c3a74ae54c672eb8dffc3738b20a4728ba703521e69f7375b8498d0f2fd70eb7ca547a3792d5c0441052efb550beca01119a02ec7ca84
@@ -5,8 +5,8 @@ module CommitLive
5
5
  class API
6
6
  attr_reader :conn
7
7
 
8
- def initialize()
9
- endpoint = CommitLive::Endpoint.new.get()
8
+ def initialize(api_url = nil)
9
+ endpoint = api_url || CommitLive::Endpoint.new.get()
10
10
  @conn = Faraday.new(url: endpoint) do |faraday|
11
11
  faraday.adapter Faraday.default_adapter
12
12
  end
@@ -50,7 +50,6 @@ module CommitLive
50
50
 
51
51
  desc "test", "This will test you"
52
52
  def test()
53
- puts 'Testing...'
54
53
  CommitLive::Test.new().run
55
54
  end
56
55
 
@@ -89,12 +89,10 @@ module CommitLive
89
89
  end
90
90
 
91
91
  def addChanges
92
- puts 'Adding changes...'
93
92
  git.add(all: true)
94
93
  end
95
94
 
96
95
  def commitChanges
97
- puts 'Committing changes...'
98
96
  begin
99
97
  git.commit('Done')
100
98
  rescue Git::GitExecuteError => e
@@ -4,6 +4,7 @@ require "commit-live/api"
4
4
  require "commit-live/github"
5
5
  require 'octokit'
6
6
  require 'git'
7
+ require "oj"
7
8
 
8
9
  module CommitLive
9
10
  class Open
@@ -46,7 +47,7 @@ module CommitLive
46
47
 
47
48
  def openALesson(puzzle_name)
48
49
  # get currently active lesson
49
- puts "Getting current lesson..."
50
+ puts "Getting lesson..."
50
51
  lesson.getCurrentLesson(puzzle_name)
51
52
 
52
53
  if !ALLOWED_TYPES.include? lesson_type
@@ -67,6 +68,9 @@ module CommitLive
67
68
  if lesson_type == "LAB" && !lesson_forked
68
69
  lesson_status.update('forked', lesson_name)
69
70
  end
71
+ if lesson_type == "PRACTICE"
72
+ open_lesson
73
+ end
70
74
  end
71
75
  # install dependencies
72
76
  # cd into it and invoke bash
@@ -116,5 +120,33 @@ module CommitLive
116
120
  puts "Done."
117
121
  exec("#{ENV['SHELL']} -l")
118
122
  end
123
+
124
+ def open_lesson
125
+ begin
126
+ Timeout::timeout(15) do
127
+ api = CommitLive::API.new("https://chat.commit.live")
128
+ netrc = CommitLive::NetrcInteractor.new()
129
+ netrc.read(machine: 'ga-extra')
130
+ username = netrc.login
131
+ url = URI.escape("/send/#{username}")
132
+ message = {
133
+ 'type': 'open-lesson',
134
+ 'title': lesson_name
135
+ }
136
+ response = api.post(
137
+ url,
138
+ headers: {
139
+ 'content-type': 'application/json',
140
+ },
141
+ body: {
142
+ 'message': Oj.dump(message, mode: :compat),
143
+ }
144
+ )
145
+ end
146
+ rescue Timeout::Error
147
+ puts "Open Lesson WebSocket call failed."
148
+ exit
149
+ end
150
+ end
119
151
  end
120
152
  end
@@ -12,7 +12,6 @@ module CommitLive
12
12
  end
13
13
 
14
14
  def update(type, trackName)
15
- puts 'Updating lesson status...'
16
15
  begin
17
16
  Timeout::timeout(15) do
18
17
  netrc.read
@@ -55,15 +55,19 @@ module CommitLive
55
55
 
56
56
  def run(updateStatus = true)
57
57
  clear_changes_in_tests
58
+ puts 'Testing lesson...'
58
59
  strategy.check_dependencies
59
60
  strategy.configure
60
61
  results = strategy.run
61
62
  if updateStatus
62
63
  if results
63
64
  # test case passed
65
+ puts 'Great! You have passed all the test cases.'
66
+ puts 'Use `clive submit` to push your changes.'
64
67
  CommitLive::Status.new().update('test_case_pass', lesson_name)
65
68
  else
66
69
  # test case failed
70
+ puts 'Oops! You still have to pass all the test cases.'
67
71
  CommitLive::Status.new().update('test_case_fail', lesson_name)
68
72
  end
69
73
  end
@@ -71,7 +75,6 @@ module CommitLive
71
75
  dump_results
72
76
  end
73
77
  strategy.cleanup
74
- puts 'Done.'
75
78
  return results
76
79
  end
77
80
 
@@ -1,5 +1,5 @@
1
1
  module CommitLive
2
2
  module Cli
3
- VERSION = "0.0.13"
3
+ VERSION = "0.0.14"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: commit-live-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - greyatom
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-24 00:00:00.000000000 Z
11
+ date: 2017-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler