kimotter 0.0.7 → 0.0.8

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 +2 -60
  2. data/lib/kimotter.rb +1 -0
  3. metadata +2 -2
data/bin/kimotter CHANGED
@@ -1,64 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
  # encoding: utf-8
3
- require 'kimotter'
4
- require 'logger'
5
- require 'optparse'
6
- require 'tempfile'
3
+ require 'kimotter_cli'
7
4
 
8
- options = {}
9
- parser = OptionParser.new{ |opts|
10
- opts.banner = "Usage: #{File.basename($0)} [options] [tweet_message]"
11
- opts.on("-d", "--debug", "Debug Mode"){ |v|
12
- options[:debug_mode] = true
13
- }
14
- opts.on("-f", "--force", "Force execute, ignore api limit"){ |v|
15
- options[:force_execute] = true
16
- }
17
- opts.on("-a", "--api=URL", "API Endpoint URL"){ |url|
18
- options[:api_endpoint] = url
19
- }
20
- }
21
- parser.parse!
22
-
23
- message = ARGV.shift
24
- unless message
25
- file = Tempfile.new('foo')
26
- file.close
27
-
28
- unless system(ENV['EDITOR'], file.path)
29
- raise "system command aborted"
30
- end
31
- message = File.read(file.path).chomp.gsub(/\n/, " ")
32
- end
33
-
34
- if message.empty?
35
- raise "please input message"
36
- end
37
-
38
- logger = options[:debug_mode] ? Logger.new(STDERR) : Logger.new(nil)
39
- api = options[:api_endpoint] || "http://api.ma.la/twitter/"
40
- kimotter = Kimotter.new(:api => api, :logger => logger)
41
-
42
- kimotter.fetch_api_limit
43
- if !options[:force_execute] and kimotter.api_limit?
44
- puts "u cant use this api now(api limit)"
45
- puts "try again later or retry with --force option (ignore API limit)"
46
- exit(1)
47
- end
48
-
49
- print kimotter.confirm_msg + "[y/N] "
50
- if user_input_line = $stdin.gets
51
- if user_input_line =~ /^(yes|y)$/i
52
- puts "hi kimoto. try to tweet your cool message"
53
- kimotter.tweet(message)
54
- puts "done!"
55
- exit(0)
56
- else
57
- puts "your tweet went to hell on earth. god damn it"
58
- exit(3)
59
- end
60
- else
61
- puts "omg?"
62
- exit(2)
63
- end
5
+ KimotterCLI.execute
64
6
 
data/lib/kimotter.rb CHANGED
@@ -92,3 +92,4 @@ class Kimotter
92
92
  (@api_limit.used >= @api_limit.limit)
93
93
  end
94
94
  end
95
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 7
9
- version: 0.0.7
8
+ - 8
9
+ version: 0.0.8
10
10
  platform: ruby
11
11
  authors:
12
12
  - kimoto