pebbles-totsugen 0.0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3cb227288cceb54738600e762eb39e1ac2c310a9
4
+ data.tar.gz: 87758c786394a3e8727212846930d0c3ce657fa2
5
+ SHA512:
6
+ metadata.gz: 447bda54f3a10ce488b5d08cca32d65b4c5b21274c06773b53aaa1022feb69d746dda6c076c59123f830a81c1b874bd7483966b82e60224197131c35c0054bf7
7
+ data.tar.gz: 88e64be366062d48fd309114cecd250d22dbc9dfff15c5efd092371ba2ba2d4f28c19b0d0ba32989f13c61d60ea813de8e5011c1896749d21e68ae397971f38d
data/.gitignore ADDED
@@ -0,0 +1,38 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .DS_Store
6
+ .ruby-version
7
+ coverage
8
+ coverage.data
9
+ InstalledFiles
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+
18
+ # bundler
19
+ vendor/
20
+
21
+ # YARD artifacts
22
+ .yardoc
23
+ _yardoc
24
+ doc/
25
+
26
+ # tmp-old
27
+ .old
28
+
29
+ # editor
30
+ *~
31
+ .redcar
32
+
33
+ # other
34
+ *.lock
35
+ *.bak
36
+ tool/
37
+ .rbx/
38
+ *\#*
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - ruby-head
5
+ - 2.0.0
6
+ - 1.9.3
7
+ - 1.9.2
8
+ - rbx-nightly-19mode
9
+ - jruby-head
10
+ - jruby-19mode
11
+
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: ruby-head
15
+ - rvm: rbx-nightly-19mode
16
+ - rvm: jruby-head
17
+ - rvm: jruby-19mode
18
+
19
+ before_install:
20
+ - gem install bundler
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --readme README.md lib/**/*.rb
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake'
7
+ end
8
+
9
+ group :test do
10
+ gem 'rake'
11
+ end
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ pebbles-totsugen
2
+ ================
3
+
4
+ [![Build Status](https://secure.travis-ci.org/kachick/pebbles-totsugen.png)](http://travis-ci.org/kachick/pebbles-totsugen)
5
+ [![Gem Version](https://badge.fury.io/rb/pebbles-totsugen.png)](http://badge.fury.io/rb/pebbles-totsugen)
6
+
7
+ なにこれ
8
+ -----------
9
+
10
+ ```plaintext
11
+ _人人人人人人人人人_
12
+ > 突然のリリース <
13
+  ̄Y^Y^Y^Y^Y^Y^Y^Y ̄
14
+ ```
15
+
16
+ 使い方
17
+ -----
18
+
19
+ ### ターミナルから
20
+
21
+ 引数で渡したり
22
+
23
+ ```bash
24
+ $ totsugen 突然の死
25
+ _人人人人人人_
26
+ > 突然の死 <
27
+  ̄Y^Y^Y^Y^Y ̄
28
+ ```
29
+
30
+ 標準入力で渡したり
31
+
32
+ ```bash
33
+ $ echo '突然のSTDIN' | totsugen
34
+ _人人人人人人人_
35
+ > 突然のSTDIN <
36
+  ̄Y^Y^Y^Y^Y^Y ̄
37
+ ```
38
+
39
+ ### ライブラリとして(なんに使うんだこんなもん)
40
+
41
+ ```ruby
42
+ require 'pebbles/totsugen'
43
+
44
+ Pebbles::TotsuGen.generate('突然のrequire') #=> _人人人人人人人人_
45
+ # > 突然のrequire <
46
+ #  ̄Y^Y^Y^Y^Y^Y^Y ̄
47
+
48
+ ```
49
+
50
+ 動作環境
51
+ -------------
52
+
53
+ * Ruby - [1.9.2以上](http://travis-ci.org/#!/kachick/pebbles-totsugen)
54
+
55
+ Install
56
+ -------
57
+
58
+ ```bash
59
+ $ gem install pebbles-totsugen
60
+ ```
61
+
62
+ Link
63
+ ----
64
+
65
+ * [Home](http://kachick.github.com/pebbles-totsugen/)
66
+ * [code](https://github.com/kachick/pebbles-totsugen)
67
+ * [API](http://kachick.github.com/pebbles-totsugen/yard/frames.html)
68
+ * [issues](https://github.com/kachick/pebbles-totsugen/issues)
69
+ * [CI](http://travis-ci.org/#!/kachick/pebbles-totsugen)
70
+ * [gem](https://rubygems.org/gems/pebbles-totsugen)
71
+
72
+ お決まりのライセンス
73
+ --------
74
+
75
+ The MIT X11 License
76
+ Copyright (c) 2013 Kenichi Kamiya
77
+ See MIT-LICENSE for further details.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env rake
2
+ require 'bundler/gem_tasks'
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ task default: [:spec]
7
+
8
+ RSpec::Core::RakeTask.new(:spec) do |t|
9
+ t.pattern = 'spec/**/*_spec.rb'
10
+ t.ruby_opts = %w[-w]
11
+ end
data/bin/totsugen ADDED
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require_relative '../lib/pebbles/totsugen'
5
+
6
+ include Pebbles
7
+
8
+ usage =<<"EOS"
9
+ #{$PROGRAM_NAME} - 突然のほにゃほにゃジェネレータ
10
+
11
+ 1. from $1
12
+ $ #{$PROGRAM_NAME} 突然の死
13
+
14
+ 2. from STDIN
15
+ $ echo '突然の死' | #{$PROGRAM_NAME}
16
+ EOS
17
+
18
+ case ARGV.length
19
+ when 0
20
+ puts TotsuGen.generate(gets.chomp)
21
+ when 1
22
+ puts TotsuGen.generate(ARGV.shift)
23
+ else
24
+ abort usage
25
+ end
@@ -0,0 +1,11 @@
1
+ # coding: us-ascii
2
+ # Copyright (c) 2013 Kenichi Kamiya
3
+
4
+ module Pebbles
5
+ module TotsuGen
6
+ end
7
+ end
8
+
9
+ require_relative 'totsugen/version'
10
+ require_relative 'totsugen/formatters'
11
+ require_relative 'totsugen/singleton_class'
@@ -0,0 +1,73 @@
1
+ # coding: utf-8
2
+
3
+ module Pebbles::TotsuGen
4
+
5
+ class Formatter
6
+ def initialize(body)
7
+ @body = body
8
+ end
9
+
10
+ def result
11
+ "#{header}\n#{center}\n#{footer}"
12
+ end
13
+
14
+ private
15
+
16
+ def body_length
17
+ @body.each_char.inject(0){|total, char|total += char.bytesize == 1 ? 1 : 2}
18
+ end
19
+
20
+ def header
21
+ "_#{body_top}_"
22
+ end
23
+
24
+ def footer
25
+ " ̄#{body_bottom} ̄"
26
+ end
27
+ end
28
+
29
+ # なんか、元々はこういうフォーマットだったっぽいので一応実装しておいた。
30
+ class OriginFormatter < Formatter
31
+ private
32
+
33
+ def center
34
+ "> #{@body} <"
35
+ end
36
+
37
+ def body_top
38
+ half = '人' * ((body_length / 2) / 2)
39
+ shortage = body_length % 4
40
+ padding = case shortage
41
+ when 3, 2
42
+ '人'
43
+ when 1
44
+ ''
45
+ when 0
46
+ ' '
47
+ end
48
+
49
+ "#{half}#{padding}#{half}"
50
+ end
51
+
52
+ def body_bottom
53
+ ('Y^' * (body_length / 2)).chop
54
+ end
55
+ end
56
+
57
+ class SimplifiedFormatter < Formatter
58
+ private
59
+
60
+ def center
61
+ "> #{@body} <"
62
+ end
63
+
64
+ def body_top
65
+ '人' * ((body_length / 2) + 2)
66
+ end
67
+
68
+ def body_bottom
69
+ ('Y^' * ((body_length / 2) + 1)).chop
70
+ end
71
+ end
72
+
73
+ end
@@ -0,0 +1,12 @@
1
+ # coding: us-ascii
2
+
3
+ module Pebbles::TotsuGen; class << self
4
+
5
+ # @param body [String, #to_str]
6
+ # @return [String]
7
+ def generate(body)
8
+ formatter = SimplifiedFormatter.new body.to_str
9
+ formatter.result
10
+ end
11
+
12
+ end; end
@@ -0,0 +1,5 @@
1
+ # coding: us-ascii
2
+
3
+ module Pebbles::TotsuGen
4
+ VERSION = '0.0.1.2'.freeze
5
+ end
@@ -0,0 +1,29 @@
1
+ require './lib/pebbles/totsugen'
2
+
3
+ Gem::Specification.new do |gem|
4
+ # specific
5
+
6
+ gem.description = %q{totsuzenno generator!!}
7
+
8
+ gem.summary = gem.description.dup
9
+ gem.homepage = 'http://kachick.github.com/pebbles-totsugen/'
10
+ gem.license = 'MIT'
11
+ gem.name = 'pebbles-totsugen'
12
+ gem.version = Pebbles::TotsuGen::VERSION.dup
13
+
14
+ gem.required_ruby_version = '>= 1.9.2'
15
+
16
+ gem.add_development_dependency 'yard', '>= 0.8.6.1', '< 0.9'
17
+ gem.add_development_dependency 'rspec', '>= 2.13', '< 3'
18
+ gem.add_development_dependency 'rake', '>= 10', '< 20'
19
+ gem.add_development_dependency 'bundler', '>= 1.3.5', '< 2'
20
+
21
+ # common
22
+
23
+ gem.authors = ['Kenichi Kamiya']
24
+ gem.email = ['kachick1+ruby@gmail.com']
25
+ gem.files = `git ls-files`.split($\)
26
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
27
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
28
+ gem.require_paths = ['lib']
29
+ end
data/spec/helper.rb ADDED
@@ -0,0 +1,5 @@
1
+ # coding: us-ascii
2
+
3
+ require 'rspec'
4
+
5
+ require_relative '../lib/pebbles/totsugen'
@@ -0,0 +1,100 @@
1
+ # coding: utf-8
2
+
3
+ require_relative 'helper'
4
+
5
+ describe Pebbles::TotsuGen do
6
+ context '.generate' do
7
+ it "簡易フォーマットを返す" do
8
+ str = Pebbles::TotsuGen::SimplifiedFormatter.new('突然の死').result
9
+ expect(Pebbles::TotsuGen.generate('突然の死')).to eq(str)
10
+ end
11
+ end
12
+ end
13
+
14
+ describe Pebbles::TotsuGen::OriginFormatter do
15
+ let(:generator) {Pebbles::TotsuGen::OriginFormatter}
16
+
17
+ context '#result' do
18
+ context '引数を突然のほにゃほにゃフォーマットにして返せるよねーっていう' do
19
+ specify '基本型として、「突然の死」をうまいこと片付ける' do
20
+ str = <<'EOS'
21
+ _人人 人人_
22
+ > 突然の死 <
23
+  ̄Y^Y^Y^Y ̄
24
+ EOS
25
+ expect(generator.new('突然の死').result).to eq(str.chomp)
26
+ end
27
+
28
+ specify '基本型から1文字増えてもうまいことやる' do
29
+ str = <<'EOS'
30
+ _人人人人人_
31
+ > 突然の昼寝 <
32
+  ̄Y^Y^Y^Y^Y ̄
33
+ EOS
34
+ expect(generator.new('突然の昼寝').result).to eq(str.chomp)
35
+ end
36
+
37
+ specify '基本型から1文字減ってもうまいことやる' do
38
+ str = <<'EOS'
39
+ _人人人_
40
+ > うだー <
41
+  ̄Y^Y^Y ̄
42
+ EOS
43
+ expect(generator.new('うだー').result).to eq(str.chomp)
44
+ end
45
+
46
+ specify '1byte文字と2byte文字混じってる時にもうまいことやっつける' do
47
+ str = <<'EOS'
48
+ _人人人人人_
49
+ > 突然のRuby <
50
+  ̄Y^Y^Y^Y^Y ̄
51
+ EOS
52
+ expect(generator.new('突然のRuby').result).to eq(str.chomp)
53
+ end
54
+ end
55
+ end
56
+ end
57
+
58
+ describe Pebbles::TotsuGen::SimplifiedFormatter do
59
+ let(:generator) {Pebbles::TotsuGen::SimplifiedFormatter}
60
+
61
+ context '#result' do
62
+ context '引数を突然のほにゃほにゃフォーマットにして返せるよねーっていう' do
63
+ specify '基本型として、「突然の死」をうまいこと片付ける' do
64
+ str = <<'EOS'
65
+ _人人人人人人_
66
+ > 突然の死 <
67
+  ̄Y^Y^Y^Y^Y ̄
68
+ EOS
69
+ expect(generator.new('突然の死').result).to eq(str.chomp)
70
+ end
71
+
72
+ specify '基本型から1文字増えてもうまいことやる' do
73
+ str = <<'EOS'
74
+ _人人人人人人人_
75
+ > 突然の昼寝 <
76
+  ̄Y^Y^Y^Y^Y^Y ̄
77
+ EOS
78
+ expect(generator.new('突然の昼寝').result).to eq(str.chomp)
79
+ end
80
+
81
+ specify '基本型から1文字減ってもうまいことやる' do
82
+ str = <<'EOS'
83
+ _人人人人人_
84
+ > うだー <
85
+  ̄Y^Y^Y^Y ̄
86
+ EOS
87
+ expect(generator.new('うだー').result).to eq(str.chomp)
88
+ end
89
+
90
+ specify '1byte文字と2byte文字混じってる時にもうまいことやっつける' do
91
+ str = <<'EOS'
92
+ _人人人人人人人_
93
+ > 突然のRuby <
94
+  ̄Y^Y^Y^Y^Y^Y ̄
95
+ EOS
96
+ expect(generator.new('突然のRuby').result).to eq(str.chomp)
97
+ end
98
+ end
99
+ end
100
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pebbles-totsugen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Kenichi Kamiya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.8.6.1
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '0.9'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.8.6.1
30
+ - - <
31
+ - !ruby/object:Gem::Version
32
+ version: '0.9'
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '2.13'
40
+ - - <
41
+ - !ruby/object:Gem::Version
42
+ version: '3'
43
+ type: :development
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '2.13'
50
+ - - <
51
+ - !ruby/object:Gem::Version
52
+ version: '3'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rake
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - '>='
58
+ - !ruby/object:Gem::Version
59
+ version: '10'
60
+ - - <
61
+ - !ruby/object:Gem::Version
62
+ version: '20'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '10'
70
+ - - <
71
+ - !ruby/object:Gem::Version
72
+ version: '20'
73
+ - !ruby/object:Gem::Dependency
74
+ name: bundler
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - '>='
78
+ - !ruby/object:Gem::Version
79
+ version: 1.3.5
80
+ - - <
81
+ - !ruby/object:Gem::Version
82
+ version: '2'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.5
90
+ - - <
91
+ - !ruby/object:Gem::Version
92
+ version: '2'
93
+ description: totsuzenno generator!!
94
+ email:
95
+ - kachick1+ruby@gmail.com
96
+ executables:
97
+ - totsugen
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - .travis.yml
103
+ - .yardopts
104
+ - Gemfile
105
+ - README.md
106
+ - Rakefile
107
+ - bin/totsugen
108
+ - lib/pebbles/totsugen.rb
109
+ - lib/pebbles/totsugen/formatters.rb
110
+ - lib/pebbles/totsugen/singleton_class.rb
111
+ - lib/pebbles/totsugen/version.rb
112
+ - pebbles-totsugen.gemspec
113
+ - spec/helper.rb
114
+ - spec/pebbles-totsugen_spec.rb
115
+ homepage: http://kachick.github.com/pebbles-totsugen/
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: 1.9.2
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.0.2
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: totsuzenno generator!!
139
+ test_files:
140
+ - spec/helper.rb
141
+ - spec/pebbles-totsugen_spec.rb
142
+ has_rdoc: