sirop 0.7 → 0.8
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/CHANGELOG.md +5 -0
- data/lib/sirop/sourcifier.rb +18 -0
- data/lib/sirop/version.rb +1 -1
- data/lib/sirop.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a44ab3d216adc8e5bda83ca86fef998d8c059ac7f62b3ab4c4b1688be65a24a6
|
4
|
+
data.tar.gz: 8c4b7b1aa49f6e293ca2f161ade3f8c1b14ad386644e7abc713eefc7798bcbd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cfbd57a4e23be3fb959462f6c76aaf1af3e2810c80b81560772965d39654d7975a6aeb7f2441f0c33b9811c898f005ac89eb163ed4215099df7b47abc60e2ca
|
7
|
+
data.tar.gz: 8c778dee6a5a416438e37972684ee6cd12d8b8332c4422b099c913b14425d3acb6c63f092f7e8433277f409807724f70fe267e6b7e08d5f21b9367d682d69b3e
|
data/CHANGELOG.md
CHANGED
data/lib/sirop/sourcifier.rb
CHANGED
@@ -98,10 +98,19 @@ module Sirop
|
|
98
98
|
|
99
99
|
def to_source(node)
|
100
100
|
@buffer.clear
|
101
|
+
@source_map = nil
|
101
102
|
visit(node)
|
102
103
|
@buffer
|
103
104
|
end
|
104
105
|
|
106
|
+
def to_source_with_source_map(obj, node, line_ofs)
|
107
|
+
@buffer.clear
|
108
|
+
@source_map_line_ofs = line_ofs
|
109
|
+
@source_map = { source_fn: obj.source_location.first }
|
110
|
+
visit(node)
|
111
|
+
[@buffer, @source_map]
|
112
|
+
end
|
113
|
+
|
105
114
|
def loc_start(loc)
|
106
115
|
[loc.start_line, loc.start_column]
|
107
116
|
end
|
@@ -111,9 +120,18 @@ module Sirop
|
|
111
120
|
end
|
112
121
|
|
113
122
|
def emit(str)
|
123
|
+
update_source_map
|
114
124
|
@buffer << str
|
115
125
|
end
|
116
126
|
|
127
|
+
def update_source_map
|
128
|
+
return if !@source_map
|
129
|
+
|
130
|
+
buffer_cur_line = @buffer.count("\n") + 1
|
131
|
+
orig_source_cur_line = @last_loc_start ? @last_loc_start.first : 1
|
132
|
+
@source_map[buffer_cur_line] ||= orig_source_cur_line
|
133
|
+
end
|
134
|
+
|
117
135
|
def adjust_whitespace(loc)
|
118
136
|
return if loc.is_a?(Sirop::Injection)
|
119
137
|
|
data/lib/sirop/version.rb
CHANGED
data/lib/sirop.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sirop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
rubygems_version: 3.6.
|
79
|
+
rubygems_version: 3.6.9
|
80
80
|
specification_version: 4
|
81
81
|
summary: 'Sirop: Ruby code rewriter'
|
82
82
|
test_files: []
|