summaryrefslogtreecommitdiff
path: root/lib/random.rb
diff options
context:
space:
mode:
authordavidtsadler <davidtsadler@googlemail.com>2012-02-08 23:15:46 +0000
committerdavidtsadler <davidtsadler@googlemail.com>2012-02-08 23:15:46 +0000
commit3c2ac474f20da6baf804e5c51f62c2c8cb19c6eb (patch)
tree743001d97c34d2f963ad20b01c60c2c3adb09895 /lib/random.rb
parent1dcb61ea904e901548deba046016661e23a1f12f (diff)
Update rake task for better creation of test posts.
Diffstat (limited to 'lib/random.rb')
-rw-r--r--lib/random.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/random.rb b/lib/random.rb
new file mode 100644
index 0000000..9204138
--- /dev/null
+++ b/lib/random.rb
@@ -0,0 +1,31 @@
+module TestPosts
+ module Random
+ APPLICATIONS = ['Apache 2', 'MySQL', 'Sqlite', 'Magento']
+
+ DISTROS = ['Ubuntu', 'Fedora', 'Kubuntu', 'Mythbuntu', 'SUSE Linux', 'Debian']
+
+ FRAMEWORKS = ['Ruby on Rails', 'CakePHP', 'Wordpress', 'Sinatra', 'Drupal']
+
+ LANGUAGES = ['Actionscript', 'Ada', 'Assembly', 'C', 'C#', 'C++', 'Cobol', 'ColdFusion', 'D', 'Delphi', 'Erlang', 'Forth', 'Fortran', 'Haskell', 'Java', 'JavaScript', 'Lisp', 'Lua', 'OCaml', 'Objective C', 'PHP', 'Pascal', 'Perl', 'Python', 'Rexx', 'Ruby', 'SQL', 'Scala', 'Scheme', 'Shell', 'Smalltalk', 'Tcl', 'Visual Basic']
+
+ TITLES = [
+ [['Getting started with', 'A tutorial on', 'Why I like', "Why I don't like", 'Developing applications with'], LANGUAGES + FRAMEWORKS],
+ [['Getting started with', 'How to install', 'How to upgrade'], DISTROS + APPLICATIONS + FRAMEWORKS],
+ [['Developing a plugin for'], FRAMEWORKS]
+ ]
+
+ def self.generate
+ topics, subjects = TITLES[rand(TITLES.size)]
+ topic = topics[rand(topics.size)]
+ subject = subjects[rand(subjects.size)]
+ [date, topic + ' ' + subject, subject]
+ end
+
+ private
+ def self.date
+ jdFrom = Date.today.prev_year.jd
+ jdTo = Date.today.jd
+ Date.jd(rand((jdTo + 1) - jdFrom) + jdFrom)
+ end
+ end
+end