personal_faker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ Hello my name is Stephanie Liu and I am here to test this new gem it's super exciting I hope it works and MJ will be super proud amirite though cool okay let's get started folks.
@@ -0,0 +1,3 @@
1
+ module PersonalFaker
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,76 @@
1
+ require "personal_faker/version"
2
+
3
+ module PersonalFaker
4
+ class Base
5
+ attr_accessor :table
6
+ attr_accessor :text
7
+ attr_accessor :file
8
+
9
+ def initialize(choose_text)
10
+ if choose_text == 'dr-seuss'
11
+ @file = 'lib/personal_faker/texts/dr-seuss.rtf'
12
+ elsif choose_text == 'pride-and-prejudice'
13
+ @file = 'lib/personal_faker/texts/pride-and-prejudice.rtf'
14
+ elsif choose_text == 'macbeth'
15
+ @file = 'lib/personal_faker/texts/macbeth.rtf'
16
+ end
17
+ end
18
+
19
+ def text
20
+ return @text unless @text.nil?
21
+ @text = File.open(@file, "r").read
22
+ @text.gsub!("\n", ' ')
23
+ @text.gsub!("\\", '')
24
+ @text.gsub!('"', '')
25
+ @text.gsub!(' ', ' ')
26
+ @text.gsub!(/[_.,!?;:]/, '')
27
+ @text.downcase!
28
+ @text.gsub!(' i ', ' I ')
29
+ end
30
+
31
+ def table
32
+ return @table unless @table.nil?
33
+ position = 0
34
+ position_of_second_word = text.index(' ', 1)
35
+ table = {}
36
+ until position_of_second_word.nil? || text.index(' ', position_of_second_word + 1).nil? do
37
+ position_of_second_word += 1
38
+ word = text[position..(position_of_second_word - 2)]
39
+ second_word = text[position_of_second_word..(text.index(' ', position_of_second_word)-1)]
40
+ table[word] ||= []
41
+ table[word] << second_word
42
+ position = position_of_second_word
43
+ position_of_second_word = text.index(' ', position + 1)
44
+ end
45
+ @table = table
46
+ end
47
+
48
+ def sentence
49
+ word = table.keys.sample.capitalize
50
+ sentence = word
51
+ 10.times do
52
+ if table[word]
53
+ word = table[word].sample
54
+ else
55
+ word = table.keys.sample
56
+ end
57
+ sentence = sentence + " " + word
58
+ end
59
+ sentence = sentence + "."
60
+ end
61
+
62
+ def question
63
+ word = table.keys.sample.capitalize
64
+ sentence = word
65
+ 10.times do
66
+ if table[word]
67
+ word = table[word].sample
68
+ else
69
+ word = table.keys.sample
70
+ end
71
+ sentence = sentence + " " + word
72
+ end
73
+ sentence = sentence + "?"
74
+ end
75
+ end
76
+ end
Binary file
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'personal_faker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "personal_faker"
8
+ spec.version = PersonalFaker::VERSION
9
+ spec.authors = ["Stephanie Liu"]
10
+ spec.email = ["sliu14@outlook.com"]
11
+
12
+ spec.summary = %q{Fake info in your own personal way!}
13
+ spec.description = %q{Input a text of your own choosing, and fake data will be created that mimics that text}
14
+ spec.homepage = "https://github.com/sliuu/personal_faker"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+ spec.add_development_dependency "pry"
34
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: personal_faker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephanie Liu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-07 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.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
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: 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: pry
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
+ description: Input a text of your own choosing, and fake data will be created that
70
+ mimics that text
71
+ email:
72
+ - sliu14@outlook.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - CODE_OF_CONDUCT.md
81
+ - Gemfile
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/.DS_Store
88
+ - lib/personal_faker.rb
89
+ - lib/personal_faker/.DS_Store
90
+ - lib/personal_faker/base.rb
91
+ - lib/personal_faker/texts/dr-seuss.rtf
92
+ - lib/personal_faker/texts/macbeth.rtf
93
+ - lib/personal_faker/texts/pride-and-prejudice.rtf
94
+ - lib/personal_faker/texts/simple_text.rtf
95
+ - lib/personal_faker/version.rb
96
+ - personal_faker-0.0.4.gem
97
+ - personal_faker.gemspec
98
+ homepage: https://github.com/sliuu/personal_faker
99
+ licenses:
100
+ - MIT
101
+ metadata:
102
+ allowed_push_host: https://rubygems.org
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.4.7
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Fake info in your own personal way!
123
+ test_files: []
124
+ has_rdoc: