Class: ShitAviSays

Inherits:
Object
  • Object
show all
Defined in:
lib/shit_avi_says.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ ShitAviSays

Returns a new instance of ShitAviSays.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/shit_avi_says.rb', line 34

def initialize(argv)
    if argv[0] == "config"

        authorize     

    else
        File.open("cache") do |file|
            while line = file.gets
                if line == "configured"
                    puts "What shit did Avi say??"

                    
                    command = gets.chomp

                    if command
                      exec("tumblr post '#{command}' --host=http://shitavisays.tumblr.com/")          
                    end
                else
                    puts "please configure the keys - use shitavisays config on a fresh prompt"
                end
            end
        end
    end
end

Instance Method Details

#authorizeObject

end



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/shit_avi_says.rb', line 11

def authorize
    puts "What's the almighty consumer key?"
    ARGV.clear
    consumer_key = gets.chomp

    puts "What's the almighty secret key?"
    consumer_secret = gets.chomp

    # path = File.expand_path("~")

    # File.open("#{path}/.tumblr", 'w') do |file|
    #   file.write("---
    #     consumer_key: #{consumer_key}
    #     consumer_secret: #{consumer_secret}
    #     token: IJQjtsdHUjv0yYdKDdEE9Kio82VJ8IsDZYtyAEgtI1aHHW3AZb
    #     token_secret: xh6nyeHz7LJc6GLg3OEUm2wrg4EXlvVBzRKaZ5OO2QjdjLjGuP")
    # end

    File.open("cache", 'w') do |file|
      file.write("configured")
    end
end