axr 0.6.2 → 0.7.1
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 +4 -4
- data/.rubocop.yml +3 -0
- data/.travis.yml +4 -3
- data/Gemfile.lock +10 -10
- data/README.md +26 -16
- data/docs/images/erp_example.png +0 -0
- data/lib/axr/cli.rb +7 -4
- data/lib/axr/runner.rb +9 -6
- data/lib/axr/scanner.rb +4 -4
- data/lib/axr/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f72dad434e267f3a0b9576b013af83a164ac2bf87f3879b1652f17df793627fc
|
4
|
+
data.tar.gz: 91c2b57c9b973ca7069eca9b14363d73abd0f56bcbfa1ddb71a6342030d60c88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35a230de00be2d28acb46c438287dd641900e03429f05928a9734d603cac8af7f3e6654b3b5683670936514c606f163cb5a99d940ad559b1705111273bb1d08c
|
7
|
+
data.tar.gz: cbe88f73c7e2e543c46d5d2a9a940b6fa92eb9e3a62143dcc1124b54baf2b51592265449394ca4eee910b39d0497609277648b0006e4095e574e01781c61ddff
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
axr (0.
|
4
|
+
axr (0.7.1)
|
5
5
|
colorize (~> 0.8.1)
|
6
6
|
thor (~> 0.20)
|
7
7
|
|
@@ -12,7 +12,7 @@ GEM
|
|
12
12
|
coderay (1.1.2)
|
13
13
|
colorize (0.8.1)
|
14
14
|
diff-lcs (1.3)
|
15
|
-
ffi (1.
|
15
|
+
ffi (1.12.2)
|
16
16
|
formatador (0.2.5)
|
17
17
|
guard (2.16.1)
|
18
18
|
formatador (>= 0.2.4)
|
@@ -32,14 +32,14 @@ GEM
|
|
32
32
|
listen (3.2.1)
|
33
33
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
34
34
|
rb-inotify (~> 0.9, >= 0.9.10)
|
35
|
-
lumberjack (1.
|
35
|
+
lumberjack (1.2.4)
|
36
36
|
method_source (0.9.2)
|
37
37
|
nenv (0.3.0)
|
38
38
|
notiffany (0.1.3)
|
39
39
|
nenv (~> 0.1)
|
40
40
|
shellany (~> 0.0)
|
41
41
|
parallel (1.19.1)
|
42
|
-
parser (2.7.0.
|
42
|
+
parser (2.7.0.5)
|
43
43
|
ast (~> 2.4.0)
|
44
44
|
pry (0.12.2)
|
45
45
|
coderay (~> 1.1.0)
|
@@ -53,15 +53,15 @@ GEM
|
|
53
53
|
rspec-core (~> 3.9.0)
|
54
54
|
rspec-expectations (~> 3.9.0)
|
55
55
|
rspec-mocks (~> 3.9.0)
|
56
|
-
rspec-core (3.9.
|
57
|
-
rspec-support (~> 3.9.
|
58
|
-
rspec-expectations (3.9.
|
56
|
+
rspec-core (3.9.1)
|
57
|
+
rspec-support (~> 3.9.1)
|
58
|
+
rspec-expectations (3.9.1)
|
59
59
|
diff-lcs (>= 1.2.0, < 2.0)
|
60
60
|
rspec-support (~> 3.9.0)
|
61
|
-
rspec-mocks (3.9.
|
61
|
+
rspec-mocks (3.9.1)
|
62
62
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
63
|
rspec-support (~> 3.9.0)
|
64
|
-
rspec-support (3.9.
|
64
|
+
rspec-support (3.9.2)
|
65
65
|
rubocop (0.76.0)
|
66
66
|
jaro_winkler (~> 1.5.1)
|
67
67
|
parallel (~> 1.10)
|
@@ -72,7 +72,7 @@ GEM
|
|
72
72
|
ruby-progressbar (1.10.1)
|
73
73
|
shellany (0.0.1)
|
74
74
|
thor (0.20.3)
|
75
|
-
unicode-display_width (1.6.
|
75
|
+
unicode-display_width (1.6.1)
|
76
76
|
|
77
77
|
PLATFORMS
|
78
78
|
ruby
|
data/README.md
CHANGED
@@ -2,11 +2,12 @@
|
|
2
2
|
|
3
3
|
**Ruby architecture for simplicity and team adoption**
|
4
4
|
|
5
|
-
Architecture
|
5
|
+
Architecture's hard. It’s very easy to build a complex system. Much harder to build a simple and adaptable solution. The code doesn't matter. Coding for the sake of writing code is foolish.
|
6
6
|
|
7
|
-
|
7
|
+
Only a few of us get to write software that survives 5-10 years or longer. 90% of our work is garbage that becomes obsolete in 1-3 years after release. Most of our work hours are wasted on features that will never be useful.
|
8
|
+
|
9
|
+
This is just a reality.
|
8
10
|
|
9
|
-
This is just reality.
|
10
11
|
|
11
12
|
(c) Volodya Sveredyuk
|
12
13
|
|
@@ -28,7 +29,7 @@ bundle install
|
|
28
29
|
|
29
30
|
## DSL
|
30
31
|
|
31
|
-
In your ruby app: (for rails app put it into `config/initializers`)
|
32
|
+
In your ruby app: (for rails app put it into `config/initializers/axr.rb` file)
|
32
33
|
```ruby
|
33
34
|
require 'axr'
|
34
35
|
|
@@ -104,6 +105,11 @@ Run for a specific file
|
|
104
105
|
axr lib/adapters/youtube.rb
|
105
106
|
```
|
106
107
|
|
108
|
+
Finish scanning with status code 1 in case of any warnings (you can use in CI environment to fail pipeline step)
|
109
|
+
```sh
|
110
|
+
axr check --exit-on-warning`
|
111
|
+
```
|
112
|
+
|
107
113
|
## More examples
|
108
114
|
|
109
115
|
**ERP system**
|
@@ -111,20 +117,24 @@ axr lib/adapters/youtube.rb
|
|
111
117
|
<img src="docs/images/erp_example.png" alt="drawing" width="500"/>
|
112
118
|
|
113
119
|
```ruby
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
120
|
+
if Rails.env.development? || Rails.env.test?
|
121
|
+
require 'axr'
|
122
|
+
|
123
|
+
AxR.app.define(isolated: true) do
|
124
|
+
layer 'UI', familiar_with: %w[Docs Inventory Production]
|
125
|
+
layer 'API', familiar_with: %w[Docs Inventory Production]
|
126
|
+
layer 'Docs', familiar_with: %w[Inventory Accounts Repo]
|
127
|
+
layer 'Accounts', familiar_with: %w[Repo]
|
128
|
+
layer 'Inventory', familiar_with: %w[Repo]
|
129
|
+
layer 'Production', familiar_with: %w[Repo]
|
130
|
+
layer 'Repo'
|
131
|
+
end
|
125
132
|
end
|
133
|
+
|
126
134
|
```
|
127
135
|
|
128
136
|
### TODO
|
129
137
|
- Add sublayers
|
130
|
-
- Add
|
138
|
+
- Add rubocop cop
|
139
|
+
- Add more app examples
|
140
|
+
- Migrate to AST analyzer
|
data/docs/images/erp_example.png
CHANGED
Binary file
|
data/lib/axr/cli.rb
CHANGED
@@ -4,15 +4,18 @@ require 'thor'
|
|
4
4
|
|
5
5
|
module AxR
|
6
6
|
class CLI < Thor
|
7
|
-
desc 'check PATH',
|
7
|
+
desc 'check PATH', 'Start AxR runner'
|
8
|
+
desc '--load APP_INIT_PATH', 'Specify file to load your ruby application'
|
9
|
+
desc '--exit-on-warnings', 'Finish with status code 1 on any warnings'
|
8
10
|
|
9
|
-
option :format # TODO: Add formats
|
10
|
-
option :load
|
11
|
+
option :format # TODO: Add more output formats
|
12
|
+
option :load
|
13
|
+
option :'exit-on-warnings'
|
11
14
|
|
12
15
|
def check(pattern = nil)
|
13
16
|
$LOAD_PATH << Dir.pwd
|
14
17
|
require options['load'] if options['load']
|
15
|
-
AxR::Runner.new(pattern).invoke
|
18
|
+
AxR::Runner.new(pattern, exit_on_warnings: !options['exit-on-warnings'].nil?).invoke
|
16
19
|
end
|
17
20
|
end
|
18
21
|
end
|
data/lib/axr/runner.rb
CHANGED
@@ -7,16 +7,19 @@ module AxR
|
|
7
7
|
class Runner
|
8
8
|
DOT_RB = '.rb'
|
9
9
|
|
10
|
-
attr_reader :target, :formatter
|
10
|
+
attr_reader :target, :formatter, :exit_on_warnings
|
11
11
|
|
12
|
-
def initialize(target = nil, formatter: AxR::Formatters::Default.new)
|
13
|
-
@target
|
14
|
-
@formatter
|
12
|
+
def initialize(target = nil, formatter: AxR::Formatters::Default.new, exit_on_warnings: false)
|
13
|
+
@target = target
|
14
|
+
@formatter = formatter
|
15
|
+
@exit_on_warnings = exit_on_warnings
|
15
16
|
end
|
16
17
|
|
18
|
+
alias exit_on_warnings? exit_on_warnings
|
19
|
+
|
17
20
|
def invoke
|
18
21
|
files_with_warnings = files_to_scan.each_with_object({}) do |file_path, issues|
|
19
|
-
scan_result = AxR::Scanner.new(
|
22
|
+
scan_result = AxR::Scanner.new(source: File.open(file_path)).scan
|
20
23
|
issues[file_path] = scan_result.warnings if scan_result.warnings.any?
|
21
24
|
|
22
25
|
formatter.single_file(scan_result, file_path)
|
@@ -24,7 +27,7 @@ module AxR
|
|
24
27
|
|
25
28
|
formatter.summary(files_to_scan, files_with_warnings)
|
26
29
|
|
27
|
-
|
30
|
+
exit 1 if exit_on_warnings? && files_with_warnings.any?
|
28
31
|
|
29
32
|
files_with_warnings
|
30
33
|
end
|
data/lib/axr/scanner.rb
CHANGED
@@ -5,10 +5,10 @@ require_relative 'scanner/warning'
|
|
5
5
|
|
6
6
|
module AxR
|
7
7
|
class Scanner
|
8
|
-
attr_reader :
|
8
|
+
attr_reader :source, :context, :dependecies, :warnings
|
9
9
|
|
10
|
-
def initialize(
|
11
|
-
@
|
10
|
+
def initialize(source: [])
|
11
|
+
@source = source
|
12
12
|
@dependecies = []
|
13
13
|
@warnings = []
|
14
14
|
@context = nil
|
@@ -16,7 +16,7 @@ module AxR
|
|
16
16
|
|
17
17
|
# rubocop:disable Metrics/AbcSize
|
18
18
|
def scan
|
19
|
-
|
19
|
+
source.each.with_index do |line, index|
|
20
20
|
loc_num = index + 1
|
21
21
|
|
22
22
|
line_detection = AxR.app.layer_names.detect { |layer| line.include?(layer) }
|
data/lib/axr/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: axr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Volodya Sveredyuk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -182,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '0'
|
184
184
|
requirements: []
|
185
|
-
rubygems_version: 3.
|
185
|
+
rubygems_version: 3.1.2
|
186
186
|
signing_key:
|
187
187
|
specification_version: 4
|
188
188
|
summary: Code checker for AxR compliance.
|