orenono 0.0.2 → 0.0.3
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/.rubocop.yml +1 -0
- data/README.md +42 -2
- data/Rakefile +2 -2
- data/bin/orenono +9 -0
- data/lib/generator.rb +77 -0
- data/lib/orenono/version.rb +1 -1
- data/lib/orenono_core.rb +10 -2
- data/rubocop-todo.yml +15 -0
- data/spec/generator_spec.rb +71 -0
- data/spec/orenono_core_spec.rb +57 -55
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e48e6407a724809d4b8bd117d6eb8fc06e9bfa3
|
4
|
+
data.tar.gz: 3ce7a6805ff09af7476a0cf48c141ba5902b3c97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6055105683308a517c76163f4f01503bd510693b88ee9bd878ecd6234102086699ed2d2b1ca48bd6c1e3aac93b92a131853c4853ba1c43c2052b08a5678f2ff9
|
7
|
+
data.tar.gz: 02634f14588ea542781fc25773e97bdec67f311ddd3a94f639ce11e535dbc39c0c22192711ca5a9aea30126a02821925d738c89e1bfdfb7dc10182705972b338
|
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: rubocop-todo.yml
|
data/README.md
CHANGED
@@ -32,8 +32,9 @@ Or install it yourself as:
|
|
32
32
|
~~~bash
|
33
33
|
$ orenono h
|
34
34
|
Commands:
|
35
|
-
orenono convert # Convert Brainf*ck default syntax to your
|
35
|
+
orenono convert # Convert Brainf*ck default syntax to your Orenonof...
|
36
36
|
orenono execute # Execute Brainf**k
|
37
|
+
orenono generate # Generate Brainf*ck code from ascii code text.
|
37
38
|
orenono help [COMMAND] # Describe available commands or one specific command
|
38
39
|
orenono init # Generate Orenonofile template
|
39
40
|
orenono version # version
|
@@ -41,7 +42,6 @@ Commands:
|
|
41
42
|
Options:
|
42
43
|
-h, [--help] # help message.
|
43
44
|
[--version] # version
|
44
|
-
|
45
45
|
~~~
|
46
46
|
|
47
47
|
### Generate Orenonofile
|
@@ -157,6 +157,45 @@ $ orenono e sample.bf
|
|
157
157
|
Hello, world!$
|
158
158
|
~~~
|
159
159
|
|
160
|
+
### Generate Brainf*ck code from ascii code text.
|
161
|
+
|
162
|
+
* Default syntax case
|
163
|
+
|
164
|
+
~~~bash
|
165
|
+
$ orenono generate 'Hello, world!' > hello.bf
|
166
|
+
$ cat hello.bf
|
167
|
+
++++++++++[>+++++++<-]>++.+++++++++++++++++++++++++++++.+++++++..+++.-------------------------------------------------------------------.------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.--------.+++.------.--------.-------------------------------------------------------------------.
|
168
|
+
$ orenono e hello.bf
|
169
|
+
Hello, world!
|
170
|
+
~~~
|
171
|
+
|
172
|
+
* Original syntax case.
|
173
|
+
|
174
|
+
Orenonofile
|
175
|
+
|
176
|
+
~~~ruby
|
177
|
+
# encoding: utf-8
|
178
|
+
|
179
|
+
increment "俺について来い!!"
|
180
|
+
decrement "頑張れよ!!"
|
181
|
+
start_loop "できる!できる!絶対にできるんだから!"
|
182
|
+
end_loop "諦めんなよ!"
|
183
|
+
next_cursol "もっと熱くなれよ…!!"
|
184
|
+
previous_cursol "ぬるま湯なんかつかってんじゃねぇよお前!!"
|
185
|
+
display "人の弱点を見つける天才よりも、人を褒める天才がいい"
|
186
|
+
read "熱い血燃やしてけよ…!!"
|
187
|
+
~~~
|
188
|
+
|
189
|
+
* results
|
190
|
+
|
191
|
+
~~~bash
|
192
|
+
$ orenono g 'Hello, world!' > hello.shuzo
|
193
|
+
$ cat hello.shuzo
|
194
|
+
俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来 い!!できる!できる!絶対にできるんだから!もっと熱くなれよ…!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺 について来い!!ぬるま湯なんかつかってんじゃねぇよお前!!頑張れよ!!諦めんなよ!もっと熱くなれよ…!!俺について来い!!俺について来い!!人の弱点を見つける天才よりも、人を褒める天才がいい俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!! 俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来 い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺につ いて来い!!人の弱点を見つける天才よりも、人を褒める天才がいい俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺に ついて来い!!人の弱点を見つける天才よりも、人を褒める天才がいい人の弱点を見つける天才よりも、人を褒める天才がいい俺について来い!!俺について来い!!俺について来い!!人の弱 点を見つける天才よりも、人を褒める天才がいい頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ! !頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張 れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ! !頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張 れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!人の弱点を見つける天才 よりも、人を褒める天才がいい頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!人 の弱点を見つける天才よりも、人を褒める天才がいい俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!! 俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来 い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺につ いて来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!! 俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来 い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺につ いて来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!! 俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来 い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺について来い!!俺につ いて来い!!俺について来い!!俺について来い!!人の弱点を見つける天才よりも、人を褒める天才がいい頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張 れよ!!頑張れよ!!人の弱点を見つける天才よりも、人を褒める天才がいい俺について来い!!俺について来い!!俺について来い!!人の弱点を見つける天才よりも、人を褒める天才がいい 頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!人の弱点を見つける天才よりも、人を褒める天才がいい頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張 れよ!!頑張れよ!!頑張れよ!!頑張れよ!!人の弱点を見つける天才よりも、人を褒める天才がいい頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ !!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑 張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ !!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑 張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ!!頑張れよ !!頑張れよ!!頑張れよ!!人の弱点を見つける天才よりも、人を褒める天才がいい
|
195
|
+
$ orenono e hello.shuzo
|
196
|
+
Hello, world!
|
197
|
+
~~~
|
198
|
+
|
160
199
|
## Brainfuck Derivation Language Samples
|
161
200
|
|
162
201
|
### Sample Define1
|
@@ -224,6 +263,7 @@ Hello, world!
|
|
224
263
|
~~~
|
225
264
|
|
226
265
|
## History
|
266
|
+
* version 0.0.3 : Add Brainf*ck code generator from ASCII code text.
|
227
267
|
* version 0.0.2 : Add converter(Brainf*ck default syntax to your Orenonofile syntax).
|
228
268
|
* version 0.0.1 : First release.
|
229
269
|
|
data/Rakefile
CHANGED
data/bin/orenono
CHANGED
@@ -5,6 +5,7 @@ require 'orenono_core'
|
|
5
5
|
require 'orenono/version'
|
6
6
|
require 'thor'
|
7
7
|
|
8
|
+
# rubocop:disable LineLength
|
8
9
|
module Orenono
|
9
10
|
# = Orenono CLI
|
10
11
|
class CLI < Thor
|
@@ -31,6 +32,13 @@ module Orenono
|
|
31
32
|
exit(0)
|
32
33
|
end
|
33
34
|
|
35
|
+
desc 'generate', 'Generate Brainf*ck code from ascii code text.'
|
36
|
+
def generate(ascii_text)
|
37
|
+
exit(1) unless ascii_text
|
38
|
+
puts Orenono::Core.new.generate_code_from_ascii_text(ascii_text)
|
39
|
+
exit(0)
|
40
|
+
end
|
41
|
+
|
34
42
|
desc 'version', 'version'
|
35
43
|
def version
|
36
44
|
p Orenono::VERSION
|
@@ -39,3 +47,4 @@ module Orenono
|
|
39
47
|
end
|
40
48
|
|
41
49
|
Orenono::CLI.start(ARGV)
|
50
|
+
# rubocop:enable LineLength
|
data/lib/generator.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'orenono_dsl'
|
3
|
+
require 'orenono_dsl_model'
|
4
|
+
|
5
|
+
# rubocop:disable LineLength
|
6
|
+
module Orenono
|
7
|
+
# Brainf*ck code generator
|
8
|
+
class Generator
|
9
|
+
attr_reader :tables, :init_codes, :pointer, :config
|
10
|
+
|
11
|
+
def self.generate(text, config)
|
12
|
+
bf = new(text[0], config)
|
13
|
+
text.split('').map(&:ord).each_with_object([bf.init_codes]) do |char, codes|
|
14
|
+
codes << bf.diff(char)
|
15
|
+
codes << bf.output
|
16
|
+
end.join
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(char, config)
|
20
|
+
char_code = char.ord
|
21
|
+
repeat = char_code / 10
|
22
|
+
rest = char_code % 10
|
23
|
+
@tables = []
|
24
|
+
@pointer = 0
|
25
|
+
@config = config
|
26
|
+
@init_codes = ten_increment(config) +
|
27
|
+
config.start_loop +
|
28
|
+
config.next_cursol +
|
29
|
+
increment(repeat) +
|
30
|
+
config.previous_cursol +
|
31
|
+
config.decrement +
|
32
|
+
config.end_loop +
|
33
|
+
config.next_cursol +
|
34
|
+
increment(rest)
|
35
|
+
@tables[@pointer] = char_code
|
36
|
+
end
|
37
|
+
|
38
|
+
def increment(count = 1)
|
39
|
+
@tables[@pointer] = 0 unless @tables[@pointer]
|
40
|
+
@tables[@pointer] += count
|
41
|
+
@config.increment * count
|
42
|
+
end
|
43
|
+
|
44
|
+
def decrement(count = 1)
|
45
|
+
@tables[@pointer] -= count
|
46
|
+
@config.decrement * count
|
47
|
+
end
|
48
|
+
|
49
|
+
def diff(char_code)
|
50
|
+
diff_of_code = char_code - @tables[@pointer]
|
51
|
+
return '' if diff_of_code.zero?
|
52
|
+
@tables[@pointer] += diff_of_code
|
53
|
+
diff_of_code > 0 ? (@config.increment * diff_of_code) : (@config.decrement * diff_of_code.abs)
|
54
|
+
end
|
55
|
+
|
56
|
+
def next_pointer(count = 1)
|
57
|
+
@pointer += count
|
58
|
+
@config.next_cursol * count
|
59
|
+
end
|
60
|
+
|
61
|
+
def previous_pointer(count = 1)
|
62
|
+
@pointer -= count
|
63
|
+
@config.previous_cursol * count
|
64
|
+
end
|
65
|
+
|
66
|
+
def output(count = 1)
|
67
|
+
@config.display * count
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def ten_increment(config)
|
73
|
+
config.increment * 10
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
# rubocop:enable LineLength
|
data/lib/orenono/version.rb
CHANGED
data/lib/orenono_core.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require 'brain'
|
3
3
|
require 'orenono_dsl'
|
4
|
+
require 'generator'
|
4
5
|
|
5
6
|
module Orenono
|
6
7
|
# Orenono Core
|
@@ -60,12 +61,19 @@ read ","
|
|
60
61
|
dsl = read_dsl
|
61
62
|
code = read_code(file)
|
62
63
|
config = dsl.orenono
|
63
|
-
convert(
|
64
|
+
convert(code, config.default_syntaxes, config.syntaxes)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Generate Brainf*ck code from ascii code text.
|
68
|
+
# If you create original syntax in Orenonofile, output syntax is your syntax.
|
69
|
+
def generate_code_from_ascii_text(ascii_text)
|
70
|
+
config = read_dsl.orenono
|
71
|
+
Generator.generate(ascii_text, config)
|
64
72
|
end
|
65
73
|
|
66
74
|
private
|
67
75
|
|
68
|
-
def convert(
|
76
|
+
def convert(src, from_syntaxes, to_syntaxes)
|
69
77
|
from_syntaxes.each_with_index do |syntax, i|
|
70
78
|
src = src.gsub(syntax, to_syntaxes[i])
|
71
79
|
end
|
data/rubocop-todo.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2014-09-11 22:13:09 +0900 using RuboCop version 0.21.0.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 1
|
9
|
+
LineLength:
|
10
|
+
Max: 81
|
11
|
+
|
12
|
+
# Offense count: 1
|
13
|
+
# Configuration parameters: CountComments.
|
14
|
+
MethodLength:
|
15
|
+
Max: 16
|
@@ -0,0 +1,71 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'generator'
|
4
|
+
|
5
|
+
# rubocop:disable Tab, UnusedMethodArgument, LineLength
|
6
|
+
describe Orenono::Generator do
|
7
|
+
context :generate do
|
8
|
+
cases = [
|
9
|
+
{
|
10
|
+
case_no: 1,
|
11
|
+
case_title: 'default case',
|
12
|
+
config: Orenono::DslModel.new.tap do |e|
|
13
|
+
e.increment = '+'
|
14
|
+
e.decrement = '-'
|
15
|
+
e.start_loop = '['
|
16
|
+
e.end_loop = ']'
|
17
|
+
e.next_cursol = '>'
|
18
|
+
e.previous_cursol = '<'
|
19
|
+
e.display = '.'
|
20
|
+
e.read = ','
|
21
|
+
end,
|
22
|
+
text: 'Hello, world!',
|
23
|
+
expected: '++++++++++[>+++++++<-]>++.+++++++++++++++++++++++++++++.+++++++..+++.-------------------------------------------------------------------.------------.+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.--------.+++.------.--------.-------------------------------------------------------------------.'
|
24
|
+
},
|
25
|
+
{
|
26
|
+
case_no: 2,
|
27
|
+
case_title: 'original case',
|
28
|
+
config: Orenono::DslModel.new.tap do |e|
|
29
|
+
e.increment = 'add'
|
30
|
+
e.decrement = 'diff'
|
31
|
+
e.start_loop = 'start'
|
32
|
+
e.end_loop = 'end'
|
33
|
+
e.next_cursol = 'next'
|
34
|
+
e.previous_cursol = 'previous'
|
35
|
+
e.display = 'display'
|
36
|
+
e.read = 'read'
|
37
|
+
end,
|
38
|
+
text: 'Hello, world!',
|
39
|
+
expected: 'addaddaddaddaddaddaddaddaddaddstartnextaddaddaddaddaddaddaddpreviousdiffendnextaddadddisplayaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddadddisplayaddaddaddaddaddaddadddisplaydisplayaddaddadddisplaydiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdisplaydiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdisplayaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddaddadddisplaydiffdiffdiffdiffdiffdiffdiffdiffdisplayaddaddadddisplaydiffdiffdiffdiffdiffdiffdisplaydiffdiffdiffdiffdiffdiffdiffdiffdisplaydiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdiffdisplay'
|
40
|
+
}
|
41
|
+
]
|
42
|
+
|
43
|
+
cases.each do |c|
|
44
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
45
|
+
begin
|
46
|
+
case_before c
|
47
|
+
|
48
|
+
# -- given --
|
49
|
+
# nothing
|
50
|
+
|
51
|
+
# -- when --
|
52
|
+
actual = Orenono::Generator.generate(c[:text], c[:config])
|
53
|
+
|
54
|
+
# -- then --
|
55
|
+
expect(actual).to eq(c[:expected])
|
56
|
+
ensure
|
57
|
+
case_after c
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def case_before(c)
|
62
|
+
# implement each case before
|
63
|
+
end
|
64
|
+
|
65
|
+
def case_after(c)
|
66
|
+
# implement each case after
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
# rubocop:enable Tab, UnusedMethodArgument, LineLength
|
data/spec/orenono_core_spec.rb
CHANGED
@@ -1,55 +1,57 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
e.
|
15
|
-
e.
|
16
|
-
e.
|
17
|
-
e.
|
18
|
-
e.
|
19
|
-
e.
|
20
|
-
e.
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'orenono_core'
|
4
|
+
require 'orenono_dsl_model'
|
5
|
+
|
6
|
+
# rubocop:disable Tab, UnusedMethodArgument, LineLength
|
7
|
+
describe Orenono::Core do
|
8
|
+
context :convert do
|
9
|
+
cases = [
|
10
|
+
{
|
11
|
+
case_no: 1,
|
12
|
+
case_title: 'valid case',
|
13
|
+
config: Orenono::DslModel.new.tap do |e|
|
14
|
+
e.increment = 'add'
|
15
|
+
e.decrement = 'diff'
|
16
|
+
e.start_loop = 'start'
|
17
|
+
e.end_loop = 'end'
|
18
|
+
e.next_cursol = 'next'
|
19
|
+
e.previous_cursol = 'previous'
|
20
|
+
e.display = 'display'
|
21
|
+
e.read = 'read'
|
22
|
+
end,
|
23
|
+
src: '++--[[]]>><<..,,',
|
24
|
+
bf_to_your: true,
|
25
|
+
expected: 'addadddiffdiffstartstartendendnextnextpreviouspreviousdisplaydisplayreadread'
|
26
|
+
}
|
27
|
+
]
|
28
|
+
|
29
|
+
cases.each do |c|
|
30
|
+
it "|case_no=#{c[:case_no]}|case_title=#{c[:case_title]}" do
|
31
|
+
begin
|
32
|
+
case_before c
|
33
|
+
|
34
|
+
# -- given --
|
35
|
+
orenono_core = Orenono::Core.new
|
36
|
+
|
37
|
+
# -- when --
|
38
|
+
actual = orenono_core.send(:convert, c[:src], c[:config].default_syntaxes, c[:config].syntaxes)
|
39
|
+
|
40
|
+
# -- then --
|
41
|
+
expect(actual).to eq(c[:expected])
|
42
|
+
ensure
|
43
|
+
case_after c
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def case_before(c)
|
48
|
+
# implement each case before
|
49
|
+
end
|
50
|
+
|
51
|
+
def case_after(c)
|
52
|
+
# implement each case after
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
# rubocop:enable Tab, UnusedMethodArgument, LineLength
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orenono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbpgr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -63,6 +63,7 @@ files:
|
|
63
63
|
- .coveralls.yml
|
64
64
|
- .gitignore
|
65
65
|
- .rspec
|
66
|
+
- .rubocop.yml
|
66
67
|
- .travis.yml
|
67
68
|
- Gemfile
|
68
69
|
- LICENSE.txt
|
@@ -70,11 +71,13 @@ files:
|
|
70
71
|
- Rakefile
|
71
72
|
- bin/orenono
|
72
73
|
- lib/brain.rb
|
74
|
+
- lib/generator.rb
|
73
75
|
- lib/orenono/version.rb
|
74
76
|
- lib/orenono_core.rb
|
75
77
|
- lib/orenono_dsl.rb
|
76
78
|
- lib/orenono_dsl_model.rb
|
77
79
|
- orenono.gemspec
|
80
|
+
- rubocop-todo.yml
|
78
81
|
- samples/default/Orenonofile
|
79
82
|
- samples/default/sample.bf
|
80
83
|
- samples/pattern1/Orenonofile
|
@@ -86,6 +89,7 @@ files:
|
|
86
89
|
- samples/pattern4/Orenonofile
|
87
90
|
- samples/pattern4/hello_world.bf
|
88
91
|
- spec/brain_spec.rb
|
92
|
+
- spec/generator_spec.rb
|
89
93
|
- spec/orenono_core_spec.rb
|
90
94
|
- spec/spec_helper.rb
|
91
95
|
homepage: https://github.com/tbpgr/orenono
|
@@ -114,5 +118,6 @@ specification_version: 4
|
|
114
118
|
summary: New Brainf**k derivation language generator and executor.
|
115
119
|
test_files:
|
116
120
|
- spec/brain_spec.rb
|
121
|
+
- spec/generator_spec.rb
|
117
122
|
- spec/orenono_core_spec.rb
|
118
123
|
- spec/spec_helper.rb
|