ikamusume 1.0.0
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.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +63 -0
- data/Rakefile +52 -0
- data/lib/ikamusume.rb +74 -0
- data/test/test_ikamusume.rb +23 -0
- metadata +71 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Yusuke Endoh
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
= ikamusume
|
2
|
+
|
3
|
+
ikamusume invades Ruby.
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
Hello, world in ikamusume
|
8
|
+
|
9
|
+
require "ikamusume"
|
10
|
+
"Hello, world" <= ikamusume!
|
11
|
+
|
12
|
+
|
13
|
+
fibonacci in ikamusume
|
14
|
+
|
15
|
+
require "ikamusume"
|
16
|
+
shinryaku! <=
|
17
|
+
(shinryaku! <=
|
18
|
+
(shinryaku! <=
|
19
|
+
ikamusume! <=
|
20
|
+
ikamusume!) <=
|
21
|
+
(geso <=
|
22
|
+
ikamusume!)) <=
|
23
|
+
(geso <=
|
24
|
+
"geso") <=
|
25
|
+
(shinryaku! <=
|
26
|
+
(shinryaku! <=
|
27
|
+
(geso <=
|
28
|
+
shinryaku!) <=
|
29
|
+
(shinryaku! <=
|
30
|
+
(geso <=
|
31
|
+
(shinryaku! <=
|
32
|
+
(geso <=
|
33
|
+
shinryaku!))) <=
|
34
|
+
(shinryaku! <=
|
35
|
+
(shinryaku! <=
|
36
|
+
(geso <=
|
37
|
+
shinryaku!) <=
|
38
|
+
(shinryaku! <=
|
39
|
+
(geso <=
|
40
|
+
(shinryaku! <=
|
41
|
+
(geso <=
|
42
|
+
"\n"))) <=
|
43
|
+
(shinryaku! <=
|
44
|
+
(geso <=
|
45
|
+
(shinryaku! <=
|
46
|
+
ikamusume!)) <=
|
47
|
+
geso))) <=
|
48
|
+
geso))) <=
|
49
|
+
(geso <=
|
50
|
+
(shinryaku! <=
|
51
|
+
(geso <=
|
52
|
+
shinryaku!) <=
|
53
|
+
geso)))
|
54
|
+
|
55
|
+
== Links
|
56
|
+
|
57
|
+
http://d.hatena.ne.jp/ku-ma-me/20101215/p1 (in Japanese)
|
58
|
+
http://github.com/mame/ikamusume
|
59
|
+
http://en.wikipedia.org/wiki/Shinryaku!_Ika_Musume
|
60
|
+
|
61
|
+
== Copyright
|
62
|
+
|
63
|
+
Copyright (c) 2010 Yusuke Endoh. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "ikamusume"
|
8
|
+
gem.summary = %Q{ikamusume invades Ruby.}
|
9
|
+
gem.description = %Q{ikamusume invades Ruby.}
|
10
|
+
gem.email = "mame@tsg.ne.jp"
|
11
|
+
gem.homepage = "http://github.com/mame/ikamusume"
|
12
|
+
gem.authors = ["Yusuke Endoh"]
|
13
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
14
|
+
end
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/testtask'
|
21
|
+
Rake::TestTask.new(:test) do |test|
|
22
|
+
test.libs << 'lib' << 'test'
|
23
|
+
test.pattern = 'test/**/test_*.rb'
|
24
|
+
test.verbose = true
|
25
|
+
end
|
26
|
+
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |test|
|
30
|
+
test.libs << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
task :rcov do
|
36
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
task :test => :check_dependencies
|
41
|
+
|
42
|
+
task :default => :test
|
43
|
+
|
44
|
+
require 'rake/rdoctask'
|
45
|
+
Rake::RDocTask.new do |rdoc|
|
46
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
47
|
+
|
48
|
+
rdoc.rdoc_dir = 'rdoc'
|
49
|
+
rdoc.title = "ikamusume #{version}"
|
50
|
+
rdoc.rdoc_files.include('README*')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
data/lib/ikamusume.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require "prettyprint"
|
4
|
+
|
5
|
+
# Proc と String を侵略してやるでゲソ
|
6
|
+
class Proc
|
7
|
+
alias <= call
|
8
|
+
end
|
9
|
+
|
10
|
+
class String
|
11
|
+
def <=(x)
|
12
|
+
display
|
13
|
+
x
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# 侵略!コンビネータ (S) じゃなイカ?
|
18
|
+
def shinryaku!
|
19
|
+
proc {|x| proc {|y| proc {|z| x <= z <= (y <= z) } } }
|
20
|
+
end
|
21
|
+
|
22
|
+
# ゲソコンビネータ (K) じゃなイカ?
|
23
|
+
def geso
|
24
|
+
proc {|x| proc {|y| x } }
|
25
|
+
end
|
26
|
+
|
27
|
+
# イカ娘!コンビネータ (I) じゃなイカ?
|
28
|
+
def ika?
|
29
|
+
proc {|x| x }
|
30
|
+
end
|
31
|
+
|
32
|
+
[ [:shinryaku!, :"侵略!", :"侵略!"],
|
33
|
+
[:geso, :geso!, :"ゲソ", :"ゲソ!", :"ゲソ!"],
|
34
|
+
[:ika?, :ikamusume!, :"イカ?", :"イカ?", :"イカ娘!", :"イカ娘!"],
|
35
|
+
].each do |m, *ms|
|
36
|
+
ms.each do |m2|
|
37
|
+
Kernel.module_eval { alias_method(m2, m) }
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Unlambda も侵略してやるでゲソ
|
42
|
+
def unlambda_to_ikamusume!(src, keywords = [["侵略!", 5], ["ゲソ", 4], ["イカ娘!", 7]])
|
43
|
+
PrettyPrint.format("", 0) do |pp|
|
44
|
+
translate = proc do |need_paren|
|
45
|
+
ch = src.slice!(0, 1)
|
46
|
+
case ch
|
47
|
+
when "`"
|
48
|
+
if need_paren
|
49
|
+
pp.group(2, "(", ")") do
|
50
|
+
translate[false]
|
51
|
+
pp.text " <="
|
52
|
+
pp.breakable
|
53
|
+
translate[true]
|
54
|
+
end
|
55
|
+
else
|
56
|
+
translate[false]
|
57
|
+
pp.text " <="
|
58
|
+
pp.breakable
|
59
|
+
translate[true]
|
60
|
+
end
|
61
|
+
when "s" then pp.text *keywords[0]
|
62
|
+
when "k" then pp.text *keywords[1]
|
63
|
+
when "i" then pp.text *keywords[2]
|
64
|
+
when "." then pp.text src.slice!(0, 1).dump
|
65
|
+
when "r" then pp.text '"\n"'
|
66
|
+
when "#" then src.slice!(/.*/); translate[need_paren]
|
67
|
+
when /\A\s\z/ then translate[need_paren]
|
68
|
+
when nil then raise "unexpected termination"
|
69
|
+
else raise "unimplemented instruction: %p" % ch
|
70
|
+
end
|
71
|
+
end
|
72
|
+
translate[false]
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require "ikamusume"
|
4
|
+
require 'test/unit'
|
5
|
+
|
6
|
+
class TestIkamusume < Test::Unit::TestCase
|
7
|
+
def test_s
|
8
|
+
assert_equal(侵略![proc {|z| proc {|w| w + 2 * z } }][proc {|z| z * 3 }][5], 25)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_k
|
12
|
+
assert_equal(ゲソ[42][43], 42)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_i
|
16
|
+
assert_equal(イカ娘![42], 42)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_apply
|
20
|
+
assert_equal(イカ娘! <= 42, 42)
|
21
|
+
assert_equal(侵略! <= ゲソ <= ゲソ <= 42, 42)
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ikamusume
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
version: 1.0.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Yusuke Endoh
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-12-15 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: ikamusume invades Ruby.
|
22
|
+
email: mame@tsg.ne.jp
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- LICENSE
|
29
|
+
- README.rdoc
|
30
|
+
files:
|
31
|
+
- .document
|
32
|
+
- .gitignore
|
33
|
+
- LICENSE
|
34
|
+
- README.rdoc
|
35
|
+
- Rakefile
|
36
|
+
- lib/ikamusume.rb
|
37
|
+
- test/test_ikamusume.rb
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/mame/ikamusume
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options:
|
44
|
+
- --charset=UTF-8
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.7
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: ikamusume invades Ruby.
|
70
|
+
test_files:
|
71
|
+
- test/test_ikamusume.rb
|