mumuki-ruby-runner 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b42e4d6d2a88e627145400a03dee6d85d245e88
4
- data.tar.gz: c47151272a126cd96217c7c0e10bc2c16e298608
3
+ metadata.gz: 988622db185a5d78fca2eb93bf165f24d0c28d07
4
+ data.tar.gz: bd1674bc036ef76421250c1a153996aa28bad849
5
5
  SHA512:
6
- metadata.gz: 14a7ac9efcf50e4cf87f9e60caeb8b3bfeefcddbd3c14371b926cd672f32d6cafa64cce928ed258a9f9950f80acf7d1db4fcd41a31eca9587dc4a8c41f7c4dcb
7
- data.tar.gz: d461227be5fc65ed97dee42eed8729caa9c4bc0a670acd6360024f83f8e7cd35f60d6b348a370d38a1c1026a951d6b2ba93500324fff74a24ab6f957b5cecc95
6
+ metadata.gz: e2ba24fc9d404aa567559948e526476e352109bde95389683f4ab45d2928b184dc8f964165b5e33a6172c2ace6ce49b999737e20beae9679a34b98ba6db34453
7
+ data.tar.gz: e47517509c27f46931bac0b49b006d67a49899dc997fb5b36704c1f7a9c6cab88bf8139745a28efbf4166ac2c63e5ebbc187e56c33f79d6eaa972ce22d9e6c75
data/lib/query_hook.rb CHANGED
@@ -6,10 +6,52 @@ class RubyQueryHook < Mumukit::Templates::FileHook
6
6
  end
7
7
 
8
8
  def compile_file_content(r)
9
- "#{r.extra}\n#{r.content}\nprint('=> ' + (#{r.query}).inspect)"
9
+ <<ruby
10
+ class MumukiConsole
11
+ def self.write(string)
12
+ end
13
+ def self.enter_cookie!
14
+ @@old_stdout = $stdout
15
+ $stdout = MumukiConsole
16
+ end
17
+ def self.exit_cookie!
18
+ $stdout = @@old_stdout
19
+ end
20
+ end
21
+ #{r.extra}
22
+ #{r.content}
23
+ MumukiConsole.enter_cookie!
24
+ #{compile_cookie(r.cookie)}
25
+ MumukiConsole.exit_cookie!
26
+ #{compile_query(r.query)}
27
+ ruby
10
28
  end
11
29
 
12
30
  def command_line(filename)
13
31
  "ruby #{filename}"
14
32
  end
15
- end
33
+
34
+ def compile_query(query)
35
+ if query.start_with? 'def '
36
+ "#{query}\nputs \"=> nil\""
37
+ else
38
+ "print('=> ' + (#{query}).inspect)"
39
+ end
40
+ end
41
+
42
+ def build_state(cookie)
43
+ (cookie||[]).map do |statement|
44
+ <<ruby
45
+ begin
46
+ #{statement}
47
+ rescue
48
+ end
49
+ ruby
50
+ end
51
+ end
52
+
53
+ def compile_cookie(cookie)
54
+ build_state(cookie).join("\n")
55
+ end
56
+
57
+ end
data/lib/ruby_runner.rb CHANGED
@@ -8,6 +8,7 @@ Mumukit.configure do |config|
8
8
  config.stateful = true
9
9
  end
10
10
 
11
+ require_relative './version'
11
12
  require_relative './metadata_hook'
12
13
  require_relative './test_hook'
13
14
  require_relative './query_hook'
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module RubyVersionHook
2
+ VERSION = '1.1.0'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumuki-ruby-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-27 00:00:00.000000000 Z
11
+ date: 2016-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mumukit
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.5'
19
+ version: '2.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.5'
26
+ version: '2.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -105,6 +105,7 @@ files:
105
105
  - lib/query_hook.rb
106
106
  - lib/ruby_runner.rb
107
107
  - lib/test_hook.rb
108
+ - lib/version.rb
108
109
  homepage: http://github.com/mumuki/mumuki-ruby-server
109
110
  licenses:
110
111
  - MIT