dirs-ruby2lolz 0.1.1 → 0.1.2

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.
Files changed (3) hide show
  1. data/lib/ruby2lolz.rb +20 -5
  2. data/ruby2lolz.gemspec +2 -2
  3. metadata +4 -6
data/lib/ruby2lolz.rb CHANGED
@@ -7,8 +7,9 @@ require "parse_tree_extensions"
7
7
  require "unified_ruby"
8
8
 
9
9
  class Ruby2Lolz < SexpProcessor
10
-
10
+
11
11
  def self.translate(klass_or_str, method = nil)
12
+ klass_or_str = ruby2string(klass_or_str).inspect unless klass_or_str.class == String
12
13
  sexp = ParseTree.translate(klass_or_str, method)
13
14
 
14
15
  # unified_ruby is a rewriter plugin that rewires
@@ -40,7 +41,21 @@ class Ruby2Lolz < SexpProcessor
40
41
  def process_scope(exp); process(exp.shift); end
41
42
  def process_lvar(exp); exp.shift.to_s; end
42
43
 
43
-
44
+ def self.ruby2string(hash)
45
+ hash.each do |k, v|
46
+ case v
47
+ when Time
48
+ hash[k] = v.to_s
49
+ when nil
50
+ hash.delete(k)
51
+ when Array
52
+ v.each {|item| ruby2string(item)}
53
+ when Hash
54
+ ruby2string(v)
55
+ end
56
+ end
57
+ end
58
+
44
59
  def process_arglist(exp, verbose = false)
45
60
  code = []
46
61
  until exp.empty? do
@@ -61,17 +76,17 @@ class Ruby2Lolz < SexpProcessor
61
76
 
62
77
  def process_hash(exp)
63
78
  result = []
64
-
79
+
65
80
  until exp.empty?
66
81
  lhs = process(exp.shift)
67
82
  rhs = exp.shift
68
83
  t = rhs.first
69
- rhs = process(rhs) unless t == :nil
84
+ rhs = process(rhs)
70
85
  rhs = "#{rhs}" unless [:lit, :str].include?(t) # TODO: verify better!
71
86
 
72
87
  result.push indent("I CAN HAS #{lhs.to_s.capitalize}\n #{indent(rhs)}\nKTHNX.")
73
88
  end
74
-
89
+
75
90
  case self.context[1]
76
91
  when :arglist, :argscat then
77
92
  return "#{result.join(', ')}"
data/ruby2lolz.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'dirs-ruby2lolz'
3
- s.version = '0.1.1'
4
- s.date = '2009-03-31'
3
+ s.version = '0.1.2'
4
+ s.date = '2009-11-27'
5
5
  s.summary = 'Ruby to Lolcode translator, kthnxbai.'
6
6
  s.description = s.summary
7
7
  s.email = 'ilya@igvita.com'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dirs-ruby2lolz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Grigorik
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-31 00:00:00 -03:00
12
+ date: 2009-11-27 00:00:00 -02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -32,8 +32,6 @@ files:
32
32
  - spec/specs/method.txt
33
33
  has_rdoc: true
34
34
  homepage: http://github.com/igrigorik/ruby2lolz
35
- licenses: []
36
-
37
35
  post_install_message:
38
36
  rdoc_options: []
39
37
 
@@ -54,9 +52,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
52
  requirements: []
55
53
 
56
54
  rubyforge_project: ruby2lolz
57
- rubygems_version: 1.3.5
55
+ rubygems_version: 1.3.1
58
56
  signing_key:
59
- specification_version: 3
57
+ specification_version: 2
60
58
  summary: Ruby to Lolcode translator, kthnxbai.
61
59
  test_files: []
62
60