prism_ext 0.3.6 → 0.3.7

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: 31a1629de1d522e1386ac118d889cc603de8ab381b53cd80d4b0b867d7a3eaf3
4
- data.tar.gz: f15b3859b932611dc9d68e7a9d8afd130bfa10fe482632c5b5952d90b2aba05b
3
+ metadata.gz: 7df9da0b75b3d011611ad94a92d532045d97df11a5d5fd00e6e753b4e35a4a5b
4
+ data.tar.gz: e9c72ce6abea12442381bdec345170c0ea7fea3796b547ae47bd6cae193f3e3c
5
5
  SHA512:
6
- metadata.gz: f328951405aee3ba268388b3154a163bcd565c2739a47cba45ad91bfa07b0774dd080b1b36a9db5bbf50f2748342e8d87fb7b4016020ba647379b2ae7c4b6a54
7
- data.tar.gz: b49c81171e69e0891615d3df6d61f3ebb9cad37d9702e6c7a6a1d9b4731377deadfacaae925191418460a228ebfcf7849debd6db9f6d530876f85aa442edc247
6
+ metadata.gz: ab250d2c6f24ab15d30f56e28252ed3263c24f47f4cca9f15ba1759fda589053e5e21d6c61f88c6d484d9bb7c1703b1e25808b1cdf17b5222455dbc406183641
7
+ data.tar.gz: 9aa4fd52106103ef276308793f1980fa2bc7426443b0cec77ad378d64411c610c7c73ae3e06ed365b73653df9a5a024b4f30f582eb0c0f8c5c7f2b2947b0d1e5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.3.7 (2024-07-06)
4
+
5
+ * Fix call node with block_argument_node `to_source`
6
+ * Use `character_offset` instead of `offset`
7
+
3
8
  ## 0.3.6 (2024-07-03)
4
9
 
5
10
  * Check `arguments` is an `ArgumetnsNode`
data/Gemfile CHANGED
@@ -5,6 +5,9 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in prism_ext.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
8
+ gem "rake"
9
+ gem "rspec"
9
10
 
10
- gem "rspec", "~> 3.0"
11
+ gem 'guard'
12
+ gem 'guard-bundler'
13
+ gem 'guard-rspec'
data/Gemfile.lock CHANGED
@@ -1,15 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prism_ext (0.3.6)
4
+ prism_ext (0.3.7)
5
5
  prism
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
+ coderay (1.1.3)
10
11
  diff-lcs (1.5.0)
12
+ ffi (1.17.0)
13
+ ffi (1.17.0-x86_64-darwin)
14
+ formatador (1.1.0)
15
+ guard (2.18.1)
16
+ formatador (>= 0.2.4)
17
+ listen (>= 2.7, < 4.0)
18
+ lumberjack (>= 1.0.12, < 2.0)
19
+ nenv (~> 0.1)
20
+ notiffany (~> 0.0)
21
+ pry (>= 0.13.0)
22
+ shellany (~> 0.0)
23
+ thor (>= 0.18.1)
24
+ guard-bundler (3.0.1)
25
+ bundler (>= 2.1, < 3)
26
+ guard (~> 2.2)
27
+ guard-compat (~> 1.1)
28
+ guard-compat (1.2.1)
29
+ guard-rspec (4.7.3)
30
+ guard (~> 2.1)
31
+ guard-compat (~> 1.1)
32
+ rspec (>= 2.99.0, < 4.0)
33
+ listen (3.9.0)
34
+ rb-fsevent (~> 0.10, >= 0.10.3)
35
+ rb-inotify (~> 0.9, >= 0.9.10)
36
+ lumberjack (1.2.10)
37
+ method_source (1.1.0)
38
+ nenv (0.3.0)
39
+ notiffany (0.1.3)
40
+ nenv (~> 0.1)
41
+ shellany (~> 0.0)
11
42
  prism (0.30.0)
43
+ pry (0.14.2)
44
+ coderay (~> 1.1)
45
+ method_source (~> 1.0)
12
46
  rake (13.1.0)
