shuwar 1.2.0 → 1.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ddc147f458aa5dc51b986b2d02eaf293732a792
4
- data.tar.gz: 934e9a7034d0582289f25c51b9206e2adfdc99d5
3
+ metadata.gz: 1909c5f5e8fd8443e2fd2920354cafcc5f1cdcd0
4
+ data.tar.gz: d494975a0d8cc4e33caeef0308a69cbe1c774018
5
5
  SHA512:
6
- metadata.gz: 70d051e0a81a39f10b044c5f413003f3d2e7b4141eea150b5abe76432cb6e9d4eb3385e3e8d1a9a4d4b56ece97f3955c72c6583f214efd67fcc801b6806fc778
7
- data.tar.gz: 1662c7ffb5ce1679a12625a79cde9b19f1fb1f318d6c98d2bcefb82076d467754ceabe3460d6652073b968d5fd1494d5bc30f53c48dcfad718777057c0a8ede6
6
+ metadata.gz: 669013248c1c819f895379b02f0b511b841ed79db560ee5bb0d394d16b20fbfdd6c2d7037aca5e52327aac3e01e219f3bb0c3e1aaaa537ad376167d69a1d5ef3
7
+ data.tar.gz: 5a7dc85c47835aee4b3378e0833fc763f44d49f5d56d2fd1058412dd8bc75aca9d038c16973435038598b8f8cd0323582df7a6a4b28ced1e2e81a6f006010266
@@ -1,4 +1,4 @@
1
- require "shuwar/stdlib"
1
+ require "shuwar"
2
2
 
3
3
  module Shuwar::Stdlib
4
4
  module Base
@@ -17,6 +17,29 @@ module Shuwar::Stdlib
17
17
 
18
18
  puts: lambda do |*vals|
19
19
  puts *vals
20
+ end,
21
+
22
+ load_file: lambda do |name|
23
+ File.open name do |f|
24
+ tk = Shuwar::Tokenizer.new f
25
+ parser = Shuwar::Parser.new tk
26
+ runtime = Shuwar::Runtime.new
27
+
28
+ parser.each_object do |x|
29
+ runtime.evaluate x
30
+ end
31
+
32
+ runtime
33
+ end
34
+ end,
35
+
36
+ fetch: lambda do |env, key|
37
+ env.get_value key
38
+ end,
39
+
40
+ from_file: lambda do |name, key|
41
+ env = evaluate [:load_file, name]
42
+ env.get_value key
20
43
  end
21
44
  }
22
45
 
@@ -14,7 +14,12 @@ module Shuwar::Stdlib
14
14
  def initialize(name, attrs, *children)
15
15
  @name = name.to_s
16
16
  @attrs = attrs.to_h
17
- @children = children
17
+ if children.all? {|a| a.is_a? String}
18
+ # Multi strings should get a space between them
19
+ @children = [children.join(" ")]
20
+ else
21
+ @children = children
22
+ end
18
23
  end
19
24
 
20
25
  def add_to(a)
@@ -56,10 +56,8 @@ module Shuwar
56
56
  block.call t.to_i
57
57
  when t.chars.all? {|c| ('1'..'9') === c or c == '.' }
58
58
  block.call t.to_f
59
- when /\A[a-zA-Z]\z/ =~ t[0] && t.chars.all? {|c| /\A[a-zA-Z0-9_]+\z/ =~ c }
60
- block.call t.to_sym
61
59
  else
62
- raise "#{t}? What was that?"
60
+ block.call t.to_sym
63
61
  end
64
62
  end
65
63
  else
@@ -1,3 +1,3 @@
1
1
  module Shuwar
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shuwar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dramforever
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-12 00:00:00.000000000 Z
11
+ date: 2014-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler