roku_builder 4.25.6 → 4.26.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
  SHA256:
3
- metadata.gz: 9b926c96062054e546bb423d2031bc48446a3c716c2488c6756882a6218d22e2
4
- data.tar.gz: 6748df137a4374f34b2c91aebac0a4e1c77129753c835f86d1ac61c9b3999f9b
3
+ metadata.gz: 8cef81268ceb5755dd1f33511fb33d40231b82f148b1cab085674a640a84422f
4
+ data.tar.gz: b76b0aec49eb4a465793cbe2db2e504aaef61c6ca5e0202e4365521c5f665ab3
5
5
  SHA512:
6
- metadata.gz: 42ff1860aded5097863dd4bd6b721d78f24e1e99888b365cb2a84dd98878c74599efc4be91c56d6b6f50b706d2eb3ce73bc75ab25ded7829a4a3325ece71a023
7
- data.tar.gz: 7b531741d6cab2f47739892edb54aeae709fe53fa44b18dcaa97a22dc112767bd323644289be3041eac1de56b12f002b562e06714a5d116b6c45510cdd1a62ce
6
+ metadata.gz: 9d85a36f9aa407e5b7cb5927f98ffca2d0c3ec67ca3282b3371c75abe41ea0378fef06fe06917d85c00e248f64aa6af4265850a15bf4bd9bd47ba22c208b8ef3
7
+ data.tar.gz: 24573d389ea6c02a025512e6ec0092adbe3934d0b0322a9ca8a0aef47b2cc6f311ee8b3b945c9b63201a7eaed2532a925f0243971d069341aa16ddc6cd69352c
@@ -47,17 +47,38 @@ module RokuBuilder
47
47
  match = nil
48
48
  start = 0
49
49
  loop do
50
+ stop = to_check.length-1
51
+ pass_match = nil
52
+ if line_inspector[:pass_if_match]
53
+ if line_inspector[:case_sensitive]
54
+ pass_match = /#{line_inspector[:pass_test_regexp]}/.match(to_check[start..stop])
55
+ else
56
+ pass_match = /#{line_inspector[:pass_test_regexp]}/i.match(to_check[start..stop])
57
+ end
58
+ break unless pass_match
59
+ stop = to_check.index("\n", start)
60
+ stop ||= to_check.length-1
61
+ end
50
62
  if line_inspector[:case_sensitive]
51
- match = /#{line_inspector[:regex]}/.match(to_check, start)
63
+ match = /#{line_inspector[:regex]}/.match(to_check[start..stop])
52
64
  else
53
- match = /#{line_inspector[:regex]}/i.match(to_check, start)
65
+ match = /#{line_inspector[:regex]}/i.match(to_check[start..stop])
54
66
  end
55
- if match
56
- start = match.end(0)
57
- line_number = to_check[0..match.begin(0)].split("\n", -1).count - 1
67
+ if (not line_inspector[:pass_if_match] and match) or (line_inspector[:pass_if_match] and not match)
68
+ error_match = match
69
+ if match
70
+ start = match.end(0)
71
+ line_number = to_check[0..match.begin(0)].split("\n", -1).count - 1
72
+ else
73
+ error_match = pass_match
74
+ line_number = to_check[0..start].split("\n", -1).count - 1
75
+ start = stop
76
+ end
58
77
  unless lines_to_ignore.include?(line_number)
59
- add_warning(inspector: line_inspector, file: file_path, line: line_number, match: match)
78
+ add_warning(inspector: line_inspector, file: file_path, line: line_number, match: error_match)
60
79
  end
80
+ elsif line_inspector[:pass_if_match]
81
+ start = stop +1
61
82
  else
62
83
  break
63
84
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module RokuBuilder
4
4
  # Version of the RokuBuilder Gem
5
- VERSION = "4.25.6"
5
+ VERSION = "4.26.0"
6
6
  end
@@ -26,6 +26,8 @@ module RokuBuilder
26
26
  def teardown
27
27
  manifest = File.join(@root_dir, "manifest")
28
28
  FileUtils.rm(manifest) if File.exist?(manifest)
29
+ linter_config = File.join(@root_dir, ".roku_builder_linter.json")
30
+ FileUtils.rm(linter_config) if File.exist?(linter_config)
29
31
  @request_stubs.each {|req| remove_request_stub(req)}
30
32
  end
31
33
  def test_analyzer_parse_commands
