gloss 0.1.1 → 0.1.6
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 +1 -0
- data/Gemfile.lock +12 -10
- data/README.md +24 -27
- data/Rakefile +4 -2
- data/ext/gloss/Makefile +6 -10
- data/ext/gloss/lib/cr_ruby.cr +5 -4
- data/ext/gloss/src/gloss.cr +7 -2
- data/gloss.gemspec +4 -3
- data/lib/gloss.rb +4 -8
- data/lib/gloss/cli.rb +3 -3
- data/lib/gloss/config.rb +14 -11
- data/lib/gloss/errors.rb +2 -3
- data/lib/gloss/initializer.rb +2 -3
- data/lib/gloss/logger.rb +7 -3
- data/lib/gloss/parser.rb +2 -3
- data/lib/gloss/prog_loader.rb +55 -36
- data/lib/gloss/runtime.rb +25 -0
- data/lib/gloss/scope.rb +2 -3
- data/lib/gloss/source.rb +2 -3
- data/lib/gloss/type_checker.rb +18 -9
- data/lib/gloss/utils.rb +12 -14
- data/lib/gloss/version.rb +4 -5
- data/lib/gloss/visitor.rb +22 -8
- data/lib/gloss/watcher.rb +14 -8
- data/lib/gloss/writer.rb +38 -22
- data/logo.svg +6 -0
- data/src/lib/gloss.gl +2 -2
- data/src/lib/gloss/cli.gl +1 -0
- data/src/lib/gloss/config.gl +11 -7
- data/src/lib/gloss/logger.gl +3 -1
- data/src/lib/gloss/prog_loader.gl +38 -27
- data/src/lib/gloss/runtime.gl +20 -0
- data/src/lib/gloss/type_checker.gl +17 -6
- data/src/lib/gloss/utils.gl +7 -5
- data/src/lib/gloss/version.gl +1 -1
- data/src/lib/gloss/visitor.gl +18 -7
- data/src/lib/gloss/watcher.gl +10 -4
- data/src/lib/gloss/writer.gl +28 -12
- metadata +27 -11
- data/.github/workflows/crystal_specs.yml +0 -26
- data/.github/workflows/ruby_specs.yml +0 -33
data/src/lib/gloss/watcher.gl
CHANGED
@@ -2,6 +2,8 @@ require "listen"
|
|
2
2
|
|
3
3
|
module Gloss
|
4
4
|
class Watcher
|
5
|
+
@listener: Listen?
|
6
|
+
|
5
7
|
def initialize(@paths : Array[String])
|
6
8
|
if @paths.empty?
|
7
9
|
@paths = [File.join(Dir.pwd, Config.src_dir)]
|
@@ -22,7 +24,7 @@ module Gloss
|
|
22
24
|
|
23
25
|
def watch
|
24
26
|
Gloss.logger.info "Now listening for changes in #{@paths.join(', ')}"
|
25
|
-
listener
|
27
|
+
@listener ||= Listen.to(
|
26
28
|
*@paths,
|
27
29
|
latency: 2,
|
28
30
|
only: @only
|
@@ -55,12 +57,16 @@ module Gloss
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
begin
|
58
|
-
listener.start
|
60
|
+
@listener.start
|
59
61
|
sleep
|
60
62
|
rescue Interrupt
|
61
|
-
|
62
|
-
exit 0
|
63
|
+
kill
|
63
64
|
end
|
64
65
|
end
|
66
|
+
|
67
|
+
def kill
|
68
|
+
Gloss.logger.info "Interrupt signal received, shutting down"
|
69
|
+
@listener.stop if @listener
|
70
|
+
end
|
65
71
|
end
|
66
72
|
end
|
data/src/lib/gloss/writer.gl
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require "pathname"
|
4
2
|
require "fileutils"
|
5
3
|
|
@@ -8,28 +6,46 @@ module Gloss
|
|
8
6
|
def initialize(
|
9
7
|
@content,
|
10
8
|
@src_path : String,
|
11
|
-
@
|
12
|
-
Utils.src_path_to_output_path(src_path)
|
13
|
-
)
|
9
|
+
@output : Pathname | IO | NilClass = nil
|
14
10
|
)
|
15
11
|
end
|
16
12
|
|
17
13
|
def run
|
18
|
-
|
19
|
-
File.open(@output_path, "wb") do |file|
|
14
|
+
write_to_output do |otpt|
|
20
15
|
sb = shebang
|
21
|
-
|
22
|
-
|
16
|
+
otpt.puts sb if sb
|
17
|
+
otpt.puts @content
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
26
21
|
private def shebang
|
27
|
-
|
28
|
-
|
29
|
-
|
22
|
+
case @output
|
23
|
+
when Pathname
|
24
|
+
if @output.executable?
|
25
|
+
first_line = File.open(@src_path) { |f| f.readline }
|
26
|
+
first_line.start_with?("#!") ? first_line : nil
|
27
|
+
end
|
30
28
|
else
|
31
29
|
nil
|
32
30
|
end
|
33
31
|
end
|
32
|
+
|
33
|
+
private def write_to_output(&blk)
|
34
|
+
case @output
|
35
|
+
when IO, StringIO
|
36
|
+
# blk.call(@output)
|
37
|
+
yield @output
|
38
|
+
else
|
39
|
+
output = @output || Pathname.new(Utils.src_path_to_output_path(@src_path))
|
40
|
+
FileUtils.mkdir_p(output.parent) unless output.parent.exist?
|
41
|
+
File.open(output, "wb") do |file|
|
42
|
+
# blk.call(file)
|
43
|
+
yield file
|
44
|
+
end
|
45
|
+
if Config.prettify_output_executable_path
|
46
|
+
system Config.prettify_output_executable_path, @output.to_s
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
34
50
|
end
|
35
51
|
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- johansenja
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fast_blank
|
@@ -42,24 +42,38 @@ 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
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.41.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.41.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-byebug
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
|
-
type: :
|
76
|
+
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
@@ -95,7 +109,7 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: rubocop
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - ">="
|
@@ -109,7 +123,7 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: rufo
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - ">="
|
@@ -132,8 +146,7 @@ extensions:
|
|
132
146
|
extra_rdoc_files: []
|
133
147
|
files:
|
134
148
|
- ".gitattributes"
|
135
|
-
- ".github/workflows/
|
136
|
-
- ".github/workflows/ruby_specs.yml"
|
149
|
+
- ".github/workflows/tests.yml"
|
137
150
|
- ".gitignore"
|
138
151
|
- ".gloss.yml"
|
139
152
|
- ".rspec"
|
@@ -166,6 +179,7 @@ files:
|
|
166
179
|
- lib/gloss/logger.rb
|
167
180
|
- lib/gloss/parser.rb
|
168
181
|
- lib/gloss/prog_loader.rb
|
182
|
+
- lib/gloss/runtime.rb
|
169
183
|
- lib/gloss/scope.rb
|
170
184
|
- lib/gloss/source.rb
|
171
185
|
- lib/gloss/type_checker.rb
|
@@ -174,6 +188,7 @@ files:
|
|
174
188
|
- lib/gloss/visitor.rb
|
175
189
|
- lib/gloss/watcher.rb
|
176
190
|
- lib/gloss/writer.rb
|
191
|
+
- logo.svg
|
177
192
|
- sig/core.rbs
|
178
193
|
- sig/fast_blank.rbs
|
179
194
|
- sig/gls.rbs
|
@@ -190,6 +205,7 @@ files:
|
|
190
205
|
- src/lib/gloss/logger.gl
|
191
206
|
- src/lib/gloss/parser.gl
|
192
207
|
- src/lib/gloss/prog_loader.gl
|
208
|
+
- src/lib/gloss/runtime.gl
|
193
209
|
- src/lib/gloss/scope.gl
|
194
210
|
- src/lib/gloss/source.gl
|
195
211
|
- src/lib/gloss/type_checker.gl
|
@@ -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-20.04
|
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
|