kimotter 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/kimotter +13 -9
  2. data/lib/kimotter.rb +6 -1
  3. metadata +2 -2
data/bin/kimotter CHANGED
@@ -1,23 +1,27 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
- # $LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
4
3
  require 'kimotter'
5
4
  require 'logger'
6
5
  require 'optparse'
7
6
 
8
7
  options = {}
9
- OptionParser.new{ |opts|
10
- opts.banner = "Usage: #{$0} [options] tweet_message"
8
+ parser = OptionParser.new{ |opts|
9
+ opts.banner = "Usage: #{File.basename($0)} [options] tweet_message"
11
10
  opts.on("-d", "--debug", "Debug Mode"){ |v|
12
11
  options[:debug_mode] = true
13
12
  }
14
13
  opts.on("-f", "--force", "Force execute, ignore api limit"){ |v|
15
14
  options[:force_execute] = true
16
15
  }
17
- }.parse!
16
+ }
17
+ parser.parse!
18
18
 
19
+ ## validate commandline arguments
19
20
  message = ARGV.shift
20
- raise "argument error" unless message
21
+ unless message
22
+ parser.help.display
23
+ exit(1)
24
+ end
21
25
 
22
26
  logger = options[:debug_mode] ? Logger.new(STDERR) : Logger.new(nil)
23
27
  kimotter = Kimotter.new(:logger => logger)
@@ -32,16 +36,16 @@ end
32
36
  print kimotter.confirm_msg + "[y/N] "
33
37
  if user_input_line = $stdin.gets
34
38
  if user_input_line =~ /^(yes|y)$/i
35
- puts "hi kimoto. try to tweet your message"
36
- puts message
39
+ puts "hi kimoto. try to tweet your cool message"
37
40
  kimotter.tweet(message)
38
- puts "done"
41
+ puts "done!"
39
42
  exit(0)
40
43
  else
41
- puts "u guys so fucking retard"
44
+ puts "your tweet went to hell on earth. god damn it"
42
45
  exit(3)
43
46
  end
44
47
  else
45
48
  puts "omg?"
46
49
  exit(2)
47
50
  end
51
+
data/lib/kimotter.rb CHANGED
@@ -73,10 +73,15 @@ class Kimotter
73
73
  end
74
74
  end
75
75
 
76
+ ## please overwrite this method if you need it
77
+ def filter(message)
78
+ message
79
+ end
80
+
76
81
  def tweet(message)
77
82
  @logger.info "try to tweet: #{message.inspect}"
78
83
  @agent.page.form_with(:action => '/twitter/'){ |form|
79
- form.field_with(:name => 'status').value = message
84
+ form.field_with(:name => 'status').value = filter(message)
80
85
  form.checkbox_with(:name => 'is_kimoto').check
81
86
  form.click_button
82
87
  }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - kimoto