bloc 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.0.8
2
+
3
+ * run_tests moved to Manifest.run_tests (since we want to run bloc.validate on resync)
4
+
1
5
  ### 0.0.7
2
6
 
3
7
  * test results are included in validation now, but only if a patch exists
@@ -8,8 +8,7 @@ module Bloc
8
8
  VALID_DEFAULT_CHAPTER_FILE = "Default file for chapter exists (OK): %s".green
9
9
  INVALID_DEFAULT_CHAPTER_FILE = "Default file for chapter does not exist: %s (expected %s)".red
10
10
  NO_SUCH_PATCH = "Patch not found: %s".red
11
- TEST_FAILURE = "Failed test:\n%s".red
12
- TEST_PASSED = "Passed: %s".green
11
+ PATCH_EXISTS = "Patch exists: %s".green
13
12
 
14
13
  def self.run(*args)
15
14
  manifest = Manifest.parse
@@ -18,7 +17,6 @@ module Bloc
18
17
  check_patches manifest
19
18
  end
20
19
 
21
-
22
20
  def self.check_course_default_file(manifest)
23
21
  course_default_file = manifest.course.default_file
24
22
  if course_default_file.nil?
@@ -48,36 +46,14 @@ module Bloc
48
46
 
49
47
  def self.check_patches(manifest)
50
48
  # TODO: ensure all chapters have patches
51
- begin
52
- `mv .git .git.backup`
53
- `git init`
54
- `git add .`
55
- `git commit -m "initial"`
56
- manifest.chapters.each do |chapter|
57
- unless chapter.patch_exists?
58
- raise NO_SUCH_PATCH % chapter.patch
59
- end
60
- chapter.apply_patch
61
- unless chapter.patch.nil?
62
- results = chapter.test
63
- results["tests"].each do |test|
64
- if test["passed"]
65
- puts TEST_PASSED % test["name"]
66
- else
67
- raise TEST_FAILURE % JSON.pretty_generate(results)
68
- end
69
- end
70
- end
49
+ manifest.chapters.each do |chapter|
50
+ if chapter.patch_exists?
51
+ puts PATCH_EXISTS % chapter.patch
52
+ else
53
+ raise NO_SUCH_PATCH % chapter.patch
71
54
  end
72
- rescue Exception => e
73
- raise e
74
- ensure
75
- `git checkout .`
76
- `rm -rf .git`
77
- `mv .git.backup .git`
78
55
  end
79
56
  end
80
-
81
57
  end
82
58
  end
83
59
  end
data/lib/bloc/manifest.rb CHANGED
@@ -48,5 +48,24 @@ module Bloc
48
48
  end
49
49
  Manifest.new({"course" => course, "chapters" => chapters})
50
50
  end
51
+
52
+ def run_tests
53
+ begin
54
+ `mv .git .git.backup`
55
+ `git init`
56
+ `git add .`
57
+ `git commit -m "initial"`
58
+
59
+ @chapters.each do |chapter|
60
+ chapter.run_tests
61
+ end
62
+ rescue
63
+ raise e
64
+ ensure
65
+ `git checkout .`
66
+ `rm -rf .git`
67
+ `mv .git.backup .git`
68
+ end
69
+ end
51
70
  end
52
71
  end
data/lib/bloc/models.rb CHANGED
@@ -7,6 +7,8 @@ module Bloc
7
7
  include HashConstructed
8
8
  include ToHash
9
9
  attr_accessor :name, :description, :default_file
10
+
11
+
10
12
  end
11
13
 
12
14
  class Chapter
@@ -14,6 +16,29 @@ module Bloc
14
16
  include ToHash
15
17
  attr_accessor :name, :command, :markdown, :default_file, :patch, :cursor_row, :cursor_column
16
18
 
19
+ TEST_FAILURE = "Failed test:\n%s".red
20
+ TEST_PASSED = "Passed: %s".green
21
+
22
+ def run_tests
23
+ apply_patch
24
+ unless @patch.nil?
25
+ results = test
26
+ results["tests"].each do |test_result|
27
+ if test_result["passed"]
28
+ puts TEST_PASSED % test_result["name"]
29
+ else
30
+ raise TEST_FAILURE % test_result["name"]
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ def patch_exists?
37
+ File.exists?("bloc/#{@patch}")
38
+ end
39
+
40
+ private
41
+
17
42
  def test
18
43
  `#{@command}`
19
44
  results = JSON.parse(File.read("results.json"))
@@ -21,10 +46,6 @@ module Bloc
21
46
  results
22
47
  end
23
48
 
24
- def patch_exists?
25
- File.exists?("bloc/#{@patch}")
26
- end
27
-
28
49
  def apply_patch
29
50
  unless @patch.nil?
30
51
  `patch < bloc/#{@patch}`
data/lib/bloc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bloc
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bloc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2012-03-05 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
17
- requirement: &70185906519900 !ruby/object:Gem::Requirement
17
+ requirement: &70257638615020 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *70185906519900
25
+ version_requirements: *70257638615020
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: fakefs
28
- requirement: &70185906519480 !ruby/object:Gem::Requirement
28
+ requirement: &70257638614600 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *70185906519480
36
+ version_requirements: *70257638614600
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: ruby-debug19
39
- requirement: &70185906519060 !ruby/object:Gem::Requirement
39
+ requirement: &70257638614180 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70185906519060
47
+ version_requirements: *70257638614180
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: json
50
- requirement: &70185906518640 !ruby/object:Gem::Requirement
50
+ requirement: &70257638613760 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *70185906518640
58
+ version_requirements: *70257638613760
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: colorize
61
- requirement: &70185906518220 !ruby/object:Gem::Requirement
61
+ requirement: &70257638613340 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *70185906518220
69
+ version_requirements: *70257638613340
70
70
  description: A command-line tool for Bloc
71
71
  email:
72
72
  - roshan.choxi@gmail.com