nilac 0.0.4.3.9.6 → 0.0.4.3.9.7
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/.gitignore +2 -1
- data/README.md +2 -0
- data/examples/decBin.js +2 -2
- data/examples/repl.js +31 -0
- data/examples/repl.nila +24 -0
- data/lib/nilac/add_semicolons.rb +1 -1
- data/lib/nilac/compile_blocks.rb +20 -2
- data/lib/nilac/compile_case_statement.rb +1 -1
- data/lib/nilac/compile_conditional_structures.rb +20 -8
- data/lib/nilac/compile_custom_function_map.rb +3 -1
- data/lib/nilac/compile_default_values.rb +15 -1
- data/lib/nilac/compile_integers.rb +147 -2
- data/lib/nilac/compile_lambdas.rb +22 -6
- data/lib/nilac/compile_loops.rb +1 -1
- data/lib/nilac/compile_monkey_patching.rb +189 -0
- data/lib/nilac/compile_named_functions.rb +44 -70
- data/lib/nilac/compile_parallel_assignment.rb +2 -2
- data/lib/nilac/compile_ruby_methods.rb +3 -1
- data/lib/nilac/compile_strings.rb +4 -4
- data/lib/nilac/friendly_errors.rb +95 -0
- data/lib/nilac/get_variables.rb +29 -18
- data/lib/nilac/lexical_scoped_function_variables.rb +6 -0
- data/lib/nilac/output_javascript.rb +9 -7
- data/lib/nilac/paranthesis_compactor.rb +37 -0
- data/lib/nilac/pretty_print_javascript.rb +53 -61
- data/lib/nilac/replace_multiline_comments.rb +6 -2
- data/lib/nilac/replace_named_functions.rb +41 -65
- data/lib/nilac/replace_strings.rb +40 -17
- data/lib/nilac/rollblocks.rb +86 -13
- data/lib/nilac/version.rb +1 -1
- data/lib/nilac.rb +46 -13
- data/shark/features/blocks.feature +11 -0
- data/shark/features/monkey_patch.feature +11 -0
- data/shark/test_files/blocks.nila +18 -0
- data/shark/test_files/correct_blocks.js +25 -0
- data/shark/test_files/correct_case.js +1 -1
- data/shark/test_files/correct_monkey_patch.js +24 -0
- data/shark/test_files/correct_multiple_return.js +2 -2
- data/shark/test_files/correct_splats.js +3 -3
- data/shark/test_files/lambda.nila +9 -1
- data/shark/test_files/monkey_patch.nila +18 -0
- data/shark/test_files/multiple_return.nila +8 -8
- data/shark/test_files/sample_class.nila +1 -1
- metadata +13 -7
- data/LICENSE +0 -20
- data/examples/countdown.nila +0 -31
- data/lib/nilac/compile_classes.rb +0 -19
- data/shark/test_files/array_sugar.nila +0 -3
- data/shark/test_files/class.nila +0 -7
data/lib/nilac.rb
CHANGED
@@ -22,13 +22,13 @@ module Nilac
|
|
22
22
|
require 'nilac/replace_named_functions'
|
23
23
|
require 'nilac/compile_parallel_assignment'
|
24
24
|
require 'nilac/compile_default_values'
|
25
|
+
require 'nilac/compile_chained_comparison'
|
25
26
|
require 'nilac/get_variables'
|
26
27
|
require 'nilac/remove_question_marks'
|
27
28
|
require 'nilac/compile_arrays'
|
28
29
|
require 'nilac/compile_hashes'
|
29
30
|
require 'nilac/compile_strings'
|
30
31
|
require 'nilac/compile_integers'
|
31
|
-
require 'nilac/compile_classes'
|
32
32
|
require 'nilac/compile_named_functions'
|
33
33
|
require 'nilac/compile_custom_function_map'
|
34
34
|
require 'nilac/compile_ruby_methods'
|
@@ -46,22 +46,30 @@ module Nilac
|
|
46
46
|
require 'nilac/output_javascript'
|
47
47
|
require 'nilac/create_mac_executable'
|
48
48
|
require 'nilac/parse_arguments'
|
49
|
-
require 'nilac/
|
49
|
+
require 'nilac/friendly_errors'
|
50
|
+
require 'nilac/compile_monkey_patching'
|
51
|
+
require 'nilac/line_number_encoding'
|
50
52
|
|
51
53
|
class NilaCompiler
|
52
54
|
|
55
|
+
include FriendlyErrors
|
56
|
+
|
53
57
|
def initialize(args)
|
54
58
|
|
55
59
|
@input_arguments = args
|
56
60
|
|
57
61
|
end
|
58
62
|
|
59
|
-
def compile(input_file_path, *output_file_name)
|
63
|
+
def compile(input_file_path, options = [], *output_file_name)
|
64
|
+
|
65
|
+
message,proceed = file_exist?(input_file_path)
|
60
66
|
|
61
|
-
if
|
67
|
+
if proceed
|
62
68
|
|
63
69
|
file_contents = read_file_line_by_line(input_file_path)
|
64
70
|
|
71
|
+
file_contents = file_contents.collect {|element| element.gsub("\r\n","\n")}
|
72
|
+
|
65
73
|
file_contents = extract_parsable_file(file_contents)
|
66
74
|
|
67
75
|
file_contents = compile_require_statements(file_contents)
|
@@ -74,6 +82,8 @@ module Nilac
|
|
74
82
|
|
75
83
|
file_contents = compile_heredocs(file_contents, temp_file)
|
76
84
|
|
85
|
+
file_contents,lambda_names = compile_lambdas(file_contents,temp_file)
|
86
|
+
|
77
87
|
file_contents,loop_vars = compile_loops(file_contents,temp_file)
|
78
88
|
|
79
89
|
file_contents = compile_interpolated_strings(file_contents)
|
@@ -84,8 +94,6 @@ module Nilac
|
|
84
94
|
|
85
95
|
file_contents = compile_conditional_structures(file_contents, temp_file)
|
86
96
|
|
87
|
-
file_contents,lambda_names = compile_lambdas(file_contents,temp_file)
|
88
|
-
|
89
97
|
file_contents = compile_blocks(file_contents,temp_file)
|
90
98
|
|
91
99
|
file_contents = compile_integers(file_contents)
|
@@ -106,6 +114,8 @@ module Nilac
|
|
106
114
|
|
107
115
|
file_contents, function_names = compile_named_functions(file_contents, named_functions, nested_functions, temp_file)
|
108
116
|
|
117
|
+
file_contents = compile_monkey_patching(file_contents,temp_file)
|
118
|
+
|
109
119
|
func_names = function_names.dup
|
110
120
|
|
111
121
|
file_contents, ruby_functions = compile_custom_function_map(file_contents)
|
@@ -138,10 +148,11 @@ module Nilac
|
|
138
148
|
|
139
149
|
else
|
140
150
|
|
141
|
-
puts
|
151
|
+
puts message
|
142
152
|
|
143
153
|
end
|
144
154
|
|
155
|
+
|
145
156
|
end
|
146
157
|
|
147
158
|
def start_compile
|
@@ -165,6 +176,28 @@ module Nilac
|
|
165
176
|
|
166
177
|
elsif opts[:compile] != nil
|
167
178
|
|
179
|
+
client_optimized = false
|
180
|
+
|
181
|
+
server_optimized = false
|
182
|
+
|
183
|
+
if opts[:compile].include?("--browser") or opts[:compile].include?("--client")
|
184
|
+
|
185
|
+
client_optimized = true
|
186
|
+
|
187
|
+
opts[:compile] = opts[:compile].delete("--browser")
|
188
|
+
|
189
|
+
opts[:compile] = opts[:compile].delete("--client")
|
190
|
+
|
191
|
+
elsif opts[:compile].include?("--server") or opts[:compile].include?("--node")
|
192
|
+
|
193
|
+
server_optimized = true
|
194
|
+
|
195
|
+
opts[:compile] = opts[:compile].delete("--server")
|
196
|
+
|
197
|
+
opts[:compile] = opts[:compile].delete("--node")
|
198
|
+
|
199
|
+
end
|
200
|
+
|
168
201
|
if opts[:compile].length == 1
|
169
202
|
|
170
203
|
input = opts[:compile][0]
|
@@ -173,14 +206,14 @@ module Nilac
|
|
173
206
|
current_directory = Dir.pwd
|
174
207
|
input_file = input
|
175
208
|
file_path = current_directory + "/" + input_file
|
176
|
-
compile(file_path)
|
177
|
-
elsif
|
209
|
+
compile(file_path,[client_optimized,server_optimized])
|
210
|
+
elsif File.directory?(input)
|
178
211
|
folder_path = input
|
179
212
|
files = Dir.glob(File.join(folder_path, "*"))
|
180
213
|
files = files.reject { |path| !path.include? ".nila" }
|
181
214
|
files.each do |file|
|
182
215
|
file_path = Dir.pwd + "/" + file
|
183
|
-
compile(file_path)
|
216
|
+
compile(file_path,[client_optimized,server_optimized])
|
184
217
|
end
|
185
218
|
end
|
186
219
|
|
@@ -195,7 +228,7 @@ module Nilac
|
|
195
228
|
output_file = output
|
196
229
|
input_file_path = input_file
|
197
230
|
output_file_path = output_file
|
198
|
-
compile(input_file_path, output_file_path)
|
231
|
+
compile(input_file_path, [client_optimized,server_optimized],output_file_path)
|
199
232
|
|
200
233
|
elsif File.directory?(input)
|
201
234
|
|
@@ -212,7 +245,7 @@ module Nilac
|
|
212
245
|
files.each do |file|
|
213
246
|
input_file_path = file
|
214
247
|
output_file_path = output_folder_path + "/" + find_file_name(file, ".nila") + ".js"
|
215
|
-
compile(input_file_path,
|
248
|
+
compile(input_file_path,[client_optimized,server_optimized],output_file_path)
|
216
249
|
end
|
217
250
|
|
218
251
|
end
|
@@ -226,7 +259,7 @@ module Nilac
|
|
226
259
|
puts " nilac -h/--help\n"
|
227
260
|
puts " nilac -v/--version\n"
|
228
261
|
puts " nilac -u/--update => Update Checker\n"
|
229
|
-
puts " nilac [command] [file_options]\n\n"
|
262
|
+
puts " nilac [command] [sub_commands] [file_options]\n\n"
|
230
263
|
puts " Available Commands:\n\n"
|
231
264
|
puts " nilac -c [nila_file] => Compile Nila File\n\n"
|
232
265
|
puts " nilac -c [nila_file] [output_js_file] => Compile nila_file and saves it as\n output_js_file\n\n"
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: This feature bring Ruby's case when structure to Nila
|
2
|
+
Scenario: Input file with multiple case when structures
|
3
|
+
Given the input file "blocks.nila"
|
4
|
+
When the ~compiler is run
|
5
|
+
The output file must be "blocks.js"
|
6
|
+
The output file must equal "correct_blocks.js"
|
7
|
+
|
8
|
+
Configurations:
|
9
|
+
|
10
|
+
~compiler => lib/nilac.rb
|
11
|
+
:v $cliusage => ruby :v --test --compile $file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Feature: This feature brings monkey patching/duck punching prototypes to Nila
|
2
|
+
Scenario: Input file with monkey patched prototypes
|
3
|
+
Given the input file "monkey_patch.nila"
|
4
|
+
When the ~compiler is run
|
5
|
+
The output file must be "monkey_patch.js"
|
6
|
+
The output file must equal "correct_monkey_patch.js"
|
7
|
+
|
8
|
+
Configurations:
|
9
|
+
|
10
|
+
~compiler => lib/nilac.rb
|
11
|
+
:v $cliusage => ruby :v --test --compile $file
|
@@ -0,0 +1,18 @@
|
|
1
|
+
read = rl.on 'line', do |line|
|
2
|
+
case line.trim()
|
3
|
+
when 'hello'
|
4
|
+
puts "world!"
|
5
|
+
else
|
6
|
+
puts "Say what? I might have heard #{line.trim()}"
|
7
|
+
end
|
8
|
+
rl.prompt()
|
9
|
+
end
|
10
|
+
|
11
|
+
read.on 'close', do
|
12
|
+
puts "Have a great day!"
|
13
|
+
process.exit(0)
|
14
|
+
end
|
15
|
+
|
16
|
+
process.argv.forEach do |val,index,array|
|
17
|
+
commandline_args << val
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
+
(function() {
|
3
|
+
var read;
|
4
|
+
|
5
|
+
read = rl.on('line',function(line) {
|
6
|
+
switch(line.trim()) {
|
7
|
+
case 'hello':
|
8
|
+
console.log("world!");
|
9
|
+
break;
|
10
|
+
default:
|
11
|
+
console.log("Say what? I might have heard " + (line.trim()));
|
12
|
+
}
|
13
|
+
rl.prompt();
|
14
|
+
});
|
15
|
+
|
16
|
+
read.on('close',function() {
|
17
|
+
console.log("Have a great day!");
|
18
|
+
process.exit(0);
|
19
|
+
});
|
20
|
+
|
21
|
+
process.argv.forEach(function(val,index,array) {
|
22
|
+
commandline_args.push(val);
|
23
|
+
});
|
24
|
+
|
25
|
+
}).call(this);
|
@@ -0,0 +1,24 @@
|
|
1
|
+
//Written using Nila. Visit http://adhithyan15.github.io/nila
|
2
|
+
(function() {
|
3
|
+
var avg, nums, sum;
|
4
|
+
|
5
|
+
Array.prototype.sum = function() {
|
6
|
+
var val;
|
7
|
+
val = 0;
|
8
|
+
for (i = 0, _j = this.length-1; i <= _j; i += 1) {
|
9
|
+
val += this[i];
|
10
|
+
}
|
11
|
+
return val;
|
12
|
+
};
|
13
|
+
|
14
|
+
Array.prototype.avg = function() {
|
15
|
+
return this.sum()/this.length;
|
16
|
+
};
|
17
|
+
|
18
|
+
nums = [1,2,3,4,5];
|
19
|
+
|
20
|
+
console.log(nums.sum());
|
21
|
+
|
22
|
+
console.log(nums.avg());
|
23
|
+
|
24
|
+
}).call(this);
|
@@ -9,11 +9,11 @@
|
|
9
9
|
_ref1 = input_name.split(" ");
|
10
10
|
first_name = _ref1[0];
|
11
11
|
last_name = _ref1[1];
|
12
|
-
return [first_name,last_name];
|
12
|
+
return [first_name, last_name];
|
13
13
|
};
|
14
14
|
|
15
15
|
test_method = function() {
|
16
|
-
return console.log("Hello
|
16
|
+
return console.log("Hello World!");
|
17
17
|
};
|
18
18
|
|
19
19
|
parsed_name = parse_name("Adhithya Rajasekaran");
|
@@ -12,7 +12,7 @@
|
|
12
12
|
b = arguments[1];
|
13
13
|
c = [];
|
14
14
|
for (var i=2;i<arguments.length;i++) {
|
15
|
-
c.push(arguments[i]);
|
15
|
+
c.push(arguments[i]);
|
16
16
|
}
|
17
17
|
console.log("I require two or more arguments!");
|
18
18
|
console.log("And sure enough, I got: ");
|
@@ -46,7 +46,7 @@
|
|
46
46
|
f = arguments[arguments.length-1];
|
47
47
|
d = [];
|
48
48
|
for (var i=3;i < arguments.length-2;i++) {
|
49
|
-
d.push(arguments[i]);
|
49
|
+
d.push(arguments[i]);
|
50
50
|
}
|
51
51
|
console.log("Arguments:");
|
52
52
|
console.log(a);
|
@@ -67,7 +67,7 @@
|
|
67
67
|
e = arguments[arguments.length-1];
|
68
68
|
c = [];
|
69
69
|
for (var i=2;i < arguments.length-2;i++) {
|
70
|
-
c.push(arguments[i]);
|
70
|
+
c.push(arguments[i]);
|
71
71
|
}
|
72
72
|
if (b == null) {
|
73
73
|
b=1;
|
@@ -1,8 +1,16 @@
|
|
1
1
|
square = -> {|num| num*num }
|
2
2
|
|
3
|
+
cube = -> {|num| num*square(num)}
|
4
|
+
|
3
5
|
l = lambda do |a, b|
|
4
6
|
tmp = a * 7
|
5
7
|
tmp * b / 50
|
6
8
|
end
|
9
|
+
|
10
|
+
hello = -> {puts "Hello World"}
|
11
|
+
|
12
|
+
hello_world = -> {|| puts "Hello World!"}
|
13
|
+
|
14
|
+
fill = -> {|container, liquid = "coffee"| "Filling the #{container} with #{liquid}" }
|
7
15
|
|
8
|
-
puts square 5
|
16
|
+
puts cube square 5
|
@@ -1,17 +1,17 @@
|
|
1
1
|
# This method demonstrates multiple return values
|
2
2
|
|
3
3
|
def parse_name(input_name)
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
|
5
|
+
first_name, last_name = input_name.split
|
6
|
+
|
7
|
+
return first_name, last_name
|
8
|
+
|
9
9
|
end
|
10
10
|
|
11
|
-
def test_method
|
12
|
-
|
13
|
-
puts "Hello, Adhithya"
|
11
|
+
def test_method
|
14
12
|
|
13
|
+
puts "Hello World!"
|
14
|
+
|
15
15
|
end
|
16
16
|
|
17
17
|
parsed_name = parse_name("Adhithya Rajasekaran")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nilac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.4.3.9.
|
4
|
+
version: 0.0.4.3.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adhithya Rajasekaran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shark
|
@@ -34,15 +34,15 @@ extra_rdoc_files: []
|
|
34
34
|
files:
|
35
35
|
- .gitignore
|
36
36
|
- Gemfile
|
37
|
-
- LICENSE
|
38
37
|
- README.md
|
39
38
|
- Rakefile
|
40
39
|
- bin/nilac
|
41
|
-
- examples/countdown.nila
|
42
40
|
- examples/decBin.js
|
43
41
|
- examples/decBin.nila
|
44
42
|
- examples/marky.js
|
45
43
|
- examples/marky.nila
|
44
|
+
- examples/repl.js
|
45
|
+
- examples/repl.nila
|
46
46
|
- lib/nilac.rb
|
47
47
|
- lib/nilac/ErrorDeclarations.rb
|
48
48
|
- lib/nilac/add_auto_return_statement.rb
|
@@ -50,7 +50,6 @@ files:
|
|
50
50
|
- lib/nilac/compile_arrays.rb
|
51
51
|
- lib/nilac/compile_blocks.rb
|
52
52
|
- lib/nilac/compile_case_statement.rb
|
53
|
-
- lib/nilac/compile_classes.rb
|
54
53
|
- lib/nilac/compile_comments.rb
|
55
54
|
- lib/nilac/compile_conditional_structures.rb
|
56
55
|
- lib/nilac/compile_custom_function_map.rb
|
@@ -62,6 +61,7 @@ files:
|
|
62
61
|
- lib/nilac/compile_interpolated_strings.rb
|
63
62
|
- lib/nilac/compile_lambdas.rb
|
64
63
|
- lib/nilac/compile_loops.rb
|
64
|
+
- lib/nilac/compile_monkey_patching.rb
|
65
65
|
- lib/nilac/compile_multiple_return.rb
|
66
66
|
- lib/nilac/compile_named_functions.rb
|
67
67
|
- lib/nilac/compile_operators.rb
|
@@ -76,9 +76,11 @@ files:
|
|
76
76
|
- lib/nilac/find_all_matching_indices.rb
|
77
77
|
- lib/nilac/find_file_name.rb
|
78
78
|
- lib/nilac/find_file_path.rb
|
79
|
+
- lib/nilac/friendly_errors.rb
|
79
80
|
- lib/nilac/get_variables.rb
|
80
81
|
- lib/nilac/lexical_scoped_function_variables.rb
|
81
82
|
- lib/nilac/output_javascript.rb
|
83
|
+
- lib/nilac/paranthesis_compactor.rb
|
82
84
|
- lib/nilac/parse_arguments.rb
|
83
85
|
- lib/nilac/pretty_print_javascript.rb
|
84
86
|
- lib/nilac/read_file_line_by_line.rb
|
@@ -96,6 +98,7 @@ files:
|
|
96
98
|
- shark/features/array_and_string_indexing.feature
|
97
99
|
- shark/features/automatic_require_statements.feature
|
98
100
|
- shark/features/barebones_compilation.feature
|
101
|
+
- shark/features/blocks.feature
|
99
102
|
- shark/features/case_when.feature
|
100
103
|
- shark/features/default_method_parameters.feature
|
101
104
|
- shark/features/fix_newlines.feature
|
@@ -105,6 +108,7 @@ files:
|
|
105
108
|
- shark/features/javascript_methods.feature
|
106
109
|
- shark/features/loop.feature
|
107
110
|
- shark/features/method_multiple_return.feature
|
111
|
+
- shark/features/monkey_patch.feature
|
108
112
|
- shark/features/multiline_array.feature
|
109
113
|
- shark/features/multiple_variable_initialization.feature
|
110
114
|
- shark/features/numbers.feature
|
@@ -120,11 +124,11 @@ files:
|
|
120
124
|
- shark/features/unless_until.feature
|
121
125
|
- shark/features/whitespace_delimitation.feature
|
122
126
|
- shark/test_files/array_string_indexing.nila
|
123
|
-
- shark/test_files/
|
127
|
+
- shark/test_files/blocks.nila
|
124
128
|
- shark/test_files/case.nila
|
125
|
-
- shark/test_files/class.nila
|
126
129
|
- shark/test_files/conditional_assignment.nila
|
127
130
|
- shark/test_files/correct.js
|
131
|
+
- shark/test_files/correct_blocks.js
|
128
132
|
- shark/test_files/correct_case.js
|
129
133
|
- shark/test_files/correct_conditional_assignment.js
|
130
134
|
- shark/test_files/correct_default_parameters.js
|
@@ -136,6 +140,7 @@ files:
|
|
136
140
|
- shark/test_files/correct_initialization.js
|
137
141
|
- shark/test_files/correct_javascript_methods.js
|
138
142
|
- shark/test_files/correct_loop.js
|
143
|
+
- shark/test_files/correct_monkey_patch.js
|
139
144
|
- shark/test_files/correct_multiline_array.js
|
140
145
|
- shark/test_files/correct_multiple_return.js
|
141
146
|
- shark/test_files/correct_numbers.js
|
@@ -160,6 +165,7 @@ files:
|
|
160
165
|
- shark/test_files/javascript_methods.nila
|
161
166
|
- shark/test_files/lambda.nila
|
162
167
|
- shark/test_files/loop.nila
|
168
|
+
- shark/test_files/monkey_patch.nila
|
163
169
|
- shark/test_files/multiline_array.nila
|
164
170
|
- shark/test_files/multiple_initialization.nila
|
165
171
|
- shark/test_files/multiple_return.nila
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2012-2013 Adhithya Rajasekaran, Sri Madhavi Rajasekaran
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
-
this software and associated documentation files (the "Software"), to deal in
|
7
|
-
the Software without restriction, including without limitation the rights to
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
-
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
-
subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/examples/countdown.nila
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
def countdown(minutes)
|
2
|
-
|
3
|
-
seconds = 60
|
4
|
-
|
5
|
-
mins = minutes
|
6
|
-
|
7
|
-
def tick
|
8
|
-
|
9
|
-
counter = document.getElementById("counter")
|
10
|
-
|
11
|
-
current_minutes = mins-1
|
12
|
-
|
13
|
-
seconds--
|
14
|
-
|
15
|
-
counter.innerHTML = "#{current_minutes.to_s}:#{if seconds < 10 then "0" else ""}#{String(seconds)}"
|
16
|
-
|
17
|
-
if seconds > 0
|
18
|
-
|
19
|
-
setTimeout(tick,1000)
|
20
|
-
|
21
|
-
else
|
22
|
-
|
23
|
-
countdown(mins - 1) if mins > 1
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
tick()
|
30
|
-
|
31
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
def compile_classes(input_file_contents)
|
2
|
-
|
3
|
-
# Nila will have support for classes. But the current implementation is not ready for prime time
|
4
|
-
# yet. So it won't be documented.
|
5
|
-
|
6
|
-
def extract_classes(file_contents)
|
7
|
-
|
8
|
-
# This method will extract code blocks between class .. end blocks and try to convert to
|
9
|
-
# Javascript equivalent code
|
10
|
-
|
11
|
-
possible_classes = file_contents.reject {|element| !element.index(/class\s*\w{1,}\s*<?\s?\w{1,}?/)}
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
16
|
-
|
17
|
-
extract_classes(input_file_contents)
|
18
|
-
|
19
|
-
end
|