47
+ rb-fsevent (0.11.2)
48
+ rb-inotify (0.11.1)
49
+ ffi (~> 1.0)
13
50
  rspec (3.12.0)
14
51
  rspec-core (~> 3.12.0)
15
52
  rspec-expectations (~> 3.12.0)
@@ -23,15 +60,20 @@ GEM
23
60
  diff-lcs (>= 1.2.0, < 2.0)
24
61
  rspec-support (~> 3.12.0)
25
62
  rspec-support (3.12.1)
63
+ shellany (0.0.1)
64
+ thor (1.3.1)
26
65
 
27
66
  PLATFORMS
28
67
  ruby
29
68
  x86_64-darwin-23
30
69
 
31
70
  DEPENDENCIES
71
+ guard
72
+ guard-bundler
73
+ guard-rspec
32
74
  prism_ext!
33
- rake (~> 13.0)
34
- rspec (~> 3.0)
75
+ rake
76
+ rspec
35
77
 
36
78
  BUNDLED WITH
37
79
  2.5.3
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: 'bundle exec rspec' do
4
+ watch(%r{^spec/.+_spec\.rb$})
5
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
6
+ watch('spec/spec_helper.rb') { 'spec' }
7
+ end
8
+
9
+ guard :bundler do
10
+ require 'guard/bundler'
11
+ require 'guard/bundler/verify'
12
+ helper = Guard::Bundler::Verify.new
13
+
14
+ files = ['Gemfile']
15
+ files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }
16
+
17
+ # Assume files are symlinked from somewhere
18
+ files.each { |file| watch(helper.real_path(file)) }
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PrismExt
4
- VERSION = "0.3.6"
4
+ VERSION = "0.3.7"
5
5
  end
data/lib/prism_ext.rb CHANGED
@@ -84,22 +84,24 @@ module Prism
84
84
  end
85
85
 
86
86
  def to_source
87
- # node.slice doesn't work for InterpolatedStringNode
88
- if interpolated_string?
89
- range = opening_loc.start_offset...closing_loc.end_offset
90
- elsif is_a?(CallNode) && arguments.is_a?(ArgumentsNode) && arguments.arguments.any?(&:interpolated_string?)
91
- last_interpolated_string_argument = arguments.arguments.select(&:interpolated_string?).last
92
- range = location.start_offset...last_interpolated_string_argument.closing_loc.end_offset
93
- else
94
- range = location.start_offset...location.end_offset
87
+ case self
88
+ when InterpolatedStringNode, StringNode
89
+ if opening.start_with?('<<')
90
+ range = opening_loc.start_character_offset...closing_loc.end_character_offset
91
+ end
92
+ when CallNode
93
+ if arguments.is_a?(ArgumentsNode) && arguments.arguments.any?(&:interpolated_string?)
94
+ last_interpolated_string_argument = arguments.arguments.select(&:interpolated_string?).last
95
+ range = location.start_character_offset...last_interpolated_string_argument.closing_loc.end_character_offset
96
+ elsif block.is_a?(BlockArgumentNode)
97
+ range = location.start_character_offset...closing_loc.end_character_offset
98
+ end
95
99
  end
96
- location.send(:source).source[range]
100
+ range ? location.send(:source).source[range] : slice
97
101
  end
98
102
 
99
103
  def interpolated_string?
100
- respond_to?(:opening_loc) && respond_to?(:closing_loc) &&
101
- opening_loc && closing_loc &&
102
- (opening == "<<~#{closing.strip}" || opening == "<<-#{closing.strip}")
104
+ (is_a?(InterpolatedStringNode) || is_a?(StringNode)) && opening.start_with?('<<')
103
105
  end
104
106
  end
105
107
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prism_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prism
@@ -35,6 +35,7 @@ files:
35
35
  - CHANGELOG.md
36
36
  - Gemfile
37
37
  - Gemfile.lock
38
+ - Guardfile
38
39
  - README.md
39
40
  - Rakefile
40
41
  - lib/prism_ext.rb