learn-co 1.0.4 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -2
- data/LICENSE.txt +0 -1
- data/README.md +4 -5
- data/Rakefile +0 -1
- data/bin/learn +11 -69
- data/learn-co.gemspec +10 -11
- data/lib/learn.rb +4 -21
- data/lib/learn/cli.rb +78 -0
- data/lib/learn/lab/parser.rb +25 -0
- data/lib/learn/options_sanitizer.rb +164 -0
- data/lib/learn/version.rb +1 -1
- metadata +30 -97
- data/.rspec +0 -2
- data/lib/learn/file_finder.rb +0 -12
- data/lib/learn/github_interactor.rb +0 -23
- data/lib/learn/jasmine/boot.js +0 -184
- data/lib/learn/jasmine/console.js +0 -161
- data/lib/learn/jasmine/formatters/jasmine2-junit.js +0 -199
- data/lib/learn/jasmine/helpers/ConsoleHelper.js +0 -12
- data/lib/learn/jasmine/helpers/ConsoleHelperNoColor.js +0 -12
- data/lib/learn/jasmine/initializer.rb +0 -27
- data/lib/learn/jasmine/jasmine-html.js +0 -360
- data/lib/learn/jasmine/jasmine-jquery.js +0 -813
- data/lib/learn/jasmine/jasmine.css +0 -56
- data/lib/learn/jasmine/jasmine.js +0 -2403
- data/lib/learn/jasmine/jasmine_favicon.png +0 -0
- data/lib/learn/jasmine/jquery-1.8.0.min.js +0 -2
- data/lib/learn/jasmine/jquery-ui-1.8.23.custom.min.js +0 -125
- data/lib/learn/jasmine/phantom_checker.rb +0 -55
- data/lib/learn/jasmine/runner.rb +0 -129
- data/lib/learn/jasmine/runners/SpecRunner.html +0 -35
- data/lib/learn/jasmine/runners/run-jasmine.js +0 -228
- data/lib/learn/jasmine/templates/SpecRunnerTemplate.html.erb +0 -35
- data/lib/learn/jasmine/templates/SpecRunnerTemplateNoColor.html.erb +0 -35
- data/lib/learn/jasmine/templates/requires.yml.example +0 -7
- data/lib/learn/jasmine/vendor/require.js +0 -2077
- data/lib/learn/netrc_interactor.rb +0 -18
- data/lib/learn/python_unittest/nose_installer.rb +0 -35
- data/lib/learn/python_unittest/requirements_checker.rb +0 -57
- data/lib/learn/python_unittest/runner.rb +0 -89
- data/lib/learn/repo_parser.rb +0 -22
- data/lib/learn/rspec/runner.rb +0 -113
- data/lib/learn/spec_type_parser.rb +0 -26
- data/lib/learn/user_id_parser.rb +0 -9
- data/lib/learn/username_parser.rb +0 -19
- data/spec/features/jasmine_jquery_fixtures_spec.rb +0 -10
- data/spec/features/rspec_unit_spec.rb +0 -10
- data/spec/fixtures/jasmine-jquery-fixtures/index.html +0 -10
- data/spec/fixtures/jasmine-jquery-fixtures/requires.yml +0 -4
- data/spec/fixtures/jasmine-jquery-fixtures/spec/jasmine-jquery-fixtures-spec.js +0 -11
- data/spec/fixtures/rspec-unit-spec/.rspec +0 -2
- data/spec/fixtures/rspec-unit-spec/lib/dog.rb +0 -2
- data/spec/fixtures/rspec-unit-spec/spec/dog_spec.rb +0 -7
- data/spec/fixtures/rspec-unit-spec/spec/spec_helper.rb +0 -93
- data/spec/repo_parser_spec.rb +0 -25
- data/spec/spec_helper.rb +0 -10
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'netrc'
|
2
|
-
|
3
|
-
module Learn
|
4
|
-
class NetrcInteractor
|
5
|
-
attr_reader :username, :user_id, :netrc
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@netrc = Netrc.read
|
9
|
-
@username, @user_id = netrc["flatiron-push"]
|
10
|
-
end
|
11
|
-
|
12
|
-
def write(username, user_id)
|
13
|
-
netrc["flatiron-push"] = username, user_id
|
14
|
-
netrc.save
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module Learn
|
2
|
-
module PythonUnittest
|
3
|
-
class NoseInstaller
|
4
|
-
def self.install
|
5
|
-
new.install
|
6
|
-
end
|
7
|
-
|
8
|
-
def install
|
9
|
-
install_nose
|
10
|
-
install_nose_json
|
11
|
-
end
|
12
|
-
|
13
|
-
def install_nose
|
14
|
-
if !nose_installed?
|
15
|
-
`pip install nose`
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def nose_installed?
|
20
|
-
!`which nosetests`.empty?
|
21
|
-
end
|
22
|
-
|
23
|
-
def install_nose_json
|
24
|
-
if !nose_json_installed?
|
25
|
-
`pip install nose-json`
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def nose_json_installed?
|
30
|
-
!`pip show nose-json`.empty?
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'open3'
|
2
|
-
|
3
|
-
module Learn
|
4
|
-
module PythonUnittest
|
5
|
-
class RequirementsChecker
|
6
|
-
def self.check_installation
|
7
|
-
new.check_installation
|
8
|
-
end
|
9
|
-
|
10
|
-
def check_installation
|
11
|
-
PythonChecker.check
|
12
|
-
PipChecker.check
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class PythonChecker
|
17
|
-
def self.check
|
18
|
-
new.check
|
19
|
-
end
|
20
|
-
|
21
|
-
def check
|
22
|
-
if !python_installed? || !correct_python_version?
|
23
|
-
puts "Please install python 2.7.x or 3.x.x"
|
24
|
-
exit
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def python_installed?
|
29
|
-
!`which python`.empty?
|
30
|
-
end
|
31
|
-
|
32
|
-
def correct_python_version?
|
33
|
-
output = Open3.popen3('python', '--version')
|
34
|
-
version = output[2].read.strip
|
35
|
-
!!version.match(/ 2.7.*| 3.*/)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class PipChecker
|
40
|
-
def self.check
|
41
|
-
new.check
|
42
|
-
end
|
43
|
-
|
44
|
-
def check
|
45
|
-
if !pip_installed?
|
46
|
-
puts "Please ensure pip is installed"
|
47
|
-
exit
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def pip_installed?
|
52
|
-
!`which pip`.empty?
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
@@ -1,89 +0,0 @@
|
|
1
|
-
module Learn
|
2
|
-
module PythonUnittest
|
3
|
-
class Runner
|
4
|
-
attr_accessor :parsed_output, :json_output, :formatted_results
|
5
|
-
attr_reader :username, :user_id, :repo_name, :options, :connection
|
6
|
-
|
7
|
-
def initialize(username, user_id, repo_name, options)
|
8
|
-
@username = username
|
9
|
-
@user_id = user_id
|
10
|
-
@repo_name = repo_name
|
11
|
-
@options = options
|
12
|
-
@json_output = ""
|
13
|
-
@parsed_output = nil
|
14
|
-
@formatted_results = {}
|
15
|
-
@connection = Faraday.new(url: SERVICE_URL) do |faraday|
|
16
|
-
faraday.adapter Faraday.default_adapter
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
run_nose
|
22
|
-
if !options.include?('-h') && !options.include?('--help')
|
23
|
-
set_json_output
|
24
|
-
jsonify
|
25
|
-
format_results
|
26
|
-
push_results
|
27
|
-
cleanup
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def run_nose
|
32
|
-
system("nosetests #{options.join(' ')} --verbose --with-json --json-file='./.results.json'")
|
33
|
-
end
|
34
|
-
|
35
|
-
def set_json_output
|
36
|
-
self.json_output = File.read('.results.json')
|
37
|
-
end
|
38
|
-
|
39
|
-
def jsonify
|
40
|
-
self.parsed_output = Oj.load(json_output, symbol_keys: true)
|
41
|
-
end
|
42
|
-
|
43
|
-
def format_results
|
44
|
-
self.formatted_results.merge!({
|
45
|
-
username: username,
|
46
|
-
github_user_id: user_id,
|
47
|
-
repo_name: repo_name,
|
48
|
-
build: {
|
49
|
-
test_suite: [{
|
50
|
-
framework: 'unittest',
|
51
|
-
formatted_output: parsed_output,
|
52
|
-
duration: calculate_duration
|
53
|
-
}]
|
54
|
-
},
|
55
|
-
examples: parsed_output[:stats][:total],
|
56
|
-
passing_count: parsed_output[:stats][:passes],
|
57
|
-
pending_count: parsed_output[:stats][:skipped],
|
58
|
-
failure_count: parsed_output[:stats][:errors],
|
59
|
-
failure_descriptions: concat_failure_descriptions
|
60
|
-
})
|
61
|
-
end
|
62
|
-
|
63
|
-
def calculate_duration
|
64
|
-
parsed_output[:results].map do |example|
|
65
|
-
example[:time]
|
66
|
-
end.inject(:+)
|
67
|
-
end
|
68
|
-
|
69
|
-
def concat_failure_descriptions
|
70
|
-
parsed_output[:results].select do |example|
|
71
|
-
example[:type] == 'failure'
|
72
|
-
end.map { |ex| ex[:tb] }.join(';')
|
73
|
-
end
|
74
|
-
|
75
|
-
def push_results
|
76
|
-
connection.post do |req|
|
77
|
-
req.url SERVICE_ENDPOINT
|
78
|
-
req.headers['Content-Type'] = 'application/json'
|
79
|
-
req.body = Oj.dump(formatted_results, mode: :compat)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def cleanup
|
84
|
-
FileUtils.rm('.results.json')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
data/lib/learn/repo_parser.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'git'
|
2
|
-
|
3
|
-
module Learn
|
4
|
-
class RepoParser
|
5
|
-
def self.get_repo
|
6
|
-
begin
|
7
|
-
repo = Git.open(FileUtils.pwd)
|
8
|
-
rescue
|
9
|
-
puts "Not a valid Git repository"
|
10
|
-
die
|
11
|
-
end
|
12
|
-
|
13
|
-
url = repo.remote.url
|
14
|
-
url.match(/(?:https:\/\/|git@).*\/(.+?)(?:\.git)?$/)[1]
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.die
|
18
|
-
exit
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
data/lib/learn/rspec/runner.rb
DELETED
@@ -1,113 +0,0 @@
|
|
1
|
-
module Learn
|
2
|
-
module RSpec
|
3
|
-
class Runner
|
4
|
-
attr_accessor :parsed_output, :json_output, :formatted_results
|
5
|
-
attr_reader :username, :user_id, :repo_name, :options, :connection
|
6
|
-
|
7
|
-
def initialize(username, user_id, repo_name, options)
|
8
|
-
@username = username
|
9
|
-
@user_id = user_id
|
10
|
-
@repo_name = repo_name
|
11
|
-
@options = options
|
12
|
-
@json_output = ""
|
13
|
-
@parsed_output = nil
|
14
|
-
@formatted_results = {}
|
15
|
-
@connection = Faraday.new(url: SERVICE_URL) do |faraday|
|
16
|
-
faraday.adapter Faraday.default_adapter
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
check_options
|
22
|
-
run_rspec
|
23
|
-
if !options.include?('-h') && !options.include?('--help')
|
24
|
-
set_json_output
|
25
|
-
jsonify
|
26
|
-
format_results
|
27
|
-
push_results
|
28
|
-
cleanup
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def check_options
|
33
|
-
options_has_format = options.include?('--format') || options.include?('-f')
|
34
|
-
if dot_rspec = read_dot_rspec
|
35
|
-
if options_has_format
|
36
|
-
if dot_rspec.any? {|dot_opt| dot_opt.match(/--format|-f/)}
|
37
|
-
options << dot_rspec.reject {|dot_opt| dot_opt.match(/--format|-f/)}
|
38
|
-
else
|
39
|
-
options << dot_rspec
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
if options_has_format
|
45
|
-
self.options.flatten!
|
46
|
-
else
|
47
|
-
options.unshift('--format documentation')
|
48
|
-
end
|
49
|
-
|
50
|
-
# Don't pass the test/local flag from learn binary to rspec runner.
|
51
|
-
options.delete("--test")
|
52
|
-
options.delete("-t")
|
53
|
-
options.delete("-l")
|
54
|
-
options.delete("--local")
|
55
|
-
end
|
56
|
-
|
57
|
-
def read_dot_rspec
|
58
|
-
if File.exist?('.rspec')
|
59
|
-
File.readlines('.rspec').map(&:strip)
|
60
|
-
else
|
61
|
-
nil
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def run_rspec
|
66
|
-
system("rspec #{options.join(' ')} --format j --out .results.json")
|
67
|
-
end
|
68
|
-
|
69
|
-
def set_json_output
|
70
|
-
self.json_output = File.read('.results.json')
|
71
|
-
end
|
72
|
-
|
73
|
-
def jsonify
|
74
|
-
self.parsed_output = Oj.load(json_output, symbol_keys: true)
|
75
|
-
end
|
76
|
-
|
77
|
-
def format_results
|
78
|
-
self.formatted_results.merge!({
|
79
|
-
username: username,
|
80
|
-
github_user_id: user_id,
|
81
|
-
repo_name: repo_name,
|
82
|
-
build: {
|
83
|
-
test_suite: [{
|
84
|
-
framework: 'rspec',
|
85
|
-
formatted_output: parsed_output,
|
86
|
-
duration: parsed_output[:summary][:duration]
|
87
|
-
}]
|
88
|
-
},
|
89
|
-
examples: parsed_output[:summary][:example_count],
|
90
|
-
passing_count: parsed_output[:summary][:example_count] - parsed_output[:summary][:failure_count] - parsed_output[:summary][:pending_count],
|
91
|
-
pending_count: parsed_output[:summary][:pending_count],
|
92
|
-
failure_count: parsed_output[:summary][:failure_count],
|
93
|
-
failure_descriptions: parsed_output[:examples].select do |example|
|
94
|
-
example[:status] == "failed"
|
95
|
-
end.map { |ex| ex[:full_description] }.join(";")
|
96
|
-
})
|
97
|
-
end
|
98
|
-
|
99
|
-
def push_results
|
100
|
-
connection.post do |req|
|
101
|
-
req.url SERVICE_ENDPOINT
|
102
|
-
req.headers['Content-Type'] = 'application/json'
|
103
|
-
req.body = Oj.dump(formatted_results, mode: :compat)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def cleanup
|
108
|
-
FileUtils.rm('.results.json')
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Learn
|
2
|
-
class SpecTypeParser
|
3
|
-
attr_reader :spec_type
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@spec_type = parse_spec_type
|
7
|
-
end
|
8
|
-
|
9
|
-
private
|
10
|
-
|
11
|
-
def parse_spec_type
|
12
|
-
files = Dir.entries('.')
|
13
|
-
|
14
|
-
if files.include?('requires.yml')
|
15
|
-
'jasmine'
|
16
|
-
elsif files.any? {|f| f.match(/.*.py$/) }
|
17
|
-
'python_unittest'
|
18
|
-
elsif files.include?('spec')
|
19
|
-
spec_files = Dir.entries('./spec')
|
20
|
-
if spec_files.include?('spec_helper.rb') || spec_files.include?('rails_helper.rb')
|
21
|
-
'rspec'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
data/lib/learn/user_id_parser.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Learn
|
2
|
-
class UsernameParser
|
3
|
-
def self.get_username
|
4
|
-
parser = Learn::NetrcInteractor.new
|
5
|
-
username = parser.username
|
6
|
-
user_id = parser.user_id
|
7
|
-
|
8
|
-
if !username || user_id == 'none'
|
9
|
-
print "Enter your github username: "
|
10
|
-
username = gets.strip
|
11
|
-
user_id = Learn::GithubInteractor.get_user_id_for(username)
|
12
|
-
parser.write(username, user_id)
|
13
|
-
end
|
14
|
-
|
15
|
-
username
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
@@ -1,10 +0,0 @@
|
|
1
|
-
describe "Running a Jasmine jQuery Specs with Fixtures" do
|
2
|
-
context 'without a browser through PhantomJS' do
|
3
|
-
it 'runs the spec with 0 failures' do
|
4
|
-
output = `cd ./spec/fixtures/jasmine-jquery-fixtures && ./../../../bin/learn --local --test`
|
5
|
-
|
6
|
-
expect(output).to include('1 spec, 0 failures')
|
7
|
-
expect(output).to_not include('1 failures')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
describe "Running a RSpec Unit Test" do
|
2
|
-
context 'a basic rspec unit test' do
|
3
|
-
it 'runs the spec with 0 failures' do
|
4
|
-
output = `cd ./spec/fixtures/rspec-unit-spec && ./../../../bin/learn --local --test`
|
5
|
-
|
6
|
-
expect(output).to include('1 example, 0 failures')
|
7
|
-
expect(output).to_not include('1 failures')
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
'use-strict';
|
2
|
-
|
3
|
-
describe('Using a local HTML fixture with jQuery', function() {
|
4
|
-
beforeEach(function() {
|
5
|
-
loadFixtures('index.html');
|
6
|
-
});
|
7
|
-
|
8
|
-
it('can use jQuery against a local fixture', function() {
|
9
|
-
expect($('h1').text()).toBe('Hello World');
|
10
|
-
});
|
11
|
-
});
|