wordini 0.0.0

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/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'rspec'
data/Gemfile.lock ADDED
@@ -0,0 +1,18 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.3)
5
+ rspec (2.10.0)
6
+ rspec-core (~> 2.10.0)
7
+ rspec-expectations (~> 2.10.0)
8
+ rspec-mocks (~> 2.10.0)
9
+ rspec-core (2.10.1)
10
+ rspec-expectations (2.10.0)
11
+ diff-lcs (~> 1.1.3)
12
+ rspec-mocks (2.10.1)
13
+
14
+ PLATFORMS
15
+ ruby
16
+
17
+ DEPENDENCIES
18
+ rspec
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
data/lib/wordini.rb ADDED
@@ -0,0 +1,14 @@
1
+ class Wordini
2
+
3
+ def self.obfuscate(word_string, words_to_remove)
4
+ split_words = word_string.split.map{ |word|
5
+ if words_to_remove.include? word
6
+ word = "*" * word.split('').count
7
+ else
8
+ word = word
9
+ end
10
+ }.join(' ')
11
+ end
12
+
13
+ #puts self.obfuscate("This is the most awesome way to run some awesome game", ["This", "awesome", "fun", "the"])
14
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'wordini'
4
+
5
+ Rspec.configure do |config|
6
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Wordini do
4
+ describe "#obfuscator" do
5
+
6
+ before(:each) do
7
+ @word_string = "this string is an awesome string"
8
+ @words_to_remove = ["this", "is", "not", "a", "string"]
9
+ end
10
+
11
+ it "takes a string as the first argument" do
12
+ Wordini.obfuscate(@word_string, @words_to_remove)
13
+ @word_string.should be_an_instance_of(String)
14
+ end
15
+
16
+ it "takes an string or array as the second argument" do
17
+ Wordini.obfuscate(@word_string, @words_to_remove)
18
+ @words_to_remove.should be_an_instance_of(Array)
19
+ end
20
+
21
+ it "does not take other first arguments besides a string" do
22
+ @word_string = ["cow"]
23
+ lambda {Wordini.obfuscate(@word_string, @words_to_remove)}.should raise_error
24
+ end
25
+
26
+ it "does not take other second arguments besides an array or string" do
27
+ @words_to_remove = 8
28
+ lambda {Wordini.obfuscate(@word_string, @words_to_remove)}.should raise_error
29
+ end
30
+
31
+ it "maintains the same number of 'words' in string" do
32
+ new_string = Wordini.obfuscate(@word_string, @words_to_remove)
33
+ new_string.split.count.should == 6
34
+ end
35
+
36
+ it "replaces the chosen words with *" do
37
+ new_string = Wordini.obfuscate(@word_string, @words_to_remove)
38
+ split_array = new_string.split('')
39
+ remaining_char = split_array - ["*"]
40
+ remaining_char.count.should == 14
41
+ end
42
+
43
+ it "contains replaced words with equivalent * count for word_char" do
44
+ new_string = Wordini.obfuscate(@word_string, @words_to_remove)
45
+ split_array = new_string.split('')
46
+ count = split_array.select{ |star| star == '*' }.size
47
+ count.should == 18
48
+ end
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wordini
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Dennis
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-14 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Gives word_count and obfuscates strings
15
+ email: adennis@groupon.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/wordini.rb
21
+ - spec/spec_helper.rb
22
+ - spec/wordini_spec.rb
23
+ - Gemfile
24
+ - Gemfile.lock
25
+ - Rakefile
26
+ homepage: http://rubygems.org/gems/wordini
27
+ licenses: []
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 1.8.24
47
+ signing_key:
48
+ specification_version: 3
49
+ summary: Obfuscates and Reports strings
50
+ test_files: []