siatra 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +20 -0
- data/bin/siatra +15 -0
- data/lib/siatra.rb +33 -0
- data/siatra.gemspec +29 -0
- data/spec/siatra_spec.rb +30 -0
- metadata +79 -0
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Siatra: reversed art'izing tool
|
2
|
+
|
3
|
+
Art + ize `->` Artize `->` Artais `->` Siatra (reversed)
|
4
|
+
|
5
|
+
To convert your artistic code to non-artistic code.
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
gem install siatra
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
$ siatra -h
|
14
|
+
$ siatra -v
|
15
|
+
$ siatra {filename}
|
16
|
+
|
17
|
+
or
|
18
|
+
|
19
|
+
require 'siatra'
|
20
|
+
p Siatra File.read '{filename}'
|
data/bin/siatra
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
$: << 'lib'
|
4
|
+
require 'siatra'
|
5
|
+
case ARGV[0]
|
6
|
+
when '-h', '--help'
|
7
|
+
puts Siatra.help
|
8
|
+
when '-v', '--version'
|
9
|
+
puts Siatra::VERSION
|
10
|
+
else
|
11
|
+
abort 'no filename given' unless ARGV[0]
|
12
|
+
filename = Pathname(ARGV.shift).expand_path
|
13
|
+
puts Siatra filename.read
|
14
|
+
end
|
15
|
+
# vim: set ft=ruby :
|
data/lib/siatra.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'strscan'
|
2
|
+
|
3
|
+
module Siatra
|
4
|
+
VERSION = '0.1'
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def help
|
8
|
+
puts " siatra -v shows version number"
|
9
|
+
puts " siatra -h shows this message"
|
10
|
+
puts " siatra {filename} shows de-artized content of the file"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def Siatra(code)
|
16
|
+
s = StringScanner.new(code)
|
17
|
+
memo = []
|
18
|
+
is = {shebanged: false}
|
19
|
+
until s.eos?
|
20
|
+
case
|
21
|
+
when !is[:shebanged] && s.scan(/^#!.*\n/)
|
22
|
+
memo << s[0]
|
23
|
+
is[:shebanged] = true
|
24
|
+
when s.scan(/\r?\n/m)
|
25
|
+
memo << ';'
|
26
|
+
when s.scan(/./)
|
27
|
+
memo << s[0]
|
28
|
+
else
|
29
|
+
raise 'must not happen'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
memo.join
|
33
|
+
end
|
data/siatra.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path('../lib/siatra', __FILE__)
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.name = %q{siatra}
|
4
|
+
s.version = Siatra::VERSION.dup
|
5
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
6
|
+
|
7
|
+
s.summary = %q{Siatra: reversed art'izing tool}
|
8
|
+
s.description = %q{To convert your artistic code to non-artistic code.}
|
9
|
+
|
10
|
+
s.author = 'ujihisa'
|
11
|
+
s.email = %q{ujihisa at gmail.com}
|
12
|
+
|
13
|
+
s.files =
|
14
|
+
Dir['lib/**/*'] +
|
15
|
+
Dir['bin/**/*'] +
|
16
|
+
Dir['spec/**/*'] +
|
17
|
+
%w{ siatra.gemspec README.md }
|
18
|
+
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.executables = ['siatra']
|
21
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
22
|
+
|
23
|
+
s.homepage = %q{https://github.com/ujihisa/siatra}
|
24
|
+
|
25
|
+
s.extra_rdoc_files = %w< README.md >
|
26
|
+
|
27
|
+
#s.add_development_dependency('rake')
|
28
|
+
s.add_development_dependency('rspec')
|
29
|
+
end
|
data/spec/siatra_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative '../lib/siatra'
|
2
|
+
require 'open3'
|
3
|
+
|
4
|
+
describe 'Siatra' do
|
5
|
+
context '()' do
|
6
|
+
it 'converts linefeeds to semicolons' do
|
7
|
+
Siatra("this\nis\na\npen.").should == 'this;is;a;pen.'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "doesn't convert shebang line" do
|
11
|
+
Siatra("#!a\nis\na\npen.").should == "#!a\nis;a;pen."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '/bin/siatra' do
|
17
|
+
context '-h' do
|
18
|
+
it 'shows help message' do
|
19
|
+
x, _ = Open3.capture2e('./bin/siatra -h')
|
20
|
+
x.should =~ /shows this message/
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context '-v' do
|
25
|
+
it 'shows version' do
|
26
|
+
x, _ = Open3.capture2e('./bin/siatra -v')
|
27
|
+
x.should =~ /\d\.\d/
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: siatra
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
version: "0.1"
|
9
|
+
platform: ruby
|
10
|
+
authors:
|
11
|
+
- ujihisa
|
12
|
+
autorequire:
|
13
|
+
bindir: bin
|
14
|
+
cert_chain: []
|
15
|
+
|
16
|
+
date: 2011-03-29 00:00:00 -07:00
|
17
|
+
default_executable:
|
18
|
+
dependencies:
|
19
|
+
- !ruby/object:Gem::Dependency
|
20
|
+
name: rspec
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
description: To convert your artistic code to non-artistic code.
|
33
|
+
email: ujihisa at gmail.com
|
34
|
+
executables:
|
35
|
+
- siatra
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files:
|
39
|
+
- README.md
|
40
|
+
files:
|
41
|
+
- lib/siatra.rb
|
42
|
+
- bin/siatra
|
43
|
+
- spec/siatra_spec.rb
|
44
|
+
- siatra.gemspec
|
45
|
+
- README.md
|
46
|
+
has_rdoc: true
|
47
|
+
homepage: https://github.com/ujihisa/siatra
|
48
|
+
licenses: []
|
49
|
+
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.3.7
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: "Siatra: reversed art'izing tool"
|
78
|
+
test_files: []
|
79
|
+
|