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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9d3de45148c936da6efb0f3f3ae56a53aa3574a52d64334c270a54addd16669
4
- data.tar.gz: a4d246801ee4e301ba5e12230fc66488b90a6ce6ae6af9d6c510a90ff5e1c10c
3
+ metadata.gz: f72dad434e267f3a0b9576b013af83a164ac2bf87f3879b1652f17df793627fc
4
+ data.tar.gz: 91c2b57c9b973ca7069eca9b14363d73abd0f56bcbfa1ddb71a6342030d60c88
5
5
  SHA512:
6
- metadata.gz: fb0e1511bd8dee8785c1f2aadec5e96140ad2d16dff6f4b3303a57e7f19b6b16236f62a7456bb6b2801f7439b2f270b3d92f1e8738ad1ba422896414b1fbc6fa
7
- data.tar.gz: 876e391294b55080b4ca6eced2fee4788be6e3d9f1ffafdacba0a8fc884c76e236e08d1d572f32da277f7d110384ac69301eac3314a980f472860e6a4cabea42
6
+ metadata.gz: 35a230de00be2d28acb46c438287dd641900e03429f05928a9734d603cac8af7f3e6654b3b5683670936514c606f163cb5a99d940ad559b1705111273bb1d08c
7
+ data.tar.gz: cbe88f73c7e2e543c46d5d2a9a940b6fa92eb9e3a62143dcc1124b54baf2b51592265449394ca4eee910b39d0497609277648b0006e4095e574e01781c61ddff
@@ -13,6 +13,9 @@ Style/Documentation:
13
13
  Metrics/LineLength:
14
14
  Max: 120
15
15
 
16
+ Metrics/AbcSize:
17
+ Max: 20
18
+
16
19
  Metrics/BlockLength:
17
20
  ExcludedMethods: [
18
21
  'describe',
@@ -1,11 +1,12 @@
1
1
  ---
2
- sudo: false
3
2
  language: ruby
4
3
  cache: bundler
5
4
  rvm:
6
- - 2.6.3
5
+ - 2.5.7
6
+ - 2.6.5
7
+ - 2.7.0
7
8
  before_install:
8
- - gem install bundler -v 2.0.2
9
+ - gem install bundler
9
10
  - bundle install
10
11
  script:
11
12
  - bundle exec rubocop
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- axr (0.6.2)
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.11.3)
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.0.13)
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.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.0)
57
- rspec-support (~> 3.9.0)
58
- rspec-expectations (3.9.0)
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.0)
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.0)
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.0)
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 is hard. It’s very easy to build a complex system; much harder to build a simple and adaptable one. The code doesn't matter and coding for the sake of writing code is foolish.
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
- Few of us get to write software that survives 5-10 years or longer. 90% of our work is garbage that becomes obsolete 1-3 years after release. Most of our work hours are wasted on features that never get shipped.
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
- require 'axr'
115
-
116
- AxR.app.define(isolated: true) do
117
- layer 'Api', familiar_with: ['ERP']
118
- layer 'UI', familiar_with: ['ERP']
119
- layer 'ERP', familiar_with: %w[Inventory Sales Supply]
120
- layer 'Sales', familiar_with: 'Inventory'
121
- layer 'Supply', familiar_with: 'Inventory'
122
- layer 'Repo'
123
- layer 'Change'
124
- layer 'Query'
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 `axr check --exit-on-warning` cli flag
138
+ - Add rubocop cop
139
+ - Add more app examples
140
+ - Migrate to AST analyzer
Binary file
@@ -4,15 +4,18 @@ require 'thor'
4
4
 
5
5
  module AxR
6
6
  class CLI < Thor
7
- desc 'check PATH', 'Start AxR runner'
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 # TODO: Add formats
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
@@ -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 = target
14
- @formatter = 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(file_path: file_path).scan
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
- # exit 1 if files_with_warnings.any?
30
+ exit 1 if exit_on_warnings? && files_with_warnings.any?
28
31
 
29
32
  files_with_warnings
30
33
  end
@@ -5,10 +5,10 @@ require_relative 'scanner/warning'
5
5
 
6
6
  module AxR
7
7
  class Scanner
8
- attr_reader :file_path, :context, :dependecies, :warnings
8
+ attr_reader :source, :context, :dependecies, :warnings
9
9
 
10
- def initialize(file_path:)
11
- @file_path = file_path
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
- File.open(file_path).each.with_index do |line, index|
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) }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AxR
4
- VERSION = '0.6.2'
4
+ VERSION = '0.7.1'
5
5
  end
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.6.2
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: 2019-12-26 00:00:00.000000000 Z
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.0.3
185
+ rubygems_version: 3.1.2
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Code checker for AxR compliance.