code_analyzer 0.5.2 → 0.5.3

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: 5a68561649e1e345495d4a494530dc7abb9ca256dc5a999d1aa71b1c567b0e66
4
- data.tar.gz: d21414e33aa72bbb23571985b9eaa00e177057f7781cbb3f1398476119f38c69
3
+ metadata.gz: 4455e3247da8def6aaed2fd3a0f677be5e563c38f67c58e3afda1292958685d1
4
+ data.tar.gz: 9f9034f8704c2df789d5182be9c6bb01ea8d83785dd91699e7d5f2b73a2a3c72
5
5
  SHA512:
6
- metadata.gz: 99369336e083dd38d76e7436ee9d824565108760339d3da59b057649341917da4649e68c78f01a29ba45c09c95a2ca71c1b2392d9c2a252826cb81abb2580131
7
- data.tar.gz: cbba861e5caa35dcd4a0e887159ae0a14bb166a21f2b0bb8b5e33f188c346f9b71b6b11bbee253e9ee2b18b4fc7be039801d438168d43d00b4f007b0541698d8
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
- | Project | code_analyzer
4
- |:---------|:--------------------------------------------
5
- | Homepage | https://github.com/flyerhzm/code_analyzer
6
- | Document | http://rubydoc.info/gems/code_analyzer/frames
7
- | CI | [![Build Status](https://travis-ci.org/flyerhzm/code_analyzer.png)](https://travis-ci.org/flyerhzm/code_analyzer)
8
- | Author | [Richard Huang][0]
3
+ [![CI](https://github.com/flyerhzm/code_analyzer/actions/workflows/main.yml/badge.svg)](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
@@ -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,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CodeAnalyzer
4
- VERSION = '0.5.2'
4
+ VERSION = '0.5.3'
5
5
  end
@@ -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.2
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: 2020-07-01 00:00:00.000000000 Z
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
- - ".travis.yml"
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.1.2
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.
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- rvm:
4
- - 2.6.6
5
- - 2.7.1