goling 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -22
- data/VERSION +1 -1
- data/goling.gemspec +62 -0
- data/lib/goling/reduction.rb +8 -18
- data/test/test_goling.rb +2 -2
- metadata +4 -3
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Goling is a linguistic compiler allowing you to compile and execute plain english.
|
4
4
|
And thus allows you to program in plain english provided you have the reduction rules needed.
|
5
5
|
|
6
|
-
Since
|
6
|
+
Since the code ends up compiled like all code should be you can execute your code so amazingly fast I am in awe just to be able to write this divine text to you about it.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -30,7 +30,7 @@ Since it compiled like all code should be you can execute your code so amazingly
|
|
30
30
|
all_dirs
|
31
31
|
end
|
32
32
|
|
33
|
-
reduce /
|
33
|
+
reduce /all files inside ({directories:[^}]*})/ => 'files' do |dirs|
|
34
34
|
dirs.map{ |f| File.new(f, "r") }
|
35
35
|
end
|
36
36
|
|
@@ -40,34 +40,34 @@ Since it compiled like all code should be you can execute your code so amazingly
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
|
43
|
+
"view all files inside all directories recursively".linguify.to_ruby
|
44
44
|
# => code = lambda do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
45
|
+
# directories_0 = Dir.entries(".").select { |f| ((not (f[0] == ".")) and File.directory?(f)) }
|
46
|
+
# directories_1 = (all_dirs = dirs
|
47
|
+
# Find.find(dirs) do |path|
|
48
|
+
# if FileTest.directory?(path) then
|
49
|
+
# if (File.basename(path)[0] == ".") then
|
50
|
+
# Find.prune
|
51
|
+
# else
|
52
|
+
# (all_dirs << path)
|
53
|
+
# next
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
# end
|
57
|
+
# all_dirs)
|
58
|
+
# files_2 = dirs.map { |f| File.new(f, "r") }
|
59
|
+
# files.each { |file| pp(file) }
|
60
|
+
# end
|
61
|
+
# Goling::Linguified.trampoline(code)
|
62
62
|
|
63
63
|
And if you simply want to execute your magnificent piece of art:
|
64
64
|
|
65
|
-
"view
|
65
|
+
"view all files inside all directories recursively".linguify.run
|
66
66
|
|
67
67
|
Or even:
|
68
68
|
|
69
69
|
# compile once, run plenty
|
70
|
-
code = "view
|
70
|
+
code = "view all files inside all directories recursively".linguify
|
71
71
|
loop do
|
72
72
|
code.run
|
73
73
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/goling.gemspec
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{goling}
|
8
|
+
s.version = "0.1.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = [%q{Patrick Hanevold}]
|
12
|
+
s.date = %q{2011-09-08}
|
13
|
+
s.description = %q{Goling is a linguistic compiler allowing you to compile and execute plain english.}
|
14
|
+
s.email = %q{patrick.hanevold@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
"Gemfile",
|
21
|
+
"Gemfile.lock",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"goling.gemspec",
|
26
|
+
"lib/goling.rb",
|
27
|
+
"lib/goling/linguified.rb",
|
28
|
+
"lib/goling/reduction.rb",
|
29
|
+
"test/helper.rb",
|
30
|
+
"test/test_goling.rb"
|
31
|
+
]
|
32
|
+
s.homepage = %q{http://github.com/patrickhno/goling}
|
33
|
+
s.licenses = [%q{MIT}]
|
34
|
+
s.require_paths = [%q{lib}]
|
35
|
+
s.rubygems_version = %q{1.8.8}
|
36
|
+
s.summary = %q{Goling, the linguistic compiler.}
|
37
|
+
|
38
|
+
if s.respond_to? :specification_version then
|
39
|
+
s.specification_version = 3
|
40
|
+
|
41
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
+
s.add_runtime_dependency(%q<sourcify>, [">= 0"])
|
43
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
44
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
45
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
46
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<sourcify>, [">= 0"])
|
49
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
50
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
51
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
52
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<sourcify>, [">= 0"])
|
56
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
57
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
58
|
+
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
59
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
data/lib/goling/reduction.rb
CHANGED
@@ -130,26 +130,16 @@ module Goling
|
|
130
130
|
def replace_variable_references(code,replacement,needle)
|
131
131
|
case code[0]
|
132
132
|
when :lasgn
|
133
|
-
if code[1] == needle
|
134
|
-
|
135
|
-
|
136
|
-
code[2..-1].each do |h|
|
137
|
-
replace_variable_references(h,replacement,needle)
|
138
|
-
end
|
133
|
+
code[1]=replacement if code[1] == needle
|
134
|
+
when :lvar
|
135
|
+
code[1]=replacement if code[1] == needle
|
139
136
|
when :call
|
140
|
-
|
141
|
-
if code[2] == needle
|
142
|
-
code[2]=replacement
|
143
|
-
end
|
144
|
-
replace_variable_references(code[3],replacement,needle)
|
137
|
+
code[2]=replacement if code[2] == needle
|
145
138
|
when :lvar
|
146
|
-
if code[1] == needle
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
code[1..-1].each do |h|
|
151
|
-
replace_variable_references(h,replacement,needle) if h.kind_of(Sexp)
|
152
|
-
end
|
139
|
+
code[1]=replacement if code[1] == needle
|
140
|
+
end
|
141
|
+
code[1..-1].each do |h|
|
142
|
+
replace_variable_references(h,replacement,needle) if h && h.kind_of?(Sexp)
|
153
143
|
end
|
154
144
|
end
|
155
145
|
|
data/test/test_goling.rb
CHANGED
@@ -22,7 +22,7 @@ class TestGoling < Test::Unit::TestCase
|
|
22
22
|
all_dirs
|
23
23
|
end
|
24
24
|
|
25
|
-
reduce /
|
25
|
+
reduce /all files inside ({directories:[^}]*})/ => 'files' do |dirs|
|
26
26
|
dirs.map{ |f| File.new(f, "r") }
|
27
27
|
end
|
28
28
|
|
@@ -32,6 +32,6 @@ class TestGoling < Test::Unit::TestCase
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
"view
|
35
|
+
"view all files inside all directories recursively".linguify.to_ruby.size > 0
|
36
36
|
end
|
37
37
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: goling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Patrick Hanevold
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-08 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sourcify
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- README.md
|
83
83
|
- Rakefile
|
84
84
|
- VERSION
|
85
|
+
- goling.gemspec
|
85
86
|
- lib/goling.rb
|
86
87
|
- lib/goling/linguified.rb
|
87
88
|
- lib/goling/reduction.rb
|
@@ -100,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
101
|
requirements:
|
101
102
|
- - ">="
|
102
103
|
- !ruby/object:Gem::Version
|
103
|
-
hash:
|
104
|
+
hash: 4126556151488913212
|
104
105
|
segments:
|
105
106
|
- 0
|
106
107
|
version: "0"
|