starlark_compiler 0.1.0 → 0.2.0

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: c67a3032b052e3a24e9d962651efb0a13b983ca082a6df86d620378164dedc6e
4
- data.tar.gz: bcfaae939420a5976f25ac744d481374e0eb3000c0e909be07111465576c6d1b
3
+ metadata.gz: 5b74a86696f726f3151ccdd78309c4b1ebea7bf398cb9208798a52e673be4051
4
+ data.tar.gz: 365d6a79086a1dd56e173ab2f849f6ce35369a39c377fe135251efcd495a2433
5
5
  SHA512:
6
- metadata.gz: 4611b9f4ae5d7840dd40c387bd8b49e3caa83474bfee0fef3225cb6ec2591adcca4d5af7ab24e3989e0b773c85f6f12024ea9b9fae25830da9a1e3cb04c22164
7
- data.tar.gz: 5569c58921d1e4fbc4ef4c9dd2a38547a6660d52700a3b26f6ef0f4450cfa9f5b34bc249948e5355a3a6089d680bfc4776a89f39e15c30d44e542c69f36210a6
6
+ metadata.gz: e8c9cfde13ec42a01be510b584b63a8316b0cdeefbd9c6c507d6c25aa60915db40d03102ef4bde0d4dbb2d6333195adb943114d14d3707991781858d73ca1512
7
+ data.tar.gz: a2f8569be65150c0f0ee30ccc20a0ec8d6b4f1dd03b5879e9349d07ac25e6c424d3207d8c816befa387018325bfd9f4b45207aa548e31d65ba7ff2331a7b2a8a
data/.rubocop.yml CHANGED
@@ -1,3 +1,6 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
1
4
  Metrics:
2
5
  Enabled: false
3
6
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- starlark_compiler (0.1.0)
4
+ starlark_compiler (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -67,6 +67,8 @@ module StarlarkCompiler
67
67
  True.new
68
68
  when FalseClass
69
69
  False.new
70
+ when Numeric
71
+ Number.new(obj)
70
72
  else
71
73
  raise Error, "#{obj.inspect} not convertible to Node"
72
74
  end
@@ -82,6 +84,13 @@ module StarlarkCompiler
82
84
  class False < Node
83
85
  end
84
86
 
87
+ class Number < Node
88
+ attr_reader :number
89
+ def initialize(number)
90
+ @number = number
91
+ end
92
+ end
93
+
85
94
  class String < Node
86
95
  attr_reader :str
87
96
  def initialize(str)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module StarlarkCompiler
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -48,6 +48,10 @@ module StarlarkCompiler
48
48
  io << str.str.inspect
49
49
  end
50
50
 
51
+ def write_number(number)
52
+ io << number.number.to_s
53
+ end
54
+
51
55
  def delegate(template, obj)
52
56
  snake_case = lambda do |str|
53
57
  return str.downcase if str =~ /^[A-Z_]+$/
@@ -63,7 +67,7 @@ module StarlarkCompiler
63
67
 
64
68
  cls = cls.superclass
65
69
  end
66
- raise Error, "No #{template} for #{obj.class}"
70
+ raise "No #{template} for #{obj.class}"
67
71
  end
68
72
 
69
73
  def write_function_call(call)
@@ -159,6 +163,14 @@ module StarlarkCompiler
159
163
  str.str.size <= 50
160
164
  end
161
165
 
166
+ def single_line_number?(_)
167
+ true
168
+ end
169
+
170
+ def single_line_binary_operator?(operator)
171
+ single_line?(operator.lhs) && single_line?(operator.rhs)
172
+ end
173
+
162
174
  def single_line_function_call?(call)
163
175
  if call.args.empty?
164
176
  call.kwargs.size <= 1 &&
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: starlark_compiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Giddins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2020-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler