shiny_wookie 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWQ3Y2Q1ZTc0NmRjNTAzODE2Yzk5YTVhNWUyYmQ0ODQyZjNmNmQyMA==
5
+ data.tar.gz: !binary |-
6
+ NzhmMzdiOTg3NTYzMDUxMzA2ZTVhMTQ1MmE1NDRiMjczNTIwY2M0MQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MmZlMWE0NTk2YTcyNzM0MDQ0ZmM5N2Q5OTJkZjliMWQ3NGMwZGVhOTEwMzY5
10
+ NzRmNWFlYzVlMTc4ZTZlOGJkNDYyZjNhMjQxNTViM2E5Yjc0ODg4MDczY2Q5
11
+ NDgzYmNmNzE1ZWQ0MjEzOTQwOGFkMmY5MjViZmU4OTQ1MGQ2YWU=
12
+ data.tar.gz: !binary |-
13
+ NzI3NTFjNDk3NDYzYTZjODUyZGIxNmFlN2YyMTY3ZTMxNGJiN2RjMTM2Yzg0
14
+ NWU2MzUzOWZlOTI4NWU2NGFiOTU3NTBmZGFmM2U2NjVmYTBiODAxMjFiMGVl
15
+ YjhiYzk3MGQ2YTgwNTYwNDlmMjkxNmExZmMzYTYxYjdhMWVkOWU=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-19mode
5
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shiny_wookie.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Kristof Vannotten
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # ShinyWookie
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'shiny_wookie'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install shiny_wookie
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
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 new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/shiny_wookie ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'shiny_wookie'
5
+
6
+ $stdout.sync = true
7
+
8
+ amount = 1
9
+
10
+ options = OptionParser.new do |o|
11
+ o.banner =
12
+ "Usage: shiny_wookie [options] \n\n"
13
+
14
+ o.on("-a", "--amount X", "generate X documents") do |k|
15
+ amount = k.to_i
16
+ end
17
+
18
+ o.on('-h', "--help", "show this help") { puts o; exit }
19
+ end
20
+
21
+ begin
22
+ args = options.parse!
23
+
24
+ documents = ShinyWookie::generate_documents amount
25
+
26
+ documents.each_with_index do |document, index|
27
+ document.write_to_file :prefix => "cv_", :name => Time.now.strftime("%Y_%m_%d_%s"), :suffix => "_#{index}"
28
+ end
29
+ rescue OptionParser::MissingArgument
30
+ puts "I don't understand what you mean :-("
31
+ puts
32
+ puts options
33
+ end
34
+
@@ -0,0 +1,35 @@
1
+ require 'gabbler'
2
+
3
+ module ShinyWookie
4
+ class Document
5
+ attr_accessor :content
6
+
7
+ def initialize
8
+ @content = generate_content
9
+ end
10
+
11
+ def write_to_file *args
12
+ options = args.last.is_a?(Hash) ? args.last : {}
13
+
14
+ prefix = (options.member?(:prefix) ? options[:prefix] : "")
15
+ name = (options.member?(:name) ? options[:name] : nil)
16
+ suffix = (options.member?(:suffix) ? options[:suffix] : "")
17
+ extension = (options.member?(:extension) ? options[:extension] : "txt")
18
+
19
+ raise ArgumentError if name.nil?
20
+
21
+ File.open("#{prefix}#{name}#{suffix}.#{extension}", "w") { |f| f.write @content }
22
+ end
23
+
24
+ private
25
+
26
+ def generate_content
27
+ sentences = rand(10..100)
28
+ @content = ShinyWookie.gabbler.sentence
29
+ sentences.times { @content << ShinyWookie.gabbler.sentence << " " }
30
+
31
+ @content
32
+ end
33
+
34
+ end
35
+ end
@@ -0,0 +1,3 @@
1
+ module ShinyWookie
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ require "shiny_wookie/version"
2
+ require "shiny_wookie/document"
3
+
4
+ module ShinyWookie
5
+
6
+ def self.generate_documents amount = 1
7
+ documents = []
8
+
9
+ return [] if amount.to_i < 1
10
+
11
+ 0.upto amount.to_i do
12
+ documents << Document.new
13
+ end
14
+
15
+ documents
16
+ end
17
+
18
+ def self.gabbler
19
+ if @gabbler.nil?
20
+ @gabbler = Gabbler.new
21
+ story_file = File.join(File.dirname(File.expand_path(__FILE__)), '../resources/huckleberry.txt')
22
+ story = File.read(story_file)
23
+ gabbler.learn story
24
+ end
25
+
26
+ @gabbler
27
+ end
28
+
29
+ end