jeka 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +55 -2
- data/README.rdoc +6 -14
- data/VERSION +1 -1
- data/bin/jeka +64 -94
- data/jeka.gemspec +56 -28
- data/lib/jeka.rb +6 -4
- data/lib/jeka/algorithm.rb +106 -24
- data/lib/jeka/analysis.rb +15 -0
- data/lib/jeka/analysis/algorithm.rb +13 -0
- data/lib/jeka/analysis/compiler.rb +14 -0
- data/lib/jeka/analysis/compiler_option.rb +24 -0
- data/lib/jeka/analysis/database.rb +11 -0
- data/lib/jeka/analysis/implementation.rb +15 -0
- data/lib/jeka/analysis/implementation_information.rb +24 -0
- data/lib/jeka/analysis/result.rb +20 -0
- data/lib/jeka/analysis/source_file.rb +24 -0
- data/lib/jeka/analysis/test.rb +15 -0
- data/lib/jeka/analysis/test_case.rb +13 -0
- data/lib/jeka/compilers.rb +3 -0
- data/lib/jeka/compilers/compiler.rb +48 -0
- data/lib/jeka/compilers/gpp.rb +29 -0
- data/lib/jeka/compilers/ruby.rb +21 -0
- data/lib/jeka/console.rb +55 -0
- data/lib/jeka/implementation.rb +22 -97
- data/lib/jeka/test.rb +15 -31
- data/lib/jeka/test_case.rb +41 -0
- data/test/bubble_sort/_tests/_test_01.rb +13 -0
- data/test/bubble_sort/algorithm_bubble_sort.rb +15 -0
- data/test/bubble_sort/cpp/_implementation.yaml +3 -0
- data/test/{example/01_bubble_sort/cpp/bubble.cpp → bubble_sort/cpp/bubble_sort.cpp} +9 -10
- data/test/bubble_sort/ruby/_implementation.yaml +3 -0
- data/test/{example/01_bubble_sort/ruby/bubble.rb → bubble_sort/ruby/bubble_sort.rb} +2 -5
- data/test/double/_tests/_test_01.rb +13 -0
- data/test/double/algorithm_double.rb +15 -0
- data/test/double/cpp/double.cpp +10 -0
- data/test/double/ruby/double.rb +2 -0
- data/test/test_algorithm.rb +25 -11
- data/test/test_gpp.rb +29 -0
- data/test/test_implementation.rb +25 -10
- data/test/test_test_case.rb +21 -0
- metadata +94 -52
- data/lib/jeka/jeka_helper.rb +0 -16
- data/lib/jeka/make.rb +0 -103
- data/test/example/01_bubble_sort/_algorithm.yaml +0 -12
- data/test/example/01_bubble_sort/_description.textile +0 -1
- data/test/example/01_bubble_sort/_references.textile +0 -1
- data/test/example/01_bubble_sort/_tests/test_01.yaml +0 -3
- data/test/example/01_bubble_sort/_tests/test_02.yaml +0 -3
- data/test/example/01_bubble_sort/cpp/_implementation.yaml +0 -9
- data/test/example/01_bubble_sort/ruby/_implementation.yaml +0 -6
- data/test/site/algorithm.textile +0 -27
- data/test/site/cpp.textile +0 -46
- data/test/site/ruby.textile +0 -28
- data/test/test_make.rb +0 -34
- data/test/test_test.rb +0 -16
data/test/test_algorithm.rb
CHANGED
@@ -1,20 +1,34 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'bubble_sort/algorithm_bubble_sort'
|
2
3
|
|
3
4
|
class TestAlgorithm < Test::Unit::TestCase
|
4
5
|
|
5
|
-
context "
|
6
|
+
context "AlgorithmBubbleSort" do
|
6
7
|
|
7
|
-
should "
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
assert_equal
|
12
|
-
|
13
|
-
assert_equal
|
14
|
-
|
15
|
-
assert_equal
|
8
|
+
should "be a acceptable algorithm" do
|
9
|
+
|
10
|
+
bubble_sort = AlgorithmBubbleSort.new
|
11
|
+
|
12
|
+
assert_equal bubble_sort.test_suites.length, 1
|
13
|
+
|
14
|
+
assert_equal 2, bubble_sort.implementations.length
|
15
|
+
assert bubble_sort.implementations[0]
|
16
|
+
assert_equal 'c++', bubble_sort.implementations[0].name
|
17
|
+
assert_equal 'c++', bubble_sort.implementations[0].information[:language]
|
18
|
+
assert_equal 'Simple implementation in C++', bubble_sort.implementations[0].information[:comment]
|
19
|
+
assert bubble_sort.implementations[0].compiler
|
20
|
+
|
21
|
+
assert_equal 2, bubble_sort.build.length
|
22
|
+
assert_equal 2, bubble_sort.run.length
|
23
|
+
|
16
24
|
end
|
17
25
|
|
18
26
|
end
|
19
27
|
|
20
|
-
|
28
|
+
context "Algorithm class" do
|
29
|
+
should "have only one algorithm" do
|
30
|
+
assert_equal 1, Jeka::Algorithm.algorithms.length
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/test/test_gpp.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestGpp < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "G++ compiler" do
|
6
|
+
|
7
|
+
should "compile and run the Bubble Sort Algorithm" do
|
8
|
+
gpp = Jeka::Compiler::Gpp.new([File.join(File.dirname(__FILE__), 'bubble_sort', 'cpp', 'bubble_sort.cpp')],
|
9
|
+
{:o => 'bubble_sort_cpp'})
|
10
|
+
|
11
|
+
stdout, stderr, process_status, benchmark = gpp.build
|
12
|
+
assert_equal 0, process_status
|
13
|
+
assert_equal [], stdout
|
14
|
+
assert_equal [], stderr
|
15
|
+
|
16
|
+
stdout, stderr, exit_status = gpp.run('9 8 7 6 5 4 3 2 1')
|
17
|
+
assert_equal 0, exit_status
|
18
|
+
assert_equal ["1 2 3 4 5 6 7 8 9"], stdout
|
19
|
+
assert_equal [], stderr
|
20
|
+
assert benchmark.has_key?(:user_cpu_time)
|
21
|
+
assert benchmark.has_key?(:system_cpu_time)
|
22
|
+
assert benchmark.has_key?(:childrens_use_cpu_time)
|
23
|
+
assert benchmark.has_key?(:childrens_system_cpu_time)
|
24
|
+
assert benchmark.has_key?(:elapsed_real_time)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/test/test_implementation.rb
CHANGED
@@ -1,18 +1,33 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
1
|
require 'helper'
|
4
2
|
|
5
3
|
class TestImplementation < Test::Unit::TestCase
|
6
|
-
|
7
|
-
|
4
|
+
context 'C++ implementation' do
|
5
|
+
|
6
|
+
should 'initialize with information in a file' do
|
7
|
+
gpp = Jeka::Compiler::Gpp.new([File.join(File.dirname(__FILE__), 'bubble_sort', 'cpp', 'bubble_sort.cpp')], {:o => 'bubble_sort_cpp'})
|
8
|
+
|
9
|
+
imp = Jeka::Implementation.new('c++')
|
10
|
+
imp.information = File.join(File.dirname(__FILE__), 'bubble_sort', 'cpp', '_implementation.yaml')
|
11
|
+
imp.compiler = gpp
|
12
|
+
|
13
|
+
assert_equal 'c++', imp.name
|
14
|
+
assert_equal 'c++', imp.information[:language]
|
15
|
+
assert_equal 'Simple implementation in C++', imp.information[:comment]
|
16
|
+
assert imp.compiler
|
17
|
+
end
|
8
18
|
|
9
|
-
should
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
19
|
+
should 'initialize with information in a hash' do
|
20
|
+
gpp = Jeka::Compiler::Gpp.new([File.join(File.dirname(__FILE__), 'bubble_sort', 'cpp', 'bubble_sort.cpp')], {:o => 'bubble_sort_cpp'})
|
21
|
+
|
22
|
+
imp = Jeka::Implementation.new('c++')
|
23
|
+
imp.information = {language: 'c++', comment: 'Simple implementation in C++'}
|
24
|
+
imp.compiler = gpp
|
25
|
+
|
26
|
+
assert_equal 'c++', imp.name
|
27
|
+
assert_equal 'c++', imp.information[:language]
|
28
|
+
assert_equal 'Simple implementation in C++', imp.information[:comment]
|
29
|
+
assert imp.compiler
|
14
30
|
end
|
15
31
|
|
16
32
|
end
|
17
|
-
|
18
33
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'bubble_sort/_tests/_test_01'
|
3
|
+
|
4
|
+
class TestTestCase < Test::Unit::TestCase
|
5
|
+
|
6
|
+
context "TestAlgorithmBubbleSort" do
|
7
|
+
|
8
|
+
should "be a acceptable test case" do
|
9
|
+
t = TestAlgorithmBubbleSort.new
|
10
|
+
assert_equal 'Decreasing Sequence', t.send('test_Decreasing Sequence').name
|
11
|
+
assert_equal '9 8 7 6 5 4 3 2 1', t.send('test_Decreasing Sequence').input
|
12
|
+
assert_equal '1 2 3 4 5 6 7 8 9', t.send('test_Decreasing Sequence').output
|
13
|
+
|
14
|
+
assert_equal 'Random Sequence', t.send('test_Random Sequence').name
|
15
|
+
assert_equal '3 1 5 7 6 8 9 4 2', t.send('test_Random Sequence').input
|
16
|
+
assert_equal '1 2 3 4 5 6 7 8 9', t.send('test_Random Sequence').output
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jeka
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
version: 0.1.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Igor Bonadio
|
@@ -14,65 +10,96 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
18
|
-
default_executable: jeka
|
13
|
+
date: 2011-09-18 00:00:00 Z
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
16
|
+
name: dm-sqlite-adapter
|
22
17
|
requirement: &id001 !ruby/object:Gem::Requirement
|
23
18
|
none: false
|
24
19
|
requirements:
|
25
20
|
- - ">="
|
26
21
|
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
22
|
version: "0"
|
30
|
-
type: :
|
23
|
+
type: :runtime
|
31
24
|
prerelease: false
|
32
25
|
version_requirements: *id001
|
33
26
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
27
|
+
name: data_mapper
|
35
28
|
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: shoulda
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: bundler
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
36
51
|
none: false
|
37
52
|
requirements:
|
38
53
|
- - ~>
|
39
54
|
- !ruby/object:Gem::Version
|
40
|
-
segments:
|
41
|
-
- 1
|
42
|
-
- 0
|
43
|
-
- 0
|
44
55
|
version: 1.0.0
|
45
56
|
type: :development
|
46
57
|
prerelease: false
|
47
|
-
version_requirements: *
|
58
|
+
version_requirements: *id004
|
48
59
|
- !ruby/object:Gem::Dependency
|
49
60
|
name: jeweler
|
50
|
-
requirement: &
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
51
62
|
none: false
|
52
63
|
requirements:
|
53
64
|
- - ~>
|
54
65
|
- !ruby/object:Gem::Version
|
55
|
-
segments:
|
56
|
-
- 1
|
57
|
-
- 5
|
58
|
-
- 2
|
59
66
|
version: 1.5.2
|
60
67
|
type: :development
|
61
68
|
prerelease: false
|
62
|
-
version_requirements: *
|
69
|
+
version_requirements: *id005
|
63
70
|
- !ruby/object:Gem::Dependency
|
64
71
|
name: rcov
|
65
|
-
requirement: &
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
66
73
|
none: false
|
67
74
|
requirements:
|
68
75
|
- - ">="
|
69
76
|
- !ruby/object:Gem::Version
|
70
|
-
segments:
|
71
|
-
- 0
|
72
77
|
version: "0"
|
73
78
|
type: :development
|
74
79
|
prerelease: false
|
75
|
-
version_requirements: *
|
80
|
+
version_requirements: *id006
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: dm-sqlite-adapter
|
83
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: "0"
|
89
|
+
type: :development
|
90
|
+
prerelease: false
|
91
|
+
version_requirements: *id007
|
92
|
+
- !ruby/object:Gem::Dependency
|
93
|
+
name: data_mapper
|
94
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: "0"
|
100
|
+
type: :development
|
101
|
+
prerelease: false
|
102
|
+
version_requirements: *id008
|
76
103
|
description: Jeka is an awesome build/test/benchmarking tool
|
77
104
|
email: igorbonadio@gmail.com
|
78
105
|
executables:
|
@@ -94,28 +121,40 @@ files:
|
|
94
121
|
- jeka.gemspec
|
95
122
|
- lib/jeka.rb
|
96
123
|
- lib/jeka/algorithm.rb
|
124
|
+
- lib/jeka/analysis.rb
|
125
|
+
- lib/jeka/analysis/algorithm.rb
|
126
|
+
- lib/jeka/analysis/compiler.rb
|
127
|
+
- lib/jeka/analysis/compiler_option.rb
|
128
|
+
- lib/jeka/analysis/database.rb
|
129
|
+
- lib/jeka/analysis/implementation.rb
|
130
|
+
- lib/jeka/analysis/implementation_information.rb
|
131
|
+
- lib/jeka/analysis/result.rb
|
132
|
+
- lib/jeka/analysis/source_file.rb
|
133
|
+
- lib/jeka/analysis/test.rb
|
134
|
+
- lib/jeka/analysis/test_case.rb
|
135
|
+
- lib/jeka/compilers.rb
|
136
|
+
- lib/jeka/compilers/compiler.rb
|
137
|
+
- lib/jeka/compilers/gpp.rb
|
138
|
+
- lib/jeka/compilers/ruby.rb
|
139
|
+
- lib/jeka/console.rb
|
97
140
|
- lib/jeka/implementation.rb
|
98
|
-
- lib/jeka/jeka_helper.rb
|
99
|
-
- lib/jeka/make.rb
|
100
141
|
- lib/jeka/test.rb
|
101
|
-
-
|
102
|
-
- test/
|
103
|
-
- test/
|
104
|
-
- test/
|
105
|
-
- test/
|
106
|
-
- test/
|
107
|
-
- test/
|
108
|
-
- test/
|
109
|
-
- test/
|
142
|
+
- lib/jeka/test_case.rb
|
143
|
+
- test/bubble_sort/_tests/_test_01.rb
|
144
|
+
- test/bubble_sort/algorithm_bubble_sort.rb
|
145
|
+
- test/bubble_sort/cpp/_implementation.yaml
|
146
|
+
- test/bubble_sort/cpp/bubble_sort.cpp
|
147
|
+
- test/bubble_sort/ruby/_implementation.yaml
|
148
|
+
- test/bubble_sort/ruby/bubble_sort.rb
|
149
|
+
- test/double/_tests/_test_01.rb
|
150
|
+
- test/double/algorithm_double.rb
|
151
|
+
- test/double/cpp/double.cpp
|
152
|
+
- test/double/ruby/double.rb
|
110
153
|
- test/helper.rb
|
111
|
-
- test/site/algorithm.textile
|
112
|
-
- test/site/cpp.textile
|
113
|
-
- test/site/ruby.textile
|
114
154
|
- test/test_algorithm.rb
|
155
|
+
- test/test_gpp.rb
|
115
156
|
- test/test_implementation.rb
|
116
|
-
- test/
|
117
|
-
- test/test_test.rb
|
118
|
-
has_rdoc: true
|
157
|
+
- test/test_test_case.rb
|
119
158
|
homepage: http://github.com/igorbonadio/jeka
|
120
159
|
licenses:
|
121
160
|
- MIT
|
@@ -129,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
129
168
|
requirements:
|
130
169
|
- - ">="
|
131
170
|
- !ruby/object:Gem::Version
|
132
|
-
hash: -
|
171
|
+
hash: -3026672053806941219
|
133
172
|
segments:
|
134
173
|
- 0
|
135
174
|
version: "0"
|
@@ -138,20 +177,23 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
177
|
requirements:
|
139
178
|
- - ">="
|
140
179
|
- !ruby/object:Gem::Version
|
141
|
-
segments:
|
142
|
-
- 0
|
143
180
|
version: "0"
|
144
181
|
requirements: []
|
145
182
|
|
146
183
|
rubyforge_project:
|
147
|
-
rubygems_version: 1.
|
184
|
+
rubygems_version: 1.8.9
|
148
185
|
signing_key:
|
149
186
|
specification_version: 3
|
150
187
|
summary: Jeka is an awesome build/test/benchmarking tool
|
151
188
|
test_files:
|
152
|
-
- test/
|
189
|
+
- test/bubble_sort/_tests/_test_01.rb
|
190
|
+
- test/bubble_sort/algorithm_bubble_sort.rb
|
191
|
+
- test/bubble_sort/ruby/bubble_sort.rb
|
192
|
+
- test/double/_tests/_test_01.rb
|
193
|
+
- test/double/algorithm_double.rb
|
194
|
+
- test/double/ruby/double.rb
|
153
195
|
- test/helper.rb
|
154
196
|
- test/test_algorithm.rb
|
197
|
+
- test/test_gpp.rb
|
155
198
|
- test/test_implementation.rb
|
156
|
-
- test/
|
157
|
-
- test/test_test.rb
|
199
|
+
- test/test_test_case.rb
|
data/lib/jeka/jeka_helper.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
module Jeka
|
2
|
-
class JekaHelper
|
3
|
-
|
4
|
-
def initialize(path)
|
5
|
-
@folder = "#{File.dirname(path)}/"
|
6
|
-
@jeka = YAML::load(File.open(path))
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.jeka_reader(name)
|
10
|
-
define_method(name) do
|
11
|
-
return @jeka[name.to_s] unless @jeka[name.to_s].kind_of? Hash
|
12
|
-
return File.open(File.join(@folder, @jeka[name.to_s]["file"])).readlines.join("")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
data/lib/jeka/make.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
require 'benchmark'
|
5
|
-
require 'uri'
|
6
|
-
|
7
|
-
module Jeka
|
8
|
-
|
9
|
-
class Make
|
10
|
-
|
11
|
-
def initialize(folder)
|
12
|
-
@algorithm = Algorithm.new(folder)
|
13
|
-
end
|
14
|
-
|
15
|
-
def build
|
16
|
-
@algorithm.implementations.each do |i|
|
17
|
-
i.build
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def test
|
22
|
-
@algorithm.implementations.each do |i|
|
23
|
-
@algorithm.tests.each do |t|
|
24
|
-
out = i.run(t.generate, false)
|
25
|
-
yield i, t, out == "#{t.output}\n"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def benchmark(n)
|
31
|
-
@algorithm.implementations.each do |i|
|
32
|
-
@algorithm.tests.each do |t|
|
33
|
-
i.benchmark(t.generate, n)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def generate_site
|
39
|
-
bench = []
|
40
|
-
@algorithm.implementations.each do |i|
|
41
|
-
bench << i.benchmark_results
|
42
|
-
end
|
43
|
-
bench = _sort_bench(bench)
|
44
|
-
_generete_site(bench)
|
45
|
-
end
|
46
|
-
|
47
|
-
def _generete_site(bench)
|
48
|
-
implementations = []
|
49
|
-
page = "---\n"
|
50
|
-
page += "layout: algorithm\n"
|
51
|
-
page += "title: #{@algorithm.name}\n"
|
52
|
-
page += "---\n\n"
|
53
|
-
page += "h1. #{@algorithm.name}\n\n"
|
54
|
-
page += "h2. #{@algorithm.type}\n\n"
|
55
|
-
page += "h3. Descrição\n\n"
|
56
|
-
page += "#{@algorithm.description}\n\n"
|
57
|
-
page += "h3. Complexidade\n\n"
|
58
|
-
page += "#{@algorithm.complexity}\n\n"
|
59
|
-
page += "h3. Referências\n\n"
|
60
|
-
page += "#{@algorithm.references}\n\n"
|
61
|
-
page += "h3. Implementações\n\n"
|
62
|
-
page += "|_. Linguagem |_. Comentário |_. Código fonte |_. Tempo de execução médio |\n"
|
63
|
-
bench.each do |b|
|
64
|
-
page += "| #{b[:language]} | #{b[:comment]} | \"ver\":#{
|
65
|
-
URI.escape("../../../../implementations/2011/01/01/#{b[:comment].gsub(" ", "_")
|
66
|
-
}.html")} | #{b[:elapsed_real_time]}s |\n"
|
67
|
-
end
|
68
|
-
page += "\n"
|
69
|
-
|
70
|
-
@algorithm.implementations.each do |i|
|
71
|
-
implementations << [i, _generate_source_page(i.source_code, "ruby")]
|
72
|
-
end
|
73
|
-
|
74
|
-
return [@algorithm, page], implementations
|
75
|
-
end
|
76
|
-
|
77
|
-
def _generate_source_page(src, lang)
|
78
|
-
page = "---\n"
|
79
|
-
page += "layout: implementation\n"
|
80
|
-
page += "title: Bubble Sort\n"
|
81
|
-
page += "---\n\n"
|
82
|
-
page += "{% highlight #{lang} %}\n"
|
83
|
-
page += src
|
84
|
-
page += "{% endhighlight %}\n"
|
85
|
-
return page
|
86
|
-
end
|
87
|
-
|
88
|
-
def _sort_bench(bench)
|
89
|
-
for i in 0..(bench.size-1) do
|
90
|
-
for j in (i+1)..(bench.size-1) do
|
91
|
-
if bench[i][:elapsed_real_time] > bench[j][:elapsed_real_time]
|
92
|
-
temp = bench[i]
|
93
|
-
bench[i] = bench[j]
|
94
|
-
bench[j] = temp
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
return bench
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|