From 3c2ac474f20da6baf804e5c51f62c2c8cb19c6eb Mon Sep 17 00:00:00 2001 From: davidtsadler Date: Wed, 8 Feb 2012 23:15:46 +0000 Subject: Update rake task for better creation of test posts. --- lib/random.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/random.rb (limited to 'lib/random.rb') 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 -- cgit v1.2.3-13-gbd6f