gloss 0.0.6 → 0.1.4
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/.github/workflows/tests.yml +41 -0
- data/.gloss.yml +2 -0
- data/Gemfile.lock +10 -10
- data/README.md +5 -7
- data/Rakefile +5 -3
- data/exe/gloss +10 -13
- data/ext/gloss/Makefile +6 -21
- data/ext/gloss/lib/cr_ruby.cr +5 -4
- data/ext/gloss/src/cr_ast.cr +61 -71
- data/ext/gloss/src/gloss.cr +7 -2
- data/ext/gloss/src/rb_ast.cr +37 -36
- data/gloss.gemspec +3 -3
- data/lib/gloss.rb +10 -7
- data/lib/gloss/cli.rb +61 -40
- data/lib/gloss/config.rb +14 -8
- data/lib/gloss/errors.rb +1 -1
- data/lib/gloss/logger.rb +6 -6
- data/lib/gloss/prog_loader.rb +144 -0
- data/lib/gloss/scope.rb +1 -1
- data/lib/gloss/source.rb +1 -1
- data/lib/gloss/type_checker.rb +60 -32
- data/lib/gloss/utils.rb +38 -0
- data/lib/gloss/version.rb +1 -1
- data/lib/gloss/{builder.rb → visitor.rb} +88 -53
- data/lib/gloss/watcher.rb +14 -7
- data/lib/gloss/writer.rb +21 -10
- data/logo.svg +6 -0
- data/sig/core.rbs +2 -0
- data/sig/fast_blank.rbs +4 -0
- data/sig/{gloss.rbs → gls.rbs} +0 -0
- data/sig/optparse.rbs +6 -0
- data/sig/rubygems.rbs +9 -0
- data/sig/yaml.rbs +3 -0
- data/src/exe/gloss +19 -0
- data/src/lib/gloss.gl +25 -0
- data/src/lib/gloss/cli.gl +41 -26
- data/src/lib/gloss/config.gl +13 -8
- data/src/lib/gloss/logger.gl +2 -5
- data/src/lib/gloss/prog_loader.gl +138 -0
- data/src/lib/gloss/scope.gl +0 -2
- data/src/lib/gloss/type_checker.gl +57 -28
- data/src/lib/gloss/utils.gl +35 -0
- data/src/lib/gloss/version.gl +1 -1
- data/src/lib/gloss/{builder.gl → visitor.gl} +82 -45
- data/src/lib/gloss/watcher.gl +13 -8
- data/src/lib/gloss/writer.gl +15 -13
- metadata +29 -18
- data/.github/workflows/crystal_specs.yml +0 -26
- data/.github/workflows/ruby_specs.yml +0 -33
data/src/lib/gloss/watcher.gl
CHANGED
@@ -1,13 +1,14 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require "listen"
|
4
2
|
|
5
3
|
module Gloss
|
6
4
|
class Watcher
|
5
|
+
@listener: Listen?
|
6
|
+
|
7
7
|
def initialize(@paths : Array[String])
|
8
8
|
if @paths.empty?
|
9
9
|
@paths = [File.join(Dir.pwd, Config.src_dir)]
|
10
|
-
|
10
|
+
# either any filepath with .gl extension, or executable with extension
|
11
|
+
@only = /(?:(\.gl|(?:(?<=\/)[^\.\/]+))\z|\A[^\.\/]+\z)/
|
11
12
|
else
|
12
13
|
file_names = Array.new
|
13
14
|
paths = Array.new
|
@@ -23,7 +24,7 @@ module Gloss
|
|
23
24
|
|
24
25
|
def watch
|
25
26
|
Gloss.logger.info "Now listening for changes in #{@paths.join(', ')}"
|
26
|
-
listener
|
27
|
+
@listener ||= Listen.to(
|
27
28
|
*@paths,
|
28
29
|
latency: 2,
|
29
30
|
only: @only
|
@@ -33,7 +34,7 @@ module Gloss
|
|
33
34
|
content = File.read(f)
|
34
35
|
err = catch :error do
|
35
36
|
Writer.new(
|
36
|
-
|
37
|
+
Visitor.new(
|
37
38
|
Parser.new(
|
38
39
|
content
|
39
40
|
).run
|
@@ -56,12 +57,16 @@ module Gloss
|
|
56
57
|
end
|
57
58
|
end
|
58
59
|
begin
|
59
|
-
listener.start
|
60
|
+
@listener.start
|
60
61
|
sleep
|
61
62
|
rescue Interrupt
|
62
|
-
|
63
|
-
exit 0
|
63
|
+
kill
|
64
64
|
end
|
65
65
|
end
|
66
|
+
|
67
|
+
def kill
|
68
|
+
Gloss.logger.info "Interrupt signal received, shutting down"
|
69
|
+
@listener.stop if @listener
|
70
|
+
end
|
66
71
|
end
|
67
72
|
end
|
data/src/lib/gloss/writer.gl
CHANGED
@@ -4,30 +4,32 @@ require "pathname"
|
|
4
4
|
require "fileutils"
|
5
5
|
|
6
6
|
module Gloss
|
7
|
-
module Utils
|
8
|
-
module_function
|
9
|
-
|
10
|
-
def src_path_to_output_path(src_path : String) : String
|
11
|
-
src_path.sub("#{Config.src_dir}/", "")
|
12
|
-
.sub(/\.gl$/, ".rb")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
7
|
class Writer
|
17
|
-
include Utils
|
18
|
-
|
19
8
|
def initialize(
|
20
9
|
@content,
|
21
|
-
src_path : String,
|
22
|
-
@output_path : Pathname? = Pathname.new(
|
10
|
+
@src_path : String,
|
11
|
+
@output_path : Pathname? = Pathname.new(
|
12
|
+
Utils.src_path_to_output_path(src_path)
|
13
|
+
)
|
23
14
|
)
|
24
15
|
end
|
25
16
|
|
26
17
|
def run
|
27
18
|
FileUtils.mkdir_p(@output_path.parent) unless @output_path.parent.exist?
|
28
19
|
File.open(@output_path, "wb") do |file|
|
20
|
+
sb = shebang
|
21
|
+
file.puts sb if sb
|
29
22
|
file.puts @content
|
30
23
|
end
|
31
24
|
end
|
25
|
+
|
26
|
+
private def shebang
|
27
|
+
if @output_path.executable?
|
28
|
+
first_line = File.open(@src_path) { |f| f.readline }
|
29
|
+
first_line.start_with?("#!") ? first_line : nil
|
30
|
+
else
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
32
34
|
end
|
33
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gloss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- johansenja
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_blank
|
@@ -42,32 +42,32 @@ dependencies:
|
|
42
42
|
name: rbs
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.0.4
|
48
48
|
type: :runtime
|
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:
|
54
|
+
version: 1.0.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: steep
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.41.0
|
62
62
|
type: :runtime
|
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:
|
68
|
+
version: 0.41.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: pry-byebug
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rake-compiler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -132,8 +132,7 @@ extensions:
|
|
132
132
|
extra_rdoc_files: []
|
133
133
|
files:
|
134
134
|
- ".gitattributes"
|
135
|
-
- ".github/workflows/
|
136
|
-
- ".github/workflows/ruby_specs.yml"
|
135
|
+
- ".github/workflows/tests.yml"
|
137
136
|
- ".gitignore"
|
138
137
|
- ".gloss.yml"
|
139
138
|
- ".rspec"
|
@@ -159,32 +158,44 @@ files:
|
|
159
158
|
- ext/gloss/src/rb_ast.cr
|
160
159
|
- gloss.gemspec
|
161
160
|
- lib/gloss.rb
|
162
|
-
- lib/gloss/builder.rb
|
163
161
|
- lib/gloss/cli.rb
|
164
162
|
- lib/gloss/config.rb
|
165
163
|
- lib/gloss/errors.rb
|
166
164
|
- lib/gloss/initializer.rb
|
167
165
|
- lib/gloss/logger.rb
|
168
166
|
- lib/gloss/parser.rb
|
167
|
+
- lib/gloss/prog_loader.rb
|
169
168
|
- lib/gloss/scope.rb
|
170
169
|
- lib/gloss/source.rb
|
171
170
|
- lib/gloss/type_checker.rb
|
171
|
+
- lib/gloss/utils.rb
|
172
172
|
- lib/gloss/version.rb
|
173
|
+
- lib/gloss/visitor.rb
|
173
174
|
- lib/gloss/watcher.rb
|
174
175
|
- lib/gloss/writer.rb
|
175
|
-
-
|
176
|
+
- logo.svg
|
177
|
+
- sig/core.rbs
|
178
|
+
- sig/fast_blank.rbs
|
179
|
+
- sig/gls.rbs
|
176
180
|
- sig/listen.rbs
|
177
|
-
-
|
181
|
+
- sig/optparse.rbs
|
182
|
+
- sig/rubygems.rbs
|
183
|
+
- sig/yaml.rbs
|
184
|
+
- src/exe/gloss
|
185
|
+
- src/lib/gloss.gl
|
178
186
|
- src/lib/gloss/cli.gl
|
179
187
|
- src/lib/gloss/config.gl
|
180
188
|
- src/lib/gloss/errors.gl
|
181
189
|
- src/lib/gloss/initializer.gl
|
182
190
|
- src/lib/gloss/logger.gl
|
183
191
|
- src/lib/gloss/parser.gl
|
192
|
+
- src/lib/gloss/prog_loader.gl
|
184
193
|
- src/lib/gloss/scope.gl
|
185
194
|
- src/lib/gloss/source.gl
|
186
195
|
- src/lib/gloss/type_checker.gl
|
196
|
+
- src/lib/gloss/utils.gl
|
187
197
|
- src/lib/gloss/version.gl
|
198
|
+
- src/lib/gloss/visitor.gl
|
188
199
|
- src/lib/gloss/watcher.gl
|
189
200
|
- src/lib/gloss/writer.gl
|
190
201
|
homepage:
|
@@ -1,26 +0,0 @@
|
|
1
|
-
name: Crystal Specs
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ master ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ master ]
|
8
|
-
|
9
|
-
defaults:
|
10
|
-
run:
|
11
|
-
working-directory: ext/gloss
|
12
|
-
|
13
|
-
jobs:
|
14
|
-
build:
|
15
|
-
|
16
|
-
runs-on: ubuntu-latest
|
17
|
-
|
18
|
-
container:
|
19
|
-
image: crystallang/crystal
|
20
|
-
|
21
|
-
steps:
|
22
|
-
- uses: actions/checkout@v2
|
23
|
-
- name: Install dependencies
|
24
|
-
run: shards install
|
25
|
-
- name: Run tests
|
26
|
-
run: crystal spec
|
@@ -1,33 +0,0 @@
|
|
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: Ruby Specs
|
9
|
-
|
10
|
-
on:
|
11
|
-
push:
|
12
|
-
branches: [ master ]
|
13
|
-
pull_request:
|
14
|
-
branches: [ master ]
|
15
|
-
|
16
|
-
jobs:
|
17
|
-
test:
|
18
|
-
|
19
|
-
runs-on: ubuntu-latest
|
20
|
-
|
21
|
-
steps:
|
22
|
-
- uses: actions/checkout@v2
|
23
|
-
- name: Set up Ruby
|
24
|
-
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
25
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
26
|
-
# uses: ruby/setup-ruby@v1
|
27
|
-
uses: ruby/setup-ruby@21351ecc0a7c196081abca5dc55b08f085efe09a
|
28
|
-
with:
|
29
|
-
ruby-version: 2.7
|
30
|
-
- name: Install dependencies
|
31
|
-
run: bundle install
|
32
|
-
- name: Run tests
|
33
|
-
run: bundle exec rake build && bundle exec rake spec
|