womanizer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 65250b2f9de5991fddbe21a03db1eef5fc9e8d76
4
+ data.tar.gz: c080822edd0b1f3898d25d92b4136ec426112a5c
5
+ SHA512:
6
+ metadata.gz: 9987d1032183c2c481b1807371ea654d6a63edbc8968a5d026f14d149e609ce3b62e9629a2dd535591672ad900657227d71494871aa9cab821716369fe2b09aa
7
+ data.tar.gz: f9b321536bc9567473763dca529ab54b942ef79430303bfbd2b5f0cc3de70f570eacd16941996069f78833456a6da1a4182590ab05826c97da1f39b26e5b68ab
@@ -0,0 +1,4 @@
1
+ Gemfile.lock
2
+ log/*.log
3
+ tmp/
4
+ *.gem
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1 @@
1
+ womanizer
@@ -0,0 +1 @@
1
+ ruby-2.0.0-p451
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
@@ -0,0 +1,13 @@
1
+ group 'develop' do
2
+ guard 'bundler' do
3
+ watch('Gemfile')
4
+ # Uncomment next line if Gemfile contain `gemspec' command
5
+ # watch(/^.+\.gemspec/)
6
+ end
7
+
8
+ guard 'rspec', :version => 2 do
9
+ watch(%r{^spec/.+_spec\.rb$})
10
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
11
+ watch('spec/spec_helper.rb') { "spec" }
12
+ end
13
+ end
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2009 Nathan Weizenbaum
2
+
3
+ Permission is hereby granted, free of charge, to any person [1] 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.
21
+
22
+ [1] "person" includes natural persons and non-military institutions and
23
+ coorperations.
@@ -0,0 +1,24 @@
1
+ == We need more women in tech ==
2
+
3
+ Here is a technical approach:
4
+
5
+
6
+ require 'womanizer'
7
+ Womanizer.ok!
8
+
9
+ ok moREWoman moREWoMaN moREWoMan moREWomAN morEwoman morEwomAn moRewOman moREwoMaN moREwOMan moREwOMan moREwOMAN morEwoman moReWoMAN moREwOMAN moREWomAn moREwOMan moREwoMan morEwomaN morEwomAn morewOmAn
10
+
11
+ Run it and it outputs `Hello world`.
12
+
13
+ You can get "morewoman" by piping to the binary
14
+
15
+ $ womanizer encode < mylib.rb
16
+
17
+
18
+ = FAQ =
19
+
20
+ * Why that punning name and premise? Are you a sexist?
21
+
22
+ I try my best not to be. The premise stems from the obvious frustration of the community to increase the number of female(\*) humans in tech and other industries. I personally feel kind of powerless to change this in any significant amount by myself -- so I escape into humor to cope with that. By my definition, a "womanizer" is a person who tries to achieve his goals always in the same way with only small variations -- and looks rather stupid doing that. In that way this gem is similar.
23
+
24
+ Additionally all other names that came to my mind were already taken.
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path('../../lib', __FILE__)
4
+ require 'womanizer'
5
+ w = Womanizer.new
6
+
7
+ case action = ARGV.shift
8
+ when 'encode'
9
+ puts w.encode $<.read
10
+ when 'decode'
11
+ puts w.decode $<.read
12
+ when 'run'
13
+ w.define!
14
+ eval $<.read
15
+ else
16
+ raise ArgumentError, "bad action: #{action}, must be run, encode or decode"
17
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path('../../lib', __FILE__)
4
+ require 'womanizer'
5
+ Womanizer.ok!
6
+
7
+ ok moREWoman moREWoMaN moREWoMan moREWomAN morEwoman morEwomAn moRewOman moREwoMaN moREwOMan moREwOMan moREwOMAN morEwoman moReWoMAN moREwOMAN moREWomAn moREwOMan moREwoMan morEwomaN morEwomAn morewOmAn
8
+
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ class Womanizer
4
+ VERSION = '0.1.0'
5
+
6
+ def self.ok!(*a)
7
+ $womanizer = Womanizer.new(*a)
8
+ $womanizer.define!
9
+ end
10
+
11
+ def initialize(words=['morewoman', 'morewomen'])
12
+ words = words.map(&:downcase).uniq
13
+
14
+ raise ArgumentError, 'needs words with length of at least 8' if words.any? { |w| w.length < 8 }
15
+
16
+ @enc = []
17
+ @dec = {}
18
+
19
+ chars = 0.upto(255).each
20
+
21
+ begin
22
+ words.each do |word|
23
+ l = word.length
24
+ f = "%0#{l}d"
25
+ 0.upto(2**l) do |i|
26
+ o = chars.next
27
+ b = (f % i.to_s(2)).chars.map(&:to_i)
28
+ t = word.chars.zip(b).map do |c, u|
29
+ if u.zero?
30
+ c
31
+ else
32
+ c.upcase
33
+ end
34
+ end.join
35
+ @enc[o] = t
36
+ @dec[t] = o
37
+
38
+ debug { "#{o} => #{t}" }
39
+ end
40
+ end
41
+ rescue StopIteration
42
+ #done
43
+ end
44
+ end
45
+ def encode(source)
46
+ source.each_byte.map { |b| @enc[b] }.join(' ')
47
+ end
48
+
49
+ def decode(encoded)
50
+ encoded.split(/\s+/).map { |t| @dec.fetch(t) }.pack('C*').
51
+ force_encoding(Encoding.default_external)
52
+ end
53
+
54
+ def define!
55
+ @dec.each do |t,c|
56
+ Kernel.send(:define_method, t) {|r=''| [c].pack('C')+r }
57
+ end
58
+ Kernel.send(:alias_method, 'ok', 'eval')
59
+ end
60
+
61
+ private
62
+
63
+ def debug
64
+ if $DEBUG
65
+ STDERR.puts yield
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+ require 'womanizer'
3
+
4
+ describe Womanizer do
5
+ let(:text) { 'Kleine Kinder können keine kleinen Kirschkerne knacken' }
6
+ let(:encoded) { subject.encode(text) }
7
+ let(:words) { encoded.split }
8
+ it 'encodes every letter into a case variation' do
9
+ words.should have(text.bytes.length).items
10
+ words.each do |w|
11
+ w.should match(/\Amorewom[ae]n\z/i)
12
+ end
13
+ end
14
+
15
+ it 'decodes' do
16
+ recoded = subject.decode( encoded )
17
+ recoded.should == text
18
+ end
19
+
20
+ it 'is ruby' do
21
+ subject.define!
22
+ foo = 23
23
+ res = ok moREwoMAn moREwOMAN moREwOMAN
24
+ res.should == 23
25
+ end
26
+ end
@@ -0,0 +1,37 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $LOAD_PATH.push File.expand_path("lib", File.dirname(__FILE__))
3
+ require 'womanizer'
4
+
5
+ Gem::Specification.new do |s|
6
+
7
+ s.name = "womanizer"
8
+ s.version = Womanizer::VERSION
9
+ s.platform = Gem::Platform::RUBY
10
+ s.authors = ["Niklas Hofer"]
11
+ s.email = ["niklas+womanizer@lanpartei.de"]
12
+ s.homepage = "https://github.com/niklas/womanizer"
13
+ s.summary = 'More women in tech'
14
+ s.description = <<-EODES
15
+ Allows to encode your ruby using your favourite words.
16
+
17
+ It is similar to the Acme::Buffy, but configurable.
18
+
19
+ Feel offended? Read the fine FAQ.
20
+ EODES
21
+
22
+ s.add_development_dependency 'pry', '~> 0'
23
+ s.add_development_dependency 'libnotify', '~> 0'
24
+ s.add_development_dependency 'rspec', '~> 0'
25
+ s.add_development_dependency 'guard-rspec', '~> 0'
26
+ s.add_development_dependency 'guard', '~> 0'
27
+ s.add_development_dependency 'guard-bundler', '~> 0'
28
+
29
+ s.has_rdoc = false
30
+ s.extra_rdoc_files = ["README.md"]
31
+ s.rdoc_options = ["--charset=UTF-8"]
32
+ s.files = `git ls-files `.split("\n")
33
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
34
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
35
+ s.require_paths = ["lib"]
36
+
37
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: womanizer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Niklas Hofer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: libnotify
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: |2
98
+ Allows to encode your ruby using your favourite words.
99
+
100
+ It is similar to the Acme::Buffy, but configurable.
101
+
102
+ Feel offended? Read the fine FAQ.
103
+ email:
104
+ - niklas+womanizer@lanpartei.de
105
+ executables:
106
+ - womanizer
107
+ extensions: []
108
+ extra_rdoc_files:
109
+ - README.md
110
+ files:
111
+ - ".gitignore"
112
+ - ".rspec"
113
+ - ".ruby_gemset"
114
+ - ".ruby_version"
115
+ - Gemfile
116
+ - Guardfile
117
+ - LICENSE
118
+ - README.md
119
+ - bin/womanizer
120
+ - demo/hello.rb
121
+ - lib/womanizer.rb
122
+ - spec/womanizer_spec.rb
123
+ - womanizer.gemspec
124
+ homepage: https://github.com/niklas/womanizer
125
+ licenses: []
126
+ metadata: {}
127
+ post_install_message:
128
+ rdoc_options:
129
+ - "--charset=UTF-8"
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.2.2
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: More women in tech
148
+ test_files: []
149
+ has_rdoc: false