@@ -100,10 +102,27 @@ module RokuBuilder
100
102
  warnings = test_file(text: "For each button in buttons\n ? button\nEND FOR")
101
103
  assert_equal 0, warnings.count
102
104
  end
105
+ def test_linter_checks
106
+ set_linter_config("dont_use_hello_world.json")
107
+ warnings = test_file(text: "hello world")
108
+ assert_equal 1, warnings.count
109
+ end
110
+ def test_linter_positive_match
111
+ set_linter_config("linter_positive_match.json")
112
+ warnings = test_file(text: "hello world\nhello moon")
113
+ assert_equal 1, warnings.count
114
+ assert_equal 1, warnings.first[:line]
115
+ end
103
116
 
104
117
 
105
118
  private
106
119
 
120
+ def set_linter_config(config_file = nil)
121
+ if config_file
122
+ FileUtils.cp(File.join(@root_dir, config_file), File.join(@root_dir, ".roku_builder_linter.json"))
123
+ end
124
+ end
125
+
107
126
  def test_manifest(manifest_file = nil)
108
127
  if manifest_file
109
128
  use_manifest(manifest_file)
@@ -0,0 +1,11 @@
1
+ {
2
+ "is_ssai": true,
3
+ "rules": [
4
+ {
5
+ "regex": "hello world",
6
+ "case_sensitive": true,
7
+ "severity": "warning",
8
+ "message": "dont use hello world"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "is_ssai": true,
3
+ "rules": [
4
+ {
5
+ "pass_if_match": true,
6
+ "pass_test_regexp": "hello",
7
+ "regex": "hello world",
8
+ "case_sensitive": true,
9
+ "severity": "warning",
10
+ "message": "dont use hello world"
11
+ }
12
+ ]
13
+ }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roku_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.25.6
4
+ version: 4.26.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - greeneca
@@ -543,6 +543,7 @@ files:
543
543
  - test/roku_builder/test_config_validator.rb
544
544
  - test/roku_builder/test_device_manager.rb
545
545
  - test/roku_builder/test_files/analyzer_test/analyzer_config.json
546
+ - test/roku_builder/test_files/analyzer_test/dont_use_hello_world.json
546
547
  - test/roku_builder/test_files/analyzer_test/images/focus.png
547
548
  - test/roku_builder/test_files/analyzer_test/images/focus_hd.png
548
549
  - test/roku_builder/test_files/analyzer_test/images/focus_sd.png
@@ -550,6 +551,7 @@ files:
550
551
  - test/roku_builder/test_files/analyzer_test/images/splash_hd.png
551
552
  - test/roku_builder/test_files/analyzer_test/images/splash_sd.png
552
553
  - test/roku_builder/test_files/analyzer_test/images/too_small.png
554
+ - test/roku_builder/test_files/analyzer_test/linter_positive_match.json
553
555
  - test/roku_builder/test_files/analyzer_test/manifest_depricated_attribute
554
556
  - test/roku_builder/test_files/analyzer_test/manifest_duplicate_attribute
555
557
  - test/roku_builder/test_files/analyzer_test/manifest_empty_value
@@ -672,6 +674,7 @@ test_files:
672
674
  - test/roku_builder/test_config_validator.rb
673
675
  - test/roku_builder/test_device_manager.rb
674
676
  - test/roku_builder/test_files/analyzer_test/analyzer_config.json
677
+ - test/roku_builder/test_files/analyzer_test/dont_use_hello_world.json
675
678
  - test/roku_builder/test_files/analyzer_test/images/focus.png
676
679
  - test/roku_builder/test_files/analyzer_test/images/focus_hd.png
677
680
  - test/roku_builder/test_files/analyzer_test/images/focus_sd.png
@@ -679,6 +682,7 @@ test_files:
679
682
  - test/roku_builder/test_files/analyzer_test/images/splash_hd.png
680
683
  - test/roku_builder/test_files/analyzer_test/images/splash_sd.png
681
684
  - test/roku_builder/test_files/analyzer_test/images/too_small.png
685
+ - test/roku_builder/test_files/analyzer_test/linter_positive_match.json
682
686
  - test/roku_builder/test_files/analyzer_test/manifest_depricated_attribute
683
687
  - test/roku_builder/test_files/analyzer_test/manifest_duplicate_attribute
684
688
  - test/roku_builder/test_files/analyzer_test/manifest_empty_value