summaryrefslogtreecommitdiff
path: root/lib/random.rb
blob: ecefd93e3c91df9b8e21efcd313143f81e11f7b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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).strftime('%Y-%m-%d')
    end
  end
end