nilac 0.0.4.0.1 → 0.0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +16 -18
- data/README.md +2 -1
- data/bin/nilac +535 -123
- data/lib/nilac/version.rb +1 -1
- data/shark/features/regular_if.feature +11 -0
- data/shark/features/unless_until.feature +11 -0
- data/shark/test_files/correct_default_parameters.js +6 -1
- data/shark/test_files/correct_regular_if.js +14 -0
- data/shark/test_files/correct_unless_until.js +21 -0
- data/shark/test_files/default_parameters.nila +3 -1
- data/shark/test_files/regular_if.nila +19 -0
- data/shark/test_files/unless_until.nila +10 -0
- data/src/nilac.rb +535 -123
- metadata +8 -4
- data/bin/.gitignore +0 -2
data/lib/nilac/version.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: This feature bring Ruby's if statement to Nila.
|
2
|
+
Scenario: Input function with if statements
|
3
|
+
Given the input file "regular_if.nila"
|
4
|
+
When the ~compiler is run
|
5
|
+
The output file must be "regular_if.js"
|
6
|
+
The output file must equal "correct_regular_if.js"
|
7
|
+
|
8
|
+
Configurations:
|
9
|
+
|
10
|
+
~compiler => src/nilac.rb
|
11
|
+
:v $cliusage => ruby :v --compile $file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: This feature bring Ruby's unless and until statements to Nila.
|
2
|
+
Scenario: Input function with unless and until statements
|
3
|
+
Given the input file "unless_until.nila"
|
4
|
+
When the ~compiler is run
|
5
|
+
The output file must be "unless_until.js"
|
6
|
+
The output file must equal "correct_unless_until.js"
|
7
|
+
|
8
|
+
Configurations:
|
9
|
+
|
10
|
+
~compiler => src/nilac.rb
|
11
|
+
:v $cliusage => ruby :v --compile $file
|
@@ -3,12 +3,17 @@
|
|
3
3
|
// This is a demo of default parameters
|
4
4
|
|
5
5
|
function fill(container,liquid) {
|
6
|
-
if (
|
6
|
+
if (container === null) {
|
7
|
+
container = "cup";
|
8
|
+
}
|
9
|
+
if (liquid === null) {
|
7
10
|
liquid = "coffee";
|
8
11
|
}
|
9
12
|
return console.log("Filling " + container + " with " + liquid);
|
10
13
|
}
|
11
14
|
|
15
|
+
fill();
|
16
|
+
|
12
17
|
fill("cup");
|
13
18
|
|
14
19
|
fill("bowl","soup");
|
@@ -0,0 +1,14 @@
|
|
1
|
+
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
+
(function() {
|
3
|
+
if (visitor_present) {;
|
4
|
+
//This file is for demonstration purpose. It doesn't really achieve anything
|
5
|
+
if (active || happy) {;
|
6
|
+
console.log("Hello Wonderful Visitor!");
|
7
|
+
} else if (idle && not_engaged) {;
|
8
|
+
console.log("Hello Visitor! It is time to engage!");
|
9
|
+
} else {
|
10
|
+
console.log("Hello user!");
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
}).call(this);
|
@@ -0,0 +1,21 @@
|
|
1
|
+
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
+
(function() {
|
3
|
+
var i;
|
4
|
+
|
5
|
+
// This file demonstrates unless && until statements.
|
6
|
+
|
7
|
+
// Examples are from http://www.skorks.com/2009/09/a-wealth-of-ruby-loops-and-iterators/ &&
|
8
|
+
|
9
|
+
// http://37signals.com/svn/posts/2699-making-sense-with-rubys-unless
|
10
|
+
|
11
|
+
if (!(person.present)) {
|
12
|
+
console.log("There's no such person");
|
13
|
+
}
|
14
|
+
|
15
|
+
i = 0;
|
16
|
+
|
17
|
+
while (!(i > 10)) {
|
18
|
+
i += 1;
|
19
|
+
}
|
20
|
+
|
21
|
+
}).call(this);
|
@@ -0,0 +1,19 @@
|
|
1
|
+
if visitor_present?
|
2
|
+
|
3
|
+
#This file is for demonstration purpose. It doesn't really achieve anything
|
4
|
+
|
5
|
+
if active? or happy?
|
6
|
+
|
7
|
+
puts "Hello Wonderful Visitor!"
|
8
|
+
|
9
|
+
elsif idle? and not_engaged?
|
10
|
+
|
11
|
+
puts "Hello Visitor! It is time to engage!"
|
12
|
+
|
13
|
+
else
|
14
|
+
|
15
|
+
puts "Hello user!"
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# This file demonstrates unless and until statements.
|
2
|
+
|
3
|
+
# Examples are from http://www.skorks.com/2009/09/a-wealth-of-ruby-loops-and-iterators/ and
|
4
|
+
# http://37signals.com/svn/posts/2699-making-sense-with-rubys-unless
|
5
|
+
|
6
|
+
puts "There's no such person" unless person.present?
|
7
|
+
|
8
|
+
i = 0
|
9
|
+
|
10
|
+
i += 1 until i > 10
|