├── .gitignore ├── Rakefile ├── Gemfile ├── lib └── _.rb ├── _.gemspec ├── README.md └── LICENSE.txt /.gitignore: -------------------------------------------------------------------------------- 1 | pkg/ 2 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } 4 | 5 | # Specify your gem's dependencies in underscore.gemspec 6 | gemspec 7 | -------------------------------------------------------------------------------- /lib/_.rb: -------------------------------------------------------------------------------- 1 | def __script__(src) 2 | code = [] 3 | src = src.unpack("C*").map {|c| c.ord.to_s(6).rjust(3, "0").chars.to_a } 4 | src.flatten(1).map {|n| n.to_i(6) + 1 }.each do |n| 5 | code.empty? || code.last.size + n + 1 >= 60 ? code << "" : code.last << " " 6 | code.last << "_" * n 7 | end 8 | ([%q(require "_")] + code).join("\n") 9 | end 10 | 11 | $code, $fragment = [], [] 12 | def method_missing(mhd, *x) 13 | if x.empty? 14 | $code.concat($fragment.reverse) 15 | $fragment.clear 16 | end 17 | $fragment << (mhd.to_s.size - 1).to_s 18 | end 19 | 20 | at_exit do 21 | $code.concat($fragment.reverse) 22 | eval($code.join.scan(/.../).map {|c| c.to_i(6) }.pack("C*")) 23 | end 24 | -------------------------------------------------------------------------------- /_.gemspec: -------------------------------------------------------------------------------- 1 | lib = File.expand_path("../lib", __FILE__) 2 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 3 | 4 | Gem::Specification.new do |spec| 5 | spec.name = "_" 6 | spec.version = "1.4" 7 | spec.authors = ["Yusuke Endoh"] 8 | spec.email = ["mame@ruby-lang.org"] 9 | 10 | spec.summary = %q{_ allows you to write Ruby script by using only _.} 11 | spec.description = %q{_ allows you to write Ruby script by using only _.} 12 | spec.homepage = "http://github.com/mame/_" 13 | spec.license = "MIT" 14 | 15 | spec.files = `git ls-files`.split($/) 16 | spec.require_paths = ["lib"] 17 | 18 | spec.add_development_dependency "bundler", "~> 1.16" 19 | spec.add_development_dependency "rake", "~> 10.0" 20 | end 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # `_` 2 | 3 | `_` allows you to write Ruby script by using only `_`. 4 | 5 | ## Installation 6 | 7 | $ gem install _ 8 | 9 | ## Usage 10 | 11 | The following __script__ is a "Hello, world!" program which can be executed by Ruby interpreter: 12 | 13 | require "_" 14 | ____ _ _____ ____ __ ____ ____ __ ___ ____ __ __ _ ______ 15 | _____ ___ _ _ ___ _____ ______ ____ _ _ ____ _ _ ____ _ 16 | ____ __ __ ___ _ ______ ___ ____ __ ______ ____ _ ____ ____ 17 | __ _ ____ _ _ ___ _____ _____ _ ______ ____ _ ______ _____ 18 | 19 | You can make a `__script__` by `__script__`: 20 | 21 | require "_" 22 | puts __script__('puts"Hello, world!"') 23 | 24 | ## License 25 | 26 | The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). 27 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2009 Yusuke Endoh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | --------------------------------------------------------------------------------