flipit 0.0.1

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/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ == 0.0.1 2012-09-04
2
+
3
+ * Hi.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source :rubygems
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) George Ogata
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.markdown ADDED
@@ -0,0 +1,31 @@
1
+ ## Flip It
2
+
3
+ Flip tables.
4
+
5
+ ## Install
6
+
7
+ gem install flipit
8
+
9
+ ## Usage
10
+
11
+ flipit
12
+ # Then paste!
13
+
14
+ flipit your text here
15
+ # Then paste!
16
+
17
+ ## Support
18
+
19
+ Mac only. Patches welcome.
20
+
21
+ ## Contributing
22
+
23
+ * [Bug reports](https://github.com/oggy/flipit/issues)
24
+ * [Source](https://github.com/oggy/flipit)
25
+ * Patches: Fork on Github, send pull request.
26
+ * Include tests where practical.
27
+ * Leave the version alone, or bump it in a separate commit.
28
+
29
+ ## Copyright
30
+
31
+ Copyright (c) George Ogata. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'ritual'
data/bin/flipit ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'flipit'
4
+
5
+ exit Flipit::App.new(ARGV).run
data/flipit.gemspec ADDED
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.unshift File.expand_path('lib', File.dirname(__FILE__))
3
+ require 'flipit/version'
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'flipit'
7
+ gem.version = Flipit::VERSION
8
+ gem.authors = ['George Ogata']
9
+ gem.email = ['george.ogata@gmail.com']
10
+ gem.summary = "Flip tables."
11
+ gem.homepage = 'https://github.com/oggy/flipit'
12
+
13
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+
17
+ gem.add_development_dependency 'ritual', '~> 0.4.1'
18
+ end
data/lib/flipit.rb ADDED
@@ -0,0 +1,4 @@
1
+ module Flipit
2
+ autoload :App, 'flipit/app'
3
+ autoload :VERSION, 'flipit/version'
4
+ end
data/lib/flipit/app.rb ADDED
@@ -0,0 +1,106 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'optparse'
3
+ require 'open3'
4
+
5
+ module Flipit
6
+ class App
7
+ def initialize(args, output=STDOUT, error=STDERR)
8
+ @args = args
9
+ @output = output
10
+ @error = error
11
+ @print = false
12
+
13
+ parser = OptionParser.new do |parser|
14
+ parser.banner = "USAGE: flipit [options] [text ...]"
15
+ parser.separator ''
16
+ parser.separator 'Options:'
17
+ parser.on '-p', '--print' do
18
+ @print = true
19
+ end
20
+ end
21
+ parser.parse!(args)
22
+ end
23
+
24
+ attr_reader :args
25
+
26
+ def run
27
+ if args.empty?
28
+ flipped = "#{flipper} #{table}"
29
+ elsif
30
+ text = args.join(' ')
31
+ flipped = "#{flipper} #{flip(text)}"
32
+ end
33
+ if @print
34
+ @output.puts flipped
35
+ else
36
+ pbcopy(flipped)
37
+ end
38
+ 0
39
+ end
40
+
41
+ def pbcopy(string)
42
+ Open3.popen2('pbcopy') do |stdin, stdout, wait_thread|
43
+ stdin.print string
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def flipper
50
+ "(╯°□°)╯︵"
51
+ end
52
+
53
+ def table
54
+ "┻━┻"
55
+ end
56
+
57
+ def flip(text)
58
+ text.chars.map { |c| CHARS[c] || c }.reverse.join
59
+ end
60
+
61
+ CHARS = {
62
+ 'a' => 'ɐ',
63
+ 'b' => 'q',
64
+ 'c' => 'ɔ',
65
+ 'd' => 'p',
66
+ 'e' => 'ǝ',
67
+ 'f' => 'ɟ',
68
+ 'g' => 'b',
69
+ 'h' => 'ɥ',
70
+ 'i' => 'ı̣',
71
+ 'j' => 'ظ',
72
+ 'k' => 'ʞ',
73
+ 'l' => 'ן',
74
+ 'm' => 'ɯ',
75
+ 'n' => 'u',
76
+ 'o' => 'o',
77
+ 'p' => 'd',
78
+ 'q' => 'b',
79
+ 'r' => 'ɹ',
80
+ 's' => 's',
81
+ 't' => 'ʇ',
82
+ 'u' => 'n',
83
+ 'v' => 'ʌ',
84
+ 'w' => 'ʍ',
85
+ 'x' => 'x',
86
+ 'y' => 'ʎ',
87
+ 'z' => 'z',
88
+ '[' => ']',
89
+ ']' => '[',
90
+ '(' => ')',
91
+ ')' => '(',
92
+ '{' => '}',
93
+ '}' => '{',
94
+ '?' => '¿',
95
+ '\u00BF' => '?',
96
+ '!' => '¡',
97
+ "\'" => ',',
98
+ ',' => "\'",
99
+ '.' => '˙',
100
+ '_' => '‾',
101
+ ';' => '؛',
102
+ '9' => '6',
103
+ '6' => '9',
104
+ }
105
+ end
106
+ end
@@ -0,0 +1,11 @@
1
+ module Flipit
2
+ VERSION = [0, 0, 1]
3
+
4
+ class << VERSION
5
+ include Comparable
6
+
7
+ def to_s
8
+ join('.')
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ # -*- coding: utf-8 -*-
2
+ require_relative '../test_helper'
3
+
4
+ require 'stringio'
5
+
6
+ describe Flipit::App do
7
+ let(:output) { StringIO.new }
8
+ let(:error) { StringIO.new }
9
+
10
+ describe "when no arguments are given" do
11
+ it "flips a table" do
12
+ app = Flipit::App.new(['-p'], output, error)
13
+ app.run.must_equal 0
14
+ output.string.must_equal "(╯°□°)╯︵ ┻━┻\n"
15
+ error.string.must_equal ""
16
+ end
17
+ end
18
+
19
+ describe "when arguments are given" do
20
+ it "flips them" do
21
+ app = Flipit::App.new(['-p', 'my', 'life'], output, error)
22
+ app.run.must_equal 0
23
+ output.string.must_equal "(╯°□°)╯︵ ǝɟı̣ן ʎɯ\n"
24
+ error.string.must_equal ""
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ require 'minitest/spec'
3
+ require 'debugger'
4
+
5
+ ROOT = File.expand_path('..', File.dirname(__FILE__))
6
+ $:.unshift "#{ROOT}/lib"
7
+ require 'flipit'
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flipit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - George Ogata
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: ritual
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 0.4.1
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.4.1
30
+ description:
31
+ email:
32
+ - george.ogata@gmail.com
33
+ executables:
34
+ - flipit
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - CHANGELOG
39
+ - Gemfile
40
+ - LICENSE
41
+ - README.markdown
42
+ - Rakefile
43
+ - bin/flipit
44
+ - flipit.gemspec
45
+ - lib/flipit.rb
46
+ - lib/flipit/app.rb
47
+ - lib/flipit/version.rb
48
+ - test/flipit/test_app.rb
49
+ - test/test_helper.rb
50
+ homepage: https://github.com/oggy/flipit
51
+ licenses: []
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ segments:
63
+ - 0
64
+ hash: 3544380048546584056
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ segments:
72
+ - 0
73
+ hash: 3544380048546584056
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 1.8.24
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: Flip tables.
80
+ test_files:
81
+ - test/flipit/test_app.rb
82
+ - test/test_helper.rb