jeka 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,4 +1,4 @@
1
- = Jeka v0.2.0
1
+ = Jeka v0.2.1
2
2
 
3
3
  Jeka is an awesome build/test/benchmarking tool.
4
4
 
@@ -12,7 +12,7 @@ This new version changed a lot! Now, Jeka generates a database containing inform
12
12
 
13
13
  == Creating a Jeka Repository
14
14
 
15
- See an example here[link:https://github.com/igorbonadio/jeka/tree/master/test/bubble_sort]
15
+ See an example here[link:https://github.com/igorbonadio/jeka/tree/master/test/double]
16
16
 
17
17
  == Using
18
18
 
@@ -22,7 +22,14 @@ Building a Jeka repository:
22
22
 
23
23
  Running implementations:
24
24
 
25
- $ jeka run "your_repository_folder/**/algorithm_*.rb" # it will generate a sqlite3 database named 'analysis.jeka'
25
+ $ jeka run -n 5 "your_repository_folder/**/algorithm_*.rb" # it will generate a sqlite3 database named 'analysis.jeka'
26
+
27
+ == Supported Compilers/Interpreters:
28
+
29
+ * GCC
30
+ * G++
31
+ * Python
32
+ * Ruby
26
33
 
27
34
  == For the future
28
35
 
data/TODO ADDED
@@ -0,0 +1,7 @@
1
+ 0.2.2
2
+ - helper para analisadores
3
+ - mais opções na linha de comando (executar/compilar uma implementação dada)
4
+ - mais compiladores
5
+
6
+ 0.2.3
7
+ - melhorar desempenho (memoria - nesse momento os modelos do db estao em memoria)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.2.1
data/bin/jeka CHANGED
@@ -1,87 +1,79 @@
1
1
  #!/usr/bin/env ruby
2
-
3
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
3
  $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+
5
+ require 'optparse'
5
6
  require 'jeka'
6
7
 
7
- def build(files)
8
- Dir.glob(files).each do |d|
9
- require File.join(File.join(Dir.getwd, d))
10
- end
8
+ TOP_MSG = "jeka v#{File.open(File.join(File.dirname(__FILE__), '..', 'VERSION'), "r").readlines.join}"
9
+ puts TOP_MSG
10
+
11
+ options = {}
12
+ run_optparse = OptionParser.new do |opts|
11
13
 
12
- error = false
13
- Jeka::Algorithm.build_all do |p, t, o|
14
- case t
15
- when :step
16
- p = p.to_s
17
- while p.length < 3
18
- p = " " + p
19
- end
20
- puts "[#{p}%] #{o}"
21
- when :output
22
- o = o.join
23
- if o.length > 0
24
- puts o
25
- end
26
- when :error
27
- o = o.join
28
- if o.length > 0
29
- puts o
30
- end
31
- error = true
32
- when :done
33
- if error
34
- puts "[100%] Some error occurs..."
35
- else
36
- puts "[100%] Done!"
37
- end
38
- end
14
+ opts.banner = "Usage: jeka run [options] file ..."
15
+
16
+ options[:n] = 1
17
+ opts.on '-n', '--n-repetitions N', Integer, 'Number of repetions' do |n|
18
+ options[:n] = n
39
19
  end
40
20
  end
41
21
 
42
- def run(files)
43
- Dir.glob(files).each do |d|
44
- require File.join(File.join(Dir.getwd, d))
22
+ build_optparse = OptionParser.new do |opts|
23
+ opts.banner = "Usage: jeka build [options] file ..."
24
+ end
25
+
26
+ def cmd(files, options)
27
+ if not files.length == 1
28
+ puts "ERROR: invalid number of files..."
29
+ return
45
30
  end
46
31
 
47
- error = false
48
- Jeka::Algorithm.run_all do |p, t, o|
49
- case t
50
- when :step
51
- p = p.to_s
52
- while p.length < 3
53
- p = " " + p
54
- end
55
- puts "[#{p}%] #{o}"
56
- when :error
57
- o = o.join
58
- if o.length > 0
59
- puts o
60
- end
61
- error = true
62
- when :done
63
- if error
64
- puts "[100%] Some error occurs..."
65
- else
66
- puts "[100%] Done!"
67
- end
68
- end
32
+ if not Jeka::Console::add_algorithms(files[0])
33
+ puts "ERROR: No such file or directory..."
34
+ return
69
35
  end
36
+
37
+ case options[:command]
38
+ when :build
39
+ build(options)
40
+ when :run
41
+ run(options)
42
+ end
43
+ end
44
+
45
+ def build(options)
46
+ Jeka::Console::build
70
47
  end
71
48
 
72
- def help
73
- puts "usage: jeka [build|run] [regexp|file|dir]"
49
+ def run(options)
50
+ Jeka::Console::run(options[:n])
74
51
  end
75
52
 
76
- if ARGV.length == 2
77
- case ARGV[0]
78
- when "build"
79
- build(ARGV[1])
80
- when "run"
81
- run(ARGV[1])
82
- else
83
- help()
53
+ def help()
54
+ puts "Usage: jeka run|build [options] file..."
55
+ end
56
+
57
+ begin
58
+ if ARGV.length >= 2
59
+ files = []
60
+ case ARGV[0]
61
+ when "build"
62
+ options[:command] = :build
63
+ files = build_optparse.parse!(ARGV[1..-1])
64
+ when "run"
65
+ options[:command] = :run
66
+ files = run_optparse.parse!(ARGV[1..-1])
67
+ else
68
+ help()
69
+ end
70
+ cmd(files, options)
71
+ else
72
+ help()
84
73
  end
85
- else
86
- help()
74
+
75
+ rescue OptionParser::MissingArgument
76
+ puts "ERROR: missing arguments..."
77
+ rescue OptionParser::InvalidOption
78
+ puts "ERROR: invalid arguments..."
87
79
  end
data/jeka.gemspec CHANGED
@@ -4,18 +4,19 @@
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{jeka}
8
- s.version = "0.2.0"
7
+ s.name = "jeka"
8
+ s.version = "0.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = [%q{Igor Bonadio}]
12
- s.date = %q{2011-09-18}
13
- s.description = %q{Jeka is an awesome build/test/benchmarking tool}
14
- s.email = %q{igorbonadio@gmail.com}
15
- s.executables = [%q{jeka}]
11
+ s.authors = ["Igor Bonadio"]
12
+ s.date = "2011-09-29"
13
+ s.description = "Jeka is an awesome build/test/benchmarking tool"
14
+ s.email = "igorbonadio@gmail.com"
15
+ s.executables = ["jeka"]
16
16
  s.extra_rdoc_files = [
17
17
  "LICENSE.txt",
18
- "README.rdoc"
18
+ "README.rdoc",
19
+ "TODO"
19
20
  ]
20
21
  s.files = [
21
22
  ".document",
@@ -42,7 +43,9 @@ Gem::Specification.new do |s|
42
43
  "lib/jeka/analysis/test_case.rb",
43
44
  "lib/jeka/compilers.rb",
44
45
  "lib/jeka/compilers/compiler.rb",
46
+ "lib/jeka/compilers/gcc.rb",
45
47
  "lib/jeka/compilers/gpp.rb",
48
+ "lib/jeka/compilers/python.rb",
46
49
  "lib/jeka/compilers/ruby.rb",
47
50
  "lib/jeka/console.rb",
48
51
  "lib/jeka/implementation.rb",
@@ -56,7 +59,10 @@ Gem::Specification.new do |s|
56
59
  "test/bubble_sort/ruby/bubble_sort.rb",
57
60
  "test/double/_tests/_test_01.rb",
58
61
  "test/double/algorithm_double.rb",
62
+ "test/double/c/double.c",
59
63
  "test/double/cpp/double.cpp",
64
+ "test/double/objc/double.m",
65
+ "test/double/python/double.py",
60
66
  "test/double/ruby/double.rb",
61
67
  "test/helper.rb",
62
68
  "test/test_algorithm.rb",
@@ -64,11 +70,11 @@ Gem::Specification.new do |s|
64
70
  "test/test_implementation.rb",
65
71
  "test/test_test_case.rb"
66
72
  ]
67
- s.homepage = %q{http://github.com/igorbonadio/jeka}
68
- s.licenses = [%q{MIT}]
69
- s.require_paths = [%q{lib}]
70
- s.rubygems_version = %q{1.8.9}
71
- s.summary = %q{Jeka is an awesome build/test/benchmarking tool}
73
+ s.homepage = "http://github.com/igorbonadio/jeka"
74
+ s.licenses = ["MIT"]
75
+ s.require_paths = ["lib"]
76
+ s.rubygems_version = "1.8.10"
77
+ s.summary = "Jeka is an awesome build/test/benchmarking tool"
72
78
  s.test_files = [
73
79
  "test/bubble_sort/_tests/_test_01.rb",
74
80
  "test/bubble_sort/algorithm_bubble_sort.rb",
@@ -1,3 +1,5 @@
1
1
  require File.join(ROOT_PATH, 'jeka/compilers/compiler')
2
2
  require File.join(ROOT_PATH, 'jeka/compilers/gpp')
3
+ require File.join(ROOT_PATH, 'jeka/compilers/gcc')
3
4
  require File.join(ROOT_PATH, 'jeka/compilers/ruby')
5
+ require File.join(ROOT_PATH, 'jeka/compilers/python')
@@ -0,0 +1,29 @@
1
+ module Jeka
2
+ module Compiler
3
+
4
+ class Gcc < Compiler
5
+ def initialize(files, options = {})
6
+ @files = files
7
+ @options = options
8
+ end
9
+
10
+ private
11
+
12
+ def _run_command
13
+ cmd = './' << @options[:o]
14
+ end
15
+
16
+ def _build_command
17
+ cmd = 'gcc '
18
+ @files.each do |f|
19
+ cmd << f << ' '
20
+ end
21
+ @options.each do |opt, value|
22
+ cmd << '-' << opt.to_s << ' ' << value << ' '
23
+ end
24
+ return cmd
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ module Jeka
2
+ module Compiler
3
+
4
+ class Python < Compiler
5
+ def initialize(file, options = {})
6
+ @files = [file]
7
+ @options = options
8
+ end
9
+
10
+ private
11
+
12
+ def _run_command
13
+ "python " << @files[0]
14
+ end
15
+
16
+ def _build_command
17
+ end
18
+
19
+ end
20
+ end
21
+ end
data/lib/jeka/console.rb CHANGED
@@ -3,12 +3,15 @@ module Jeka
3
3
 
4
4
  def self.add_algorithms(dir)
5
5
  Jeka::Algorithm.reset
6
+ ok = false
6
7
  Dir.glob(dir).each do |d|
8
+ ok = true
7
9
  load d
8
10
  end
11
+ ok
9
12
  end
10
13
 
11
- def self.run(n)
14
+ def self.run(n=1)
12
15
  error = false
13
16
  Jeka::Algorithm.run_all(n) do |p, t, o|
14
17
  self._show(p, t, o, false)
@@ -7,9 +7,24 @@ class AlgorithmDouble < Jeka::Algorithm
7
7
  imp.compiler = Jeka::Compiler::Gpp.new([File.join(File.dirname(__FILE__), 'cpp', 'double.cpp')], {:o => 'double_cpp'})
8
8
  end
9
9
 
10
+ implementation 'c' do |imp|
11
+ imp.information = {language: 'c', comment: 'Simple implementation in C'}
12
+ imp.compiler = Jeka::Compiler::Gcc.new([File.join(File.dirname(__FILE__), 'c', 'double.c')], {:o => 'double_c'})
13
+ end
14
+
15
+ implementation 'obj-c' do |imp|
16
+ imp.information = {language: 'objective-c', comment: 'Simple implementation in Objective-C'}
17
+ imp.compiler = Jeka::Compiler::Gcc.new([File.join(File.dirname(__FILE__), 'objc', 'double.m')], {:o => 'double_objc', :ObjC => "", :framework => "Foundation"})
18
+ end
19
+
10
20
  implementation 'ruby' do |imp|
11
21
  imp.information = {language: 'ruby', comment: 'Simple implementation in Ruby'}
12
22
  imp.compiler = Jeka::Compiler::Ruby.new(File.join(File.dirname(__FILE__), 'ruby', 'double.rb'))
13
23
  end
14
24
 
25
+ implementation 'python' do |imp|
26
+ imp.information = {language: 'python', comment: 'Simple implementation in Python'}
27
+ imp.compiler = Jeka::Compiler::Python.new(File.join(File.dirname(__FILE__), 'python', 'double.py'))
28
+ end
29
+
15
30
  end
@@ -0,0 +1,8 @@
1
+ #include <stdio.h>
2
+
3
+ int main() {
4
+ int n;
5
+ scanf("%d", &n);
6
+ printf("%d", 2*n);
7
+ return 0;
8
+ }
@@ -0,0 +1,8 @@
1
+ #include <stdio.h>
2
+
3
+ int main() {
4
+ int n;
5
+ scanf("%d", &n);
6
+ printf("%d", 2*n);
7
+ return 0;
8
+ }
@@ -0,0 +1,4 @@
1
+ import sys
2
+
3
+ x = raw_input()
4
+ sys.stdout.write(str(2*int(x)))
metadata CHANGED
@@ -1,115 +1,114 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: jeka
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
4
5
  prerelease:
5
- version: 0.2.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Igor Bonadio
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-09-18 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-09-29 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: dm-sqlite-adapter
17
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70188295884960 !ruby/object:Gem::Requirement
18
17
  none: false
19
- requirements:
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *70188295884960
25
+ - !ruby/object:Gem::Dependency
27
26
  name: data_mapper
28
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &70188295884480 !ruby/object:Gem::Requirement
29
28
  none: false
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
34
33
  type: :runtime
35
34
  prerelease: false
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *70188295884480
36
+ - !ruby/object:Gem::Dependency
38
37
  name: shoulda
39
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirement: &70188295884000 !ruby/object:Gem::Requirement
40
39
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
45
44
  type: :development
46
45
  prerelease: false
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *70188295884000
47
+ - !ruby/object:Gem::Dependency
49
48
  name: bundler
50
- requirement: &id004 !ruby/object:Gem::Requirement
49
+ requirement: &70188295883520 !ruby/object:Gem::Requirement
51
50
  none: false
52
- requirements:
51
+ requirements:
53
52
  - - ~>
54
- - !ruby/object:Gem::Version
53
+ - !ruby/object:Gem::Version
55
54
  version: 1.0.0
56
55
  type: :development
57
56
  prerelease: false
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *70188295883520
58
+ - !ruby/object:Gem::Dependency
60
59
  name: jeweler
61
- requirement: &id005 !ruby/object:Gem::Requirement
60
+ requirement: &70188295883040 !ruby/object:Gem::Requirement
62
61
  none: false
63
- requirements:
62
+ requirements:
64
63
  - - ~>
65
- - !ruby/object:Gem::Version
64
+ - !ruby/object:Gem::Version
66
65
  version: 1.5.2
67
66
  type: :development
68
67
  prerelease: false
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *70188295883040
69
+ - !ruby/object:Gem::Dependency
71
70
  name: rcov
72
- requirement: &id006 !ruby/object:Gem::Requirement
71
+ requirement: &70188295882560 !ruby/object:Gem::Requirement
73
72
  none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
78
77
  type: :development
79
78
  prerelease: false
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *70188295882560
80
+ - !ruby/object:Gem::Dependency
82
81
  name: dm-sqlite-adapter
83
- requirement: &id007 !ruby/object:Gem::Requirement
82
+ requirement: &70188295882080 !ruby/object:Gem::Requirement
84
83
  none: false
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
89
88
  type: :development
90
89
  prerelease: false
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *70188295882080
91
+ - !ruby/object:Gem::Dependency
93
92
  name: data_mapper
94
- requirement: &id008 !ruby/object:Gem::Requirement
93
+ requirement: &70188295881600 !ruby/object:Gem::Requirement
95
94
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- version: "0"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
100
99
  type: :development
101
100
  prerelease: false
102
- version_requirements: *id008
101
+ version_requirements: *70188295881600
103
102
  description: Jeka is an awesome build/test/benchmarking tool
104
103
  email: igorbonadio@gmail.com
105
- executables:
104
+ executables:
106
105
  - jeka
107
106
  extensions: []
108
-
109
- extra_rdoc_files:
107
+ extra_rdoc_files:
110
108
  - LICENSE.txt
111
109
  - README.rdoc
112
- files:
110
+ - TODO
111
+ files:
113
112
  - .document
114
113
  - Gemfile
115
114
  - Gemfile.lock
@@ -134,7 +133,9 @@ files:
134
133
  - lib/jeka/analysis/test_case.rb
135
134
  - lib/jeka/compilers.rb
136
135
  - lib/jeka/compilers/compiler.rb
136
+ - lib/jeka/compilers/gcc.rb
137
137
  - lib/jeka/compilers/gpp.rb
138
+ - lib/jeka/compilers/python.rb
138
139
  - lib/jeka/compilers/ruby.rb
139
140
  - lib/jeka/console.rb
140
141
  - lib/jeka/implementation.rb
@@ -148,44 +149,46 @@ files:
148
149
  - test/bubble_sort/ruby/bubble_sort.rb
149
150
  - test/double/_tests/_test_01.rb
150
151
  - test/double/algorithm_double.rb
152
+ - test/double/c/double.c
151
153
  - test/double/cpp/double.cpp
154
+ - test/double/objc/double.m
155
+ - test/double/python/double.py
152
156
  - test/double/ruby/double.rb
153
157
  - test/helper.rb
154
158
  - test/test_algorithm.rb
155
159
  - test/test_gpp.rb
156
160
  - test/test_implementation.rb
157
161
  - test/test_test_case.rb
162
+ - TODO
158
163
  homepage: http://github.com/igorbonadio/jeka
159
- licenses:
164
+ licenses:
160
165
  - MIT
161
166
  post_install_message:
162
167
  rdoc_options: []
163
-
164
- require_paths:
168
+ require_paths:
165
169
  - lib
166
- required_ruby_version: !ruby/object:Gem::Requirement
170
+ required_ruby_version: !ruby/object:Gem::Requirement
167
171
  none: false
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- hash: -3026672053806941219
172
- segments:
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ segments:
173
177
  - 0
174
- version: "0"
175
- required_rubygems_version: !ruby/object:Gem::Requirement
178
+ hash: -3355155901599309883
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
180
  none: false
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- version: "0"
181
+ requirements:
182
+ - - ! '>='
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
181
185
  requirements: []
182
-
183
186
  rubyforge_project:
184
- rubygems_version: 1.8.9
187
+ rubygems_version: 1.8.10
185
188
  signing_key:
186
189
  specification_version: 3
187
190
  summary: Jeka is an awesome build/test/benchmarking tool
188
- test_files:
191
+ test_files:
189
192
  - test/bubble_sort/_tests/_test_01.rb
190
193
  - test/bubble_sort/algorithm_bubble_sort.rb
191
194
  - test/bubble_sort/ruby/bubble_sort.rb