jeka 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/Gemfile +4 -0
  2. data/Gemfile.lock +55 -2
  3. data/README.rdoc +6 -14
  4. data/VERSION +1 -1
  5. data/bin/jeka +64 -94
  6. data/jeka.gemspec +56 -28
  7. data/lib/jeka.rb +6 -4
  8. data/lib/jeka/algorithm.rb +106 -24
  9. data/lib/jeka/analysis.rb +15 -0
  10. data/lib/jeka/analysis/algorithm.rb +13 -0
  11. data/lib/jeka/analysis/compiler.rb +14 -0
  12. data/lib/jeka/analysis/compiler_option.rb +24 -0
  13. data/lib/jeka/analysis/database.rb +11 -0
  14. data/lib/jeka/analysis/implementation.rb +15 -0
  15. data/lib/jeka/analysis/implementation_information.rb +24 -0
  16. data/lib/jeka/analysis/result.rb +20 -0
  17. data/lib/jeka/analysis/source_file.rb +24 -0
  18. data/lib/jeka/analysis/test.rb +15 -0
  19. data/lib/jeka/analysis/test_case.rb +13 -0
  20. data/lib/jeka/compilers.rb +3 -0
  21. data/lib/jeka/compilers/compiler.rb +48 -0
  22. data/lib/jeka/compilers/gpp.rb +29 -0
  23. data/lib/jeka/compilers/ruby.rb +21 -0
  24. data/lib/jeka/console.rb +55 -0
  25. data/lib/jeka/implementation.rb +22 -97
  26. data/lib/jeka/test.rb +15 -31
  27. data/lib/jeka/test_case.rb +41 -0
  28. data/test/bubble_sort/_tests/_test_01.rb +13 -0
  29. data/test/bubble_sort/algorithm_bubble_sort.rb +15 -0
  30. data/test/bubble_sort/cpp/_implementation.yaml +3 -0
  31. data/test/{example/01_bubble_sort/cpp/bubble.cpp → bubble_sort/cpp/bubble_sort.cpp} +9 -10
  32. data/test/bubble_sort/ruby/_implementation.yaml +3 -0
  33. data/test/{example/01_bubble_sort/ruby/bubble.rb → bubble_sort/ruby/bubble_sort.rb} +2 -5
  34. data/test/double/_tests/_test_01.rb +13 -0
  35. data/test/double/algorithm_double.rb +15 -0
  36. data/test/double/cpp/double.cpp +10 -0
  37. data/test/double/ruby/double.rb +2 -0
  38. data/test/test_algorithm.rb +25 -11
  39. data/test/test_gpp.rb +29 -0
  40. data/test/test_implementation.rb +25 -10
  41. data/test/test_test_case.rb +21 -0
  42. metadata +94 -52
  43. data/lib/jeka/jeka_helper.rb +0 -16
  44. data/lib/jeka/make.rb +0 -103
  45. data/test/example/01_bubble_sort/_algorithm.yaml +0 -12
  46. data/test/example/01_bubble_sort/_description.textile +0 -1
  47. data/test/example/01_bubble_sort/_references.textile +0 -1
  48. data/test/example/01_bubble_sort/_tests/test_01.yaml +0 -3
  49. data/test/example/01_bubble_sort/_tests/test_02.yaml +0 -3
  50. data/test/example/01_bubble_sort/cpp/_implementation.yaml +0 -9
  51. data/test/example/01_bubble_sort/ruby/_implementation.yaml +0 -6
  52. data/test/site/algorithm.textile +0 -27
  53. data/test/site/cpp.textile +0 -46
  54. data/test/site/ruby.textile +0 -28
  55. data/test/test_make.rb +0 -34
  56. data/test/test_test.rb +0 -16
@@ -1,12 +0,0 @@
1
- name: Bubble Sort
2
- type: Sorting
3
- description: {
4
- file: _description.textile
5
- }
6
- references: {
7
- file: _references.textile
8
- }
9
- complexity: O(n^2)
10
- implementations:
11
- - ruby
12
- - cpp
@@ -1 +0,0 @@
1
- Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. The equally simple insertion sort has better performance than bubble sort, so some have suggested no longer teaching the bubble sort.
@@ -1 +0,0 @@
1
- http://en.wikipedia.org/wiki/Bubble_sort
@@ -1,3 +0,0 @@
1
- name: Sequencia decrescente
2
- input: 9 9 8 7 6 5 4 3 2 1
3
- output: 1 2 3 4 5 6 7 8 9
@@ -1,3 +0,0 @@
1
- name: Sequencia aleatoria
2
- input: 9 8 9 1 3 4 7 6 2 5
3
- output: 1 2 3 4 5 6 7 8 9
@@ -1,9 +0,0 @@
1
- language: c++
2
- source: bubble.cpp
3
- comment: Implementação simples em C++
4
- build: {
5
- command: g++ -o $bubble $bubble.cpp
6
- }
7
- run: {
8
- command: ./$bubble
9
- }
@@ -1,6 +0,0 @@
1
- language: ruby
2
- source: bubble.rb
3
- comment: Implementação simples em Ruby
4
- run: {
5
- command: ruby $bubble.rb
6
- }
@@ -1,27 +0,0 @@
1
- ---
2
- layout: algorithm
3
- title: Bubble Sort
4
- ---
5
-
6
- h1. Bubble Sort
7
-
8
- h2. Sorting
9
-
10
- h3. Descrição
11
-
12
- Bubble sort, also known as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wrong order. The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. The algorithm gets its name from the way smaller elements "bubble" to the top of the list. Because it only uses comparisons to operate on elements, it is a comparison sort. The equally simple insertion sort has better performance than bubble sort, so some have suggested no longer teaching the bubble sort.
13
-
14
- h3. Complexidade
15
-
16
- O(n^2)
17
-
18
- h3. Referências
19
-
20
- http://en.wikipedia.org/wiki/Bubble_sort
21
-
22
- h3. Implementações
23
-
24
- |_. Linguagem |_. Comentário |_. Código fonte |_. Tempo de execução médio |
25
- | c++ | Implementação simples em C++ | "ver":../../../../implementations/2011/01/01/Implementa%C3%A7%C3%A3o_simples_em_C++.html | 0.003s |
26
- | ruby | Implementação simples em Ruby | "ver":../../../../implementations/2011/01/01/Implementa%C3%A7%C3%A3o_simples_em_Ruby.html | 0.006500000000000001s |
27
-
@@ -1,46 +0,0 @@
1
- ---
2
- layout: implementation
3
- title: Bubble Sort
4
- ---
5
-
6
- {% highlight ruby %}
7
- #include <iostream>
8
- #include <vector>
9
- #include <stdlib.h>
10
-
11
- using namespace std;
12
-
13
- vector<int> bubble_sort(vector<int> numbers) {
14
- for(int i = 0; i < 9; i++) {
15
- for(int j = i; j < 9; j++) {
16
- if (numbers[i] > numbers[j]) {
17
- int temp = numbers[i];
18
- numbers[i] = numbers[j];
19
- numbers[j] = temp;
20
- }
21
- }
22
- }
23
- return numbers;
24
- }
25
-
26
- int main() {
27
- vector<int> numbers;
28
- int max, v;
29
-
30
- // Reading the input
31
- cin >> max;
32
- for (int i = 0; i < max; i++) {
33
- cin >> v;
34
- numbers.push_back(v);
35
- }
36
-
37
- numbers = bubble_sort(numbers);
38
-
39
- // Printing the output
40
- for (int i=0; i< 8; i++)
41
- cout << numbers[i] << " ";
42
- cout << numbers[8] << endl;
43
-
44
- return 0;
45
- }
46
- {% endhighlight %}
@@ -1,28 +0,0 @@
1
- ---
2
- layout: implementation
3
- title: Bubble Sort
4
- ---
5
-
6
- {% highlight ruby %}
7
- def bubble(numbers)
8
- for i in (0..numbers.size-1)
9
- for j in (i..numbers.size-1)
10
- if numbers[i] > numbers[j]
11
- temp = numbers[i]
12
- numbers[i] = numbers[j]
13
- numbers[j] = temp
14
- end
15
- end
16
- end
17
- numbers
18
- end
19
-
20
- # Reading the input
21
- input = gets
22
- input = input.split(' ')[1..-1].map {|c| c.to_i }
23
-
24
- bubble(input)
25
-
26
- # Printing the output
27
- puts input.inject {|output, n| "#{output} #{n}"}
28
- {% endhighlight %}
data/test/test_make.rb DELETED
@@ -1,34 +0,0 @@
1
- require 'helper'
2
-
3
- class TestMake < Test::Unit::TestCase
4
-
5
- context "The example" do
6
-
7
- should "pass all the tests" do
8
- make = Jeka::Make.new(File.join(File.dirname(__FILE__), "example", "01_bubble_sort"))
9
- make.build
10
- make.test do |i, t, r|
11
- assert r
12
- end
13
- end
14
-
15
- should "generate the web pages" do
16
- falgorithm = File.new(File.join(File.dirname(__FILE__), "site", "algorithm.textile"), "r")
17
- falgorithm = falgorithm.readlines.join()
18
- falgorithm = falgorithm.gsub(/(\d)*\.(\d)*s/, "*")
19
- fcpp = File.new(File.join(File.dirname(__FILE__), "site", "cpp.textile"), "r")
20
- fcpp = fcpp.readlines.join()
21
- fruby = File.new(File.join(File.dirname(__FILE__), "site", "ruby.textile"), "r")
22
- fruby = fruby.readlines.join()
23
- make = Jeka::Make.new(File.join(File.dirname(__FILE__), "example", "01_bubble_sort"))
24
- make.build
25
- make.benchmark(1)
26
- algorithm, implementations = make.generate_site
27
- assert_equal falgorithm, algorithm[1].gsub(/(\d)*\.(\d)*s/, "*")
28
- assert_equal fruby, implementations[0][1]
29
- assert_equal fcpp, implementations[1][1]
30
- end
31
-
32
- end
33
-
34
- end
data/test/test_test.rb DELETED
@@ -1,16 +0,0 @@
1
- require 'helper'
2
-
3
- class TestTest < Test::Unit::TestCase
4
-
5
- context "The example" do
6
-
7
- should "open the bubble sort tests" do
8
- test = Jeka::Test.new(File.join(File.dirname(__FILE__), "example", "01_bubble_sort", "_tests", "test_01.yaml"))
9
- assert_equal test.name, "Sequencia decrescente"
10
- assert_equal test.input, "9 9 8 7 6 5 4 3 2 1"
11
- assert_equal test.output, "1 2 3 4 5 6 7 8 9"
12
- end
13
-
14
- end
15
-
16
- end