syntax_tree_ext 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +38 -0
- data/README.md +31 -0
- data/Rakefile +8 -0
- data/lib/syntax_tree_ext/version.rb +5 -0
- data/lib/syntax_tree_ext.rb +45 -0
- data/sig/syntax_tree_ext.rbs +4 -0
- metadata +68 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d51e4d0fd788f5234eded21764f3e8e7a85dd27038c9c40f0a7f211a1a84dd60
|
4
|
+
data.tar.gz: fb064aee9423515356daf3e935bbfcac7320e56883d25fad0cc179380f78bcc1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d68490aa8fa813bd72e892acf2db74627142c60dd2c6f6d5f163593ba999b026fda774c3fa0c6d37c0eaa293ebe7baeab4f18aeb0126d5fefc50df3d42cf7edb
|
7
|
+
data.tar.gz: 69554ffc9196a4c0c758c91771a60b7e39b0cb65dfb6535e4f918ce81e93c15e7d5764188c40d9e6b51d7591067cb262e8d2b6f0102d6d43a50ffe6f5933dfe4
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
syntax_tree_ext (0.1.0)
|
5
|
+
syntax_tree
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.5.0)
|
11
|
+
prettier_print (1.2.1)
|
12
|
+
rake (13.0.6)
|
13
|
+
rspec (3.12.0)
|
14
|
+
rspec-core (~> 3.12.0)
|
15
|
+
rspec-expectations (~> 3.12.0)
|
16
|
+
rspec-mocks (~> 3.12.0)
|
17
|
+
rspec-core (3.12.2)
|
18
|
+
rspec-support (~> 3.12.0)
|
19
|
+
rspec-expectations (3.12.3)
|
20
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
21
|
+
rspec-support (~> 3.12.0)
|
22
|
+
rspec-mocks (3.12.5)
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
+
rspec-support (~> 3.12.0)
|
25
|
+
rspec-support (3.12.0)
|
26
|
+
syntax_tree (6.1.1)
|
27
|
+
prettier_print (>= 1.2.0)
|
28
|
+
|
29
|
+
PLATFORMS
|
30
|
+
ruby
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
rake (~> 13.0)
|
34
|
+
rspec (~> 3.0)
|
35
|
+
syntax_tree_ext!
|
36
|
+
|
37
|
+
BUNDLED WITH
|
38
|
+
2.4.10
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# SyntaxTreeExt
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/syntax_tree_ext`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
14
|
+
|
15
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
+
|
17
|
+
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/syntax_tree_ext.
|
data/Rakefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "syntax_tree_ext/version"
|
4
|
+
|
5
|
+
require 'syntax_tree'
|
6
|
+
|
7
|
+
module SyntaxTreeExt
|
8
|
+
class Error < StandardError; end
|
9
|
+
# Your code goes here...
|
10
|
+
end
|
11
|
+
|
12
|
+
module SyntaxTree
|
13
|
+
class Parser
|
14
|
+
alias_method :original_parse, :parse
|
15
|
+
|
16
|
+
def parse
|
17
|
+
node = original_parse
|
18
|
+
node.set_parent_and_source(source)
|
19
|
+
node
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class Node
|
24
|
+
attr_accessor :parent, :source
|
25
|
+
|
26
|
+
def set_parent_and_source(source)
|
27
|
+
self.source = source
|
28
|
+
child_nodes.each do |child_node|
|
29
|
+
next unless child_node.is_a?(Node)
|
30
|
+
|
31
|
+
child_node.parent = self
|
32
|
+
child_node.set_parent_and_source(source)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def siblings
|
37
|
+
index = parent.child_nodes.index(self)
|
38
|
+
parent.child_nodes[index + 1...]
|
39
|
+
end
|
40
|
+
|
41
|
+
def source
|
42
|
+
@source[location.start_char..location.end_char]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: syntax_tree_ext
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Huang
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-04-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: syntax_tree
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: extend syntax_tree, add parent and sibling
|
28
|
+
email:
|
29
|
+
- flyerhzm@gmail.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".rspec"
|
35
|
+
- CHANGELOG.md
|
36
|
+
- Gemfile
|
37
|
+
- Gemfile.lock
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- lib/syntax_tree_ext.rb
|
41
|
+
- lib/syntax_tree_ext/version.rb
|
42
|
+
- sig/syntax_tree_ext.rbs
|
43
|
+
homepage: https://github.com/xinminlabs/syntax_tree_ext
|
44
|
+
licenses: []
|
45
|
+
metadata:
|
46
|
+
homepage_uri: https://github.com/xinminlabs/syntax_tree_ext
|
47
|
+
source_code_uri: https://github.com/xinminlabs/syntax_tree_ext
|
48
|
+
changelog_uri: https://github.com/xinminlabs/syntax_tree_ext/blob/main/CHANGELOG
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 2.6.0
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubygems_version: 3.4.10
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: extend syntax_tree
|
68
|
+
test_files: []
|