code_breaker 0.3.1 → 1.0.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
- SHA1:
3
- metadata.gz: a4ac73ad102a55afe5e5a492a42ded9d2dfe095c
4
- data.tar.gz: d064a7361c2a50f443349ed321cd5818fd330aff
2
+ SHA256:
3
+ metadata.gz: 34e130c3a963be818c41a997843620e65a3e89aa4daa4aad2d0ffdb8aa380087
4
+ data.tar.gz: e55c8809962f90a39ff8b5ad73f7cb1b3b45d2572f8954578fefabfe8ba00051
5
5
  SHA512:
6
- metadata.gz: 235820b55d87c7c830a08234c26a457e3a6f227c5f8dae64fed87008cdc79b62d273896b36ab40fcbb2abe16cc1ef86f4e27235cc637b39973690645a571e8bc
7
- data.tar.gz: afea7c80e437651b71e945f30659f6ae90f32771527da6108483435737871936af9f80350642478e26b06642770b408f14ad71387267869519fe6341069dae1d
6
+ metadata.gz: 42ed1c04674bb3049df6c4a1805cda4e17594ca84f99d48ceb159a9d96580d0061bb9d4c774bb33b0f77dcdb106ab145c616aaaa2a456e0825f2ac3ae213e847
7
+ data.tar.gz: dbb5fe81fa8690056f738496add777f80ae6aab7ab3d36fac9834096cd9ded694bd8ebf744fbfb2926ca83b37039231d23b15679249a922f98a39d5f86932dd1
@@ -0,0 +1,33 @@
1
+ name: Ruby CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, develop ]
6
+ pull_request:
7
+ branches: [ main, develop ]
8
+
9
+ jobs:
10
+ test:
11
+ strategy:
12
+ fail-fast: false
13
+ matrix:
14
+ os: [ ubuntu-latest, macos-latest, windows-latest ]
15
+ ruby: [ 2.5, 2.6, 2.7, ruby-head ]
16
+ runs-on: ${{ matrix.os }}
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+ - uses: actions/cache@v2
23
+ with:
24
+ path: vendor/bundle
25
+ key: ${{ matrix.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
26
+ restore-keys: |
27
+ ${{ matrix.os }}-gems-
28
+ - name: Install dependencies
29
+ run: |
30
+ gem install bundler
31
+ bundle install --jobs 4 --retry 3
32
+ - name: Run Tests
33
+ run: bundle exec rake default
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # CodeBreaker
2
2
 
3
- [![Build Status](https://travis-ci.org/daigaku-ruby/code_breaker.svg?branch=master)](https://travis-ci.org/daigaku-ruby/code_breaker)
3
+ [![Build Status](https://github.com/daigaku-ruby/code_breaker/workflows/Ruby%20CI/badge.svg)](https://github.com/daigaku-ruby/code_breaker/workflows/Ruby%20CI/badge.svg)
4
4
  [![Gem Version](https://badge.fury.io/rb/code_breaker.svg)](http://badge.fury.io/rb/code_breaker)
5
5
 
6
6
  CodeBreaker breaks a line of Ruby code into its receiver classes and the methods
@@ -44,10 +44,6 @@ require 'code_breaker'
44
44
 
45
45
  code_snippet = 'crazy_number = Rational(3, 5) + 42 - Complex(2.3, 6.4) * 1.2'
46
46
  CodeBreaker.parse(code_snippet)
47
- # for Ruby < v2.4.0:
48
- # => {:lvasgn=>[:crazy_number, [Rational, :+, Fixnum, :-, Complex, :*, Float]]}
49
- #
50
- # for Ruby >= v2.4.0:
51
47
  # => {:lvasgn=>[:crazy_number, [Rational, :+, Integer, :-, Complex, :*, Float]]}
52
48
 
53
49
  code_snippet = '"hello" + "World"'
@@ -26,10 +26,11 @@ Gem::Specification.new do |spec|
26
26
  spec.bindir = 'exe'
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ['lib']
29
+ spec.required_ruby_version = '~> 2.5'
29
30
 
30
- spec.add_dependency 'parser', '~> 2.4'
31
+ spec.add_dependency 'parser', '~> 2.7'
31
32
 
32
- spec.add_development_dependency 'bundler', '~> 1.14'
33
- spec.add_development_dependency 'rake', '~> 12.0'
34
- spec.add_development_dependency 'rspec', '~> 3.6'
33
+ spec.add_development_dependency 'bundler', '~> 2.0'
34
+ spec.add_development_dependency 'rake', '~> 13.0'
35
+ spec.add_development_dependency 'rspec', '~> 3.9'
35
36
  end
@@ -2,19 +2,21 @@ module CodeBreaker
2
2
  module Parsable
3
3
  module Node
4
4
  def parse(node)
5
- return if node.nil?
6
-
7
5
  if node.is_a?(Symbol)
8
6
  node
7
+ elsif node.nil?
8
+ parse_nil_node(node)
9
9
  else
10
10
  send("parse_#{node.type}_node", node)
11
11
  end
12
12
  end
13
13
 
14
- def parse_children(node)
15
- node.children.each_with_object([]) do |child, nodes|
16
- nodes << parse(child) unless child.nil?
17
- nodes
14
+ def parse_children(node, compact: true)
15
+ children = node.children
16
+ children = children.compact if compact
17
+
18
+ children.each_with_object([]) do |child, nodes|
19
+ nodes << parse(child)
18
20
  end
19
21
  end
20
22
 
@@ -31,7 +33,8 @@ module CodeBreaker
31
33
  end
32
34
 
33
35
  def method_missing(method, *args, &block)
34
- node_type = method.to_s.match(/^parse_(.+)_node$/).captures.first
36
+ matches = method.to_s.match(/^parse_(.+)_node$/)
37
+ node_type = matches ? matches.captures.first : []
35
38
 
36
39
  if node_type.empty?
37
40
  super
@@ -3,11 +3,15 @@ module CodeBreaker
3
3
  module Ranges
4
4
  include Parsable::Node
5
5
 
6
- # inclusive range a..b
7
- alias_method :parse_irange_node, :parse_as_hash
6
+ # inclusive range a..b, a.., ..b
7
+ def parse_irange_node(node)
8
+ { node.type => parse_children(node, compact: false) }
9
+ end
8
10
 
9
- # exclusive range a...b
10
- alias_method :parse_erange_node, :parse_as_hash
11
+ # exclusive range a...b, a..., ...b
12
+ def parse_erange_node(node)
13
+ { node.type => parse_children(node, compact: false) }
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -1,3 +1,3 @@
1
1
  module CodeBreaker
2
- VERSION = '0.3.1'.freeze
2
+ VERSION = '1.0.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code_breaker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Götze
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-05-12 00:00:00.000000000 Z
11
+ date: 2020-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser
@@ -16,56 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.4'
19
+ version: '2.7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.4'
26
+ version: '2.7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.14'
33
+ version: '2.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.14'
40
+ version: '2.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '12.0'
47
+ version: '13.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '12.0'
54
+ version: '13.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.6'
61
+ version: '3.9'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.6'
68
+ version: '3.9'
69
69
  description: Breaking a Ruby code snippet into a sequence of classes and their connecting
70
70
  methods.
71
71
  email:
@@ -74,9 +74,9 @@ executables: []
74
74
  extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
+ - ".github/workflows/main.yml"
77
78
  - ".gitignore"
78
79
  - ".rspec"
79
- - ".travis.yml"
80
80
  - CODE_OF_CONDUCT.md
81
81
  - Gemfile
82
82
  - LICENSE.txt
@@ -108,17 +108,16 @@ require_paths:
108
108
  - lib
109
109
  required_ruby_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - ">="
111
+ - - "~>"
112
112
  - !ruby/object:Gem::Version
113
- version: '0'
113
+ version: '2.5'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
116
  - - ">="
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubyforge_project:
121
- rubygems_version: 2.6.12
120
+ rubygems_version: 3.1.3
122
121
  signing_key:
123
122
  specification_version: 4
124
123
  summary: Breaking a Ruby code snippet into a sequence of classes and their connecting
@@ -1,10 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.0
4
- - 2.2.7
5
- - 2.3.0
6
- - 2.3.4
7
- - 2.4.0
8
- - 2.4.1
9
- - ruby-head
10
- before_install: gem install bundler -v 1.14.6