sawarineko 0.1.0

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: ed36c54059b56206a7a3be7cb23d87bbaf4e5f41
4
+ data.tar.gz: 55394debcf39c23fb2d70a48b376c693a130fd34
5
+ SHA512:
6
+ metadata.gz: a7618612fa74967554b300c6e456e7f2bfb1b1276e0819239bb92c4a5ce81b5109bd251900950a5d7c5e45972db5e65bcc6d8b515f7aa39cdc4f9b5a4746380d
7
+ data.tar.gz: 7e0ccfe7fc9ba061512be4ef3fbe8e4a7eac45add9f9e50f609536cc022dd34974d12d7054e2c5037ece09ad51ec517552966b6828a15e687f40f4e56240cecb
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ # Bundler
2
+ /.bundle/
3
+ *.bundle
4
+ /Gemfile.lock
5
+
6
+ # Documentation
7
+ /.yardoc
8
+ /_yardoc/
9
+ /doc/
10
+
11
+ # Coverage
12
+ /coverage/
13
+ /spec/reports/
14
+
15
+ # RubyGems
16
+ /pkg/
17
+
18
+ # Temp
19
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,4 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Style/Encoding:
4
+ Enabled: true
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,6 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-10-12 11:48:54 +0900 using RuboCop version 0.26.1.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2014-10-12)
4
+
5
+ - First release
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # encoding: utf-8
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 ChaYoung You
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.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # Sawarineko
2
+
3
+ > ななめななじゅうななどのならびでなくなくいななくななはんななだいなんなくならべてながながめ
4
+
5
+ Get your Nya!
6
+
7
+ ## Installation
8
+
9
+ ``` sh
10
+ gem install sawarineko
11
+ ```
12
+
13
+ Or add this line to your application's Gemfile:
14
+
15
+ ``` ruby
16
+ gem 'sawarineko'
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it (https://github.com/yous/sawarineko/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
30
+
31
+ ## License
32
+
33
+ Copyright (c) ChaYoung You. See [LICENSE.txt](LICENSE.txt) for further details.
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+
3
+ require 'bundler/gem_tasks'
data/bin/sawarineko ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ $LOAD_PATH.unshift(File.expand_path('../../lib', File.realpath(__FILE__)))
5
+ require 'sawarineko'
6
+
7
+ cli = Sawarineko::CLI.new
8
+ exit cli.run
data/lib/sawarineko.rb ADDED
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+
3
+ require 'sawarineko/version'
4
+ require 'sawarineko/converter'
5
+ require 'sawarineko/option'
6
+ require 'sawarineko/cli'
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+
3
+ module Sawarineko
4
+ # Handle command line interfaces logic.
5
+ class CLI
6
+ # Initialize a CLi.
7
+ def initialize
8
+ @options = {}
9
+ end
10
+
11
+ # Entry point for the application logic. Process command line arguments and
12
+ # run the Sawarineko.
13
+ #
14
+ # args - An Array of Strings user passed.
15
+ #
16
+ # Returns an Integer UNIX exit code.
17
+ def run(args = ARGV)
18
+ @options, paths = Option.new.parse(args)
19
+ source = if paths.empty?
20
+ $stdin.read
21
+ else
22
+ IO.read(paths[0])
23
+ end
24
+ runner = Converter.new(source)
25
+ puts runner.convert
26
+ 0
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ module Sawarineko
4
+ # Convert plain text to Sawarineko text.
5
+ class Converter
6
+ # Initialize a Converter. Get a String source.
7
+ #
8
+ # source - The String source to convert.
9
+ def initialize(source)
10
+ @source = source
11
+ end
12
+
13
+ # Convert the source.
14
+ #
15
+ # Returns the String converted to Sawarineko.
16
+ def convert
17
+ @source
18
+ .gsub(/な/, 'にゃ')
19
+ .gsub(/[나-낳]/) { |ch| (ch.ord + 56).chr(Encoding::UTF_8) }
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ require 'optparse'
4
+
5
+ module Sawarineko
6
+ # Handle command line options.
7
+ class Option
8
+ # Initialize a Option.
9
+ def initialize
10
+ @options = {}
11
+ end
12
+
13
+ # Parse the passed arguments to a Hash.
14
+ #
15
+ # args - An Array of Strings containing options.
16
+ #
17
+ # Returns an Array contains of a Hash options and an Array of Strings
18
+ # remaining arguments.
19
+ def parse(args)
20
+ OptionParser.new do |opts|
21
+ opts.banner = 'Usage: sawarineko [options] [source]'
22
+
23
+ add_options(opts)
24
+ end.parse!(args)
25
+ [@options, args]
26
+ end
27
+
28
+ private
29
+
30
+ # Add command line options to OptionParser.
31
+ #
32
+ # opts - An OptionParser object to add options.
33
+ #
34
+ # Returns nothing.
35
+ def add_options(opts)
36
+ opts.on('-h', '--help', 'Print this message.') do
37
+ puts opts
38
+ exit 0
39
+ end
40
+
41
+ opts.on('-v', '--version', 'Print version.') do
42
+ puts Version::STRING
43
+ exit 0
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ module Sawarineko
4
+ # Holds Sawarineko's version information.
5
+ module Version
6
+ STRING = '0.1.0'
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'sawarineko/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'sawarineko'
9
+ spec.version = Sawarineko::Version::STRING
10
+ spec.authors = ['ChaYoung You']
11
+ spec.email = ['yousbe@gmail.com']
12
+ spec.summary = 'Get your Nya!'
13
+ spec.description = 'Get your Nya!'
14
+ spec.homepage = ''
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(/^(test|spec|features)\//)
20
+ spec.require_paths = %w(lib)
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rubocop', '~> 0.26.1'
25
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sawarineko
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - ChaYoung You
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.26.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.26.1
55
+ description: Get your Nya!
56
+ email:
57
+ - yousbe@gmail.com
58
+ executables:
59
+ - sawarineko
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rubocop.yml"
65
+ - ".rubocop_todo.yml"
66
+ - CHANGELOG.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/sawarineko
72
+ - lib/sawarineko.rb
73
+ - lib/sawarineko/cli.rb
74
+ - lib/sawarineko/converter.rb
75
+ - lib/sawarineko/option.rb
76
+ - lib/sawarineko/version.rb
77
+ - sawarineko.gemspec
78
+ homepage: ''
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.2.2
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Get your Nya!
102
+ test_files: []