code_analyzer 0.5.2 → 0.5.3
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/.github/workflows/main.yml +31 -0
- data/.ruby-version +1 -0
- data/README.md +1 -7
- data/lib/code_analyzer/sexp.rb +22 -0
- data/lib/code_analyzer/version.rb +1 -1
- data/spec/code_analyzer/sexp_spec.rb +20 -0
- metadata +5 -4
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4455e3247da8def6aaed2fd3a0f677be5e563c38f67c58e3afda1292958685d1
|
4
|
+
data.tar.gz: 9f9034f8704c2df789d5182be9c6bb01ea8d83785dd91699e7d5f2b73a2a3c72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8e7a551087cf2be47f0dfb3d8e34dc2234227bd12a2f97d26747f1d2682c54c4aa3e59c70b6ff3c930f74210e27c845bd8897b5d1c82155a8b596d2defba025
|
7
|
+
data.tar.gz: 50a1841f6e96d84c6839d6ba30cee28d0be769ac80d9905f36a77709c59c1a57ee72ecdee36aa72bc80d6e30b373d1a0dde881036b728b89a0b254d425e277f2
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: CI
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
runs-on: ubuntu-latest
|
19
|
+
strategy:
|
20
|
+
matrix:
|
21
|
+
ruby-version: ['2.6', '2.7', '3.0', '3.1']
|
22
|
+
|
23
|
+
steps:
|
24
|
+
- uses: actions/checkout@v2
|
25
|
+
- name: Set up Ruby
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: ${{ matrix.ruby-version }}
|
29
|
+
bundler-cache: true
|
30
|
+
- name: Run tests
|
31
|
+
run: bundle exec rspec spec
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.0
|
data/README.md
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
# CodeAnalyzer
|
2
2
|
|
3
|
-
|
4
|
-
|:---------|:--------------------------------------------
|
5
|
-
| Homepage | https://github.com/flyerhzm/code_analyzer
|
6
|
-
| Document | http://rubydoc.info/gems/code_analyzer/frames
|
7
|
-
| CI | [](https://travis-ci.org/flyerhzm/code_analyzer)
|
8
|
-
| Author | [Richard Huang][0]
|
3
|
+
[](https://github.com/flyerhzm/code_analyzer/actions/workflows/main.yml)
|
9
4
|
|
10
5
|
code_analyzer is extracted from [rails_best_practices][1], it helps you
|
11
6
|
easily build your own code analyzer tool.
|
@@ -36,5 +31,4 @@ Or install it yourself as:
|
|
36
31
|
4. Push to the branch (`git push origin my-new-feature`)
|
37
32
|
5. Create new Pull Request
|
38
33
|
|
39
|
-
[0]: http://huangzhimin.com
|
40
34
|
[1]: https://github.com/railsbp/rails_best_practices
|
data/lib/code_analyzer/sexp.rb
CHANGED
@@ -688,6 +688,28 @@ class Sexp
|
|
688
688
|
end
|
689
689
|
end
|
690
690
|
|
691
|
+
# Get the hash key
|
692
|
+
#
|
693
|
+
# s(:assoc_new, s(:@label, "first_name:", s(1, 1)), s(:string_literal, s(:string_add, s(:string_content), s(:@tstring_content, "Richard", s(1, 14)))))
|
694
|
+
# =>
|
695
|
+
# s(:@label, "first_name:", s(1, 1))
|
696
|
+
def key
|
697
|
+
if :assoc_new == sexp_type
|
698
|
+
self[1].to_s
|
699
|
+
end
|
700
|
+
end
|
701
|
+
|
702
|
+
# Get the hash value
|
703
|
+
#
|
704
|
+
# s(:assoc_new, s(:@label, "first_name:", s(1, 1)), s(:string_literal, s(:string_add, s(:string_content), s(:@tstring_content, "Richard", s(1, 14)))))
|
705
|
+
# =>
|
706
|
+
# s(:string_literal, s(:string_add, s(:string_content), s(:@tstring_content, "Richard", s(1, 14))))
|
707
|
+
def value
|
708
|
+
if :assoc_new == sexp_type
|
709
|
+
self[2].to_s
|
710
|
+
end
|
711
|
+
end
|
712
|
+
|
691
713
|
# Get the array size.
|
692
714
|
#
|
693
715
|
# s(:array,
|
@@ -644,6 +644,26 @@ describe Sexp do
|
|
644
644
|
end
|
645
645
|
end
|
646
646
|
|
647
|
+
describe 'key' do
|
648
|
+
it 'should get key for assoc_new' do
|
649
|
+
node =
|
650
|
+
parse_content("add_user :user, first_name: 'Richard'").grep_node(
|
651
|
+
sexp_type: :assoc_new
|
652
|
+
)
|
653
|
+
expect(node.key).to eq 'first_name'
|
654
|
+
end
|
655
|
+
end
|
656
|
+
|
657
|
+
describe 'value' do
|
658
|
+
it 'should get value for assoc_new' do
|
659
|
+
node =
|
660
|
+
parse_content("add_user :user, first_name: 'Richard'").grep_node(
|
661
|
+
sexp_type: :assoc_new
|
662
|
+
)
|
663
|
+
expect(node.value).to eq 'Richard'
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
647
667
|
describe 'array_size' do
|
648
668
|
it 'should get array size' do
|
649
669
|
node = parse_content("['first_name', 'last_name']").grep_node(sexp_type: :array)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sexp_processor
|
@@ -60,9 +60,10 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".github/workflows/main.yml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".rspec"
|
65
|
-
- ".
|
66
|
+
- ".ruby-version"
|
66
67
|
- Gemfile
|
67
68
|
- LICENSE
|
68
69
|
- README.md
|
@@ -106,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
107
|
- !ruby/object:Gem::Version
|
107
108
|
version: '0'
|
108
109
|
requirements: []
|
109
|
-
rubygems_version: 3.
|
110
|
+
rubygems_version: 3.3.3
|
110
111
|
signing_key:
|
111
112
|
specification_version: 4
|
112
113
|
summary: a code analyzer helps you build your own code analyzer tool.
|