atig 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -0
  3. data/.travis.yml +3 -2
  4. data/Gemfile +2 -0
  5. data/README.mkdn +2 -0
  6. data/Rakefile +0 -6
  7. data/atig.gemspec +21 -20
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/{bin → exe}/atig +0 -0
  11. data/lib/atig/agent/agent.rb +4 -4
  12. data/lib/atig/agent/dm.rb +4 -4
  13. data/lib/atig/agent/following.rb +3 -3
  14. data/lib/atig/agent/list.rb +2 -2
  15. data/lib/atig/agent/list_status.rb +6 -6
  16. data/lib/atig/agent/stream_follow.rb +2 -2
  17. data/lib/atig/agent/user_stream.rb +3 -3
  18. data/lib/atig/basic_twitter.rb +1 -3
  19. data/lib/atig/bitly.rb +1 -1
  20. data/lib/atig/channel/channel.rb +1 -1
  21. data/lib/atig/channel/list.rb +3 -3
  22. data/lib/atig/channel/retweet.rb +1 -1
  23. data/lib/atig/channel/timeline.rb +1 -1
  24. data/lib/atig/command/autofix.rb +4 -4
  25. data/lib/atig/command/destroy.rb +1 -1
  26. data/lib/atig/command/dm.rb +2 -2
  27. data/lib/atig/command/favorite.rb +1 -1
  28. data/lib/atig/command/info.rb +2 -2
  29. data/lib/atig/command/reply.rb +2 -2
  30. data/lib/atig/command/retweet.rb +2 -2
  31. data/lib/atig/command/search.rb +2 -2
  32. data/lib/atig/command/status.rb +3 -3
  33. data/lib/atig/command/user.rb +3 -3
  34. data/lib/atig/command/version.rb +3 -3
  35. data/lib/atig/db/followings.rb +5 -6
  36. data/lib/atig/db/statuses.rb +12 -10
  37. data/lib/atig/db/transaction.rb +1 -1
  38. data/lib/atig/gateway/channel.rb +1 -2
  39. data/lib/atig/gateway/session.rb +13 -13
  40. data/lib/atig/http.rb +4 -4
  41. data/lib/atig/ifilter/expand_url.rb +1 -1
  42. data/lib/atig/ifilter/retweet.rb +1 -1
  43. data/lib/atig/ifilter/retweet_time.rb +1 -1
  44. data/lib/atig/ifilter/sanitize.rb +1 -1
  45. data/lib/atig/ifilter/strip.rb +1 -1
  46. data/lib/atig/ifilter/xid.rb +1 -1
  47. data/lib/atig/oauth.rb +3 -3
  48. data/lib/atig/ofilter/escape_url.rb +1 -1
  49. data/lib/atig/ofilter/footer.rb +1 -1
  50. data/lib/atig/ofilter/geo.rb +1 -1
  51. data/lib/atig/ofilter/short_url.rb +1 -1
  52. data/lib/atig/option.rb +1 -1
  53. data/lib/atig/optparse.rb +22 -11
  54. data/lib/atig/search.rb +4 -2
  55. data/lib/atig/stream.rb +1 -1
  56. data/lib/atig/twitter.rb +5 -4
  57. data/lib/atig/update_checker.rb +2 -2
  58. data/lib/atig/url_escape.rb +1 -1
  59. data/lib/atig/version.rb +1 -1
  60. data/lib/memory_profiler.rb +1 -1
  61. data/spec/command/autofix_spec.rb +7 -8
  62. data/spec/command/destroy_spec.rb +12 -13
  63. data/spec/command/dm_spec.rb +5 -6
  64. data/spec/command/favorite_spec.rb +11 -12
  65. data/spec/command/limit_spec.rb +6 -7
  66. data/spec/command/location_spec.rb +4 -5
  67. data/spec/command/name_spec.rb +2 -3
  68. data/spec/command/option_spec.rb +28 -29
  69. data/spec/command/refresh_spec.rb +3 -4
  70. data/spec/command/reply_spec.rb +22 -23
  71. data/spec/command/retweet_spec.rb +17 -18
  72. data/spec/command/spam_spec.rb +4 -5
  73. data/spec/command/status_spec.rb +19 -20
  74. data/spec/command/thread_spec.rb +20 -21
  75. data/spec/command/time_spec.rb +18 -21
  76. data/spec/command/uptime_spec.rb +17 -18
  77. data/spec/command/user_info_spec.rb +13 -16
  78. data/spec/command/user_spec.rb +13 -14
  79. data/spec/command/version_spec.rb +25 -29
  80. data/spec/command/whois_spec.rb +25 -26
  81. data/spec/command_helper.rb +2 -2
  82. data/spec/db/followings_spec.rb +22 -23
  83. data/spec/db/listenable_spec.rb +2 -3
  84. data/spec/db/lists_spec.rb +16 -17
  85. data/spec/db/roman_spec.rb +3 -5
  86. data/spec/db/sized_uniq_array_spec.rb +13 -14
  87. data/spec/db/statuses_spec.rb +69 -70
  88. data/spec/ifilter/expand_url_spec.rb +18 -20
  89. data/spec/ifilter/retweet_spec.rb +4 -5
  90. data/spec/ifilter/retweet_time_spec.rb +4 -5
  91. data/spec/ifilter/sanitize_spec.rb +5 -6
  92. data/spec/ifilter/sid_spec.rb +6 -7
  93. data/spec/ifilter/strip_spec.rb +3 -4
  94. data/spec/ifilter/tid_spec.rb +6 -7
  95. data/spec/levenshtein_spec.rb +2 -3
  96. data/spec/ofilter/escape_url_spec.rb +13 -14
  97. data/spec/ofilter/footer_spec.rb +10 -11
  98. data/spec/ofilter/geo_spec.rb +12 -13
  99. data/spec/ofilter/short_url_spec.rb +28 -29
  100. data/spec/option_spec.rb +23 -24
  101. data/spec/sized_hash_spec.rb +5 -6
  102. data/spec/spec_helper.rb +8 -6
  103. data/spec/update_checker_spec.rb +14 -15
  104. metadata +9 -32
  105. data/docs/_static/allow.png +0 -0
  106. data/docs/_static/emacs.png +0 -0
  107. data/docs/_static/irc_setting.png +0 -0
  108. data/docs/_static/irssi.png +0 -0
  109. data/docs/_static/limechat.png +0 -0
  110. data/docs/_static/limechat_s.png +0 -0
  111. data/docs/_static/oauth_channel.png +0 -0
  112. data/docs/_static/screenshot.png +0 -0
  113. data/docs/_static/structure.png +0 -0
  114. data/docs/_static/verify.png +0 -0
  115. data/docs/changelog.rst +0 -233
  116. data/docs/commandline_options.rst +0 -21
  117. data/docs/commands.rst +0 -84
  118. data/docs/conf.py +0 -194
  119. data/docs/config.rst +0 -159
  120. data/docs/feature.rst +0 -41
  121. data/docs/hacking_guide.rst +0 -43
  122. data/docs/index.rst +0 -102
  123. data/docs/irc.rst +0 -31
  124. data/docs/options.rst +0 -76
  125. data/docs/quickstart.rst +0 -96
  126. data/docs/resize.sh +0 -7
  127. data/docs/tiarra.rst +0 -2
  128. data/docs/tig.rst +0 -21
  129. data/requirements.txt +0 -5
@@ -23,10 +23,10 @@ module Atig
23
23
 
24
24
  chars = text.each_char.to_a
25
25
  if chars.size > 140 then
26
- url = @bitly.shorten "http://twitter.com/#{entry.user.screen_name}/status/#{entry.status.id}"
26
+ url = @bitly.shorten "https://twitter.com/#{entry.user.screen_name}/status/#{entry.status.id}"
27
27
  text = chars[0,140-url.size-1].join('') + ' ' + url
28
28
  end
29
- q = gateway.output_message(:status => text)
29
+ q = gateway.output_message(status: text)
30
30
  api.delay(0) do|t|
31
31
  ret = t.post("statuses/update", q)
32
32
  gateway.update_status ret,target, "RT to #{entry.user.screen_name}: #{entry.status.text}"
@@ -17,7 +17,7 @@ module Atig
17
17
  end
18
18
 
19
19
  q = mesg.sub(/^#{command}\s+/, '')
20
- opts = { :q => q }
20
+ opts = { q: q }
21
21
  while /^:(?:(lang)=(\w+))/ =~ args.first
22
22
  opts[$1] = $2
23
23
  q.sub!(/^#{args.first}\W+/, "")
@@ -35,7 +35,7 @@ module Atig
35
35
  db.statuses.transaction do|d|
36
36
  user = TwitterStruct.make('id' => status.from_user_id,
37
37
  'screen_name' => status.from_user)
38
- d.add :status => status, :user => user, :source => :user
38
+ d.add status: status, user: user, source: :user
39
39
  end
40
40
  end
41
41
 
@@ -15,14 +15,14 @@ module Atig
15
15
  return
16
16
  end
17
17
  text = mesg.split(" ", 2)[1]
18
- previous,*_ = db.statuses.find_by_user( db.me, :limit => 1)
18
+ previous,*_ = db.statuses.find_by_user( db.me, limit: 1)
19
19
  if previous and
20
20
  ((::Time.now - ::Time.parse(previous.status.created_at)).to_i < 60*60*24 rescue true) and
21
21
  text.strip == previous.status.text.strip
22
22
  yield "You can't submit the same status twice in a row."
23
23
  return
24
24
  end
25
- q = gateway.output_message(:status => text)
25
+ q = gateway.output_message(status: text)
26
26
 
27
27
  case tweet_invalid? q[:status]
28
28
  when :too_long
@@ -33,7 +33,7 @@ module Atig
33
33
  return
34
34
  end
35
35
 
36
- api.delay(0, :retry=>3) do|t|
36
+ api.delay(0, retry:3) do|t|
37
37
  ret = t.post("statuses/update", q)
38
38
  gateway.update_status ret,target
39
39
  end
@@ -20,15 +20,15 @@ module Atig
20
20
  api.delay(0) do|t|
21
21
  begin
22
22
  statuses = t.get("statuses/user_timeline",
23
- { :count => count, :screen_name => nick})
23
+ { count: count, screen_name: nick})
24
24
  statuses.reverse_each do|status|
25
25
  db.statuses.transaction do|d|
26
- d.add :status => status, :user => status.user, :source => :user
26
+ d.add status: status, user: status.user, source: :user
27
27
  end
28
28
  end
29
29
 
30
30
  db.statuses.
31
- find_by_screen_name(nick, :limit=>count).
31
+ find_by_screen_name(nick, limit:count).
32
32
  reverse_each do|entry|
33
33
  gateway[target].message entry, Net::IRC::Constants::NOTICE
34
34
  end
@@ -15,7 +15,7 @@ module Atig
15
15
  end
16
16
  nick,*_ = args
17
17
 
18
- entries = db.statuses.find_by_screen_name(nick, :limit => 1)
18
+ entries = db.statuses.find_by_screen_name(nick, limit: 1)
19
19
  if entries && !entries.empty? then
20
20
  entry = TwitterStruct.make('user' => entries.first.user,
21
21
  'status' => { 'text' =>
@@ -24,9 +24,9 @@ module Atig
24
24
  else
25
25
  api.delay(0) do|t|
26
26
  begin
27
- user = t.get("users/show", { :screen_name => nick})
27
+ user = t.get("users/show", { screen_name: nick})
28
28
  db.statuses.transaction do|d|
29
- d.add :user => user, :status => user.status, :source => :version
29
+ d.add user: user, status: user.status, source: :version
30
30
  entry = TwitterStruct.make('user' => user,
31
31
  'status' => { 'text' =>
32
32
  format(user.status.source) })
@@ -83,7 +83,6 @@ module Atig
83
83
  }
84
84
 
85
85
  names = users.map{|u| u.screen_name.inspect }.join(",")
86
- parts =
87
86
  may_notify :part, db.execute(%{SELECT screen_name,data FROM users
88
87
  WHERE screen_name NOT IN (#{names})}).map{|_,data|
89
88
  @db.load(data)
@@ -109,11 +108,11 @@ module Atig
109
108
  else
110
109
  db.execute("INSERT INTO users
111
110
  VALUES(NULL, :screen_name, :user_id, :protected, :only, :data)",
112
- :screen_name => user.screen_name,
113
- :user_id => user.id,
114
- :protected => bool(user.protected),
115
- :only => bool(user.only),
116
- :data => @db.dump(user))
111
+ screen_name: user.screen_name,
112
+ user_id: user.id,
113
+ protected: bool(user.protected),
114
+ only: bool(user.only),
115
+ data: @db.dump(user))
117
116
  end
118
117
  end
119
118
  end
@@ -63,17 +63,17 @@ module Atig
63
63
  screen_name = opt[:user].screen_name
64
64
  sum = db.get_first_value("SELECT sum(count) FROM id").to_i
65
65
  count = db.get_first_value("SELECT count FROM id WHERE screen_name = ?", screen_name).to_i
66
- entry = OpenStruct.new opt.merge(:tid => @roman.make(sum),
67
- :sid => "#{screen_name}:#{@roman.make(count)}")
66
+ entry = OpenStruct.new opt.merge(tid: @roman.make(sum),
67
+ sid: "#{screen_name}:#{@roman.make(count)}")
68
68
  db.execute(%{INSERT INTO status
69
69
  VALUES(NULL, :id, :tid, :sid, :screen_name, :user_id, :created_at, :data)},
70
- :id => id,
71
- :tid => entry.tid,
72
- :sid => entry.sid,
73
- :screen_name => screen_name,
74
- :user_id => opt[:user].id,
75
- :created_at => Time.parse(opt[:status].created_at).to_i,
76
- :data => @db.dump(entry))
70
+ id: id,
71
+ tid: entry.tid,
72
+ sid: entry.sid,
73
+ screen_name: screen_name,
74
+ user_id: opt[:user].id,
75
+ created_at: Time.parse(opt[:status].created_at).to_i,
76
+ data: @db.dump(entry))
77
77
  if count == 0 then
78
78
  db.execute("INSERT INTO id VALUES(NULL,?,?)", screen_name, 1)
79
79
  else
@@ -129,8 +129,10 @@ module Atig
129
129
 
130
130
  private
131
131
  def find(lhs,rhs, opt={},&f)
132
+ rhs.encoding!("UTF-8") if rhs.respond_to? :encoding!
133
+
132
134
  query = "SELECT id,data FROM status WHERE #{lhs} = :rhs ORDER BY created_at DESC LIMIT :limit"
133
- params = { :rhs => rhs, :limit => opt.fetch(:limit,20) }
135
+ params = { rhs: rhs, limit: opt.fetch(:limit,20) }
134
136
  res = []
135
137
 
136
138
  @db.execute do|db|
@@ -18,7 +18,7 @@ module Atig
18
18
 
19
19
  if respond_to?(:timeout_interval) && timeout_interval > 0 then
20
20
  begin
21
- timeout(timeout_interval){ f.call self }
21
+ Timeout.timeout(timeout_interval){ f.call self }
22
22
  rescue TimeoutError
23
23
  debug "transaction is timeout at #{src}"
24
24
  end
@@ -44,7 +44,6 @@ END
44
44
  def message(entry, command = PRIVMSG)
45
45
  GC.start
46
46
  user = entry.user
47
- screen_name = user.screen_name
48
47
  prefix = prefix user
49
48
  str = run_filters entry
50
49
 
@@ -88,7 +87,7 @@ END
88
87
  private
89
88
 
90
89
  def run_filters(entry)
91
- status = entry.status.merge(:tid=>entry.tid, :sid=>entry.sid)
90
+ status = entry.status.merge(tid:entry.tid, sid:entry.sid)
92
91
  @filters.inject(status) {|x, f| f.call x }.text
93
92
  end
94
93
 
@@ -16,7 +16,7 @@ require 'atig/option'
16
16
 
17
17
  begin
18
18
  require 'continuation'
19
- rescue LoadError => e
19
+ rescue LoadError
20
20
  end
21
21
 
22
22
  module Atig
@@ -50,7 +50,7 @@ END
50
50
 
51
51
  def update_status(ret, target, msg='')
52
52
  @db.transaction do|db|
53
- db.statuses.add(:source => :me, :status => ret, :user => ret.user )
53
+ db.statuses.add(source: :me, status: ret, user: ret.user )
54
54
  end
55
55
 
56
56
  msg = "(#{msg})" unless msg.empty?
@@ -58,12 +58,12 @@ END
58
58
  end
59
59
 
60
60
  def channel(name,opts={})
61
- opts.update(:session => self,
62
- :name => name,
63
- :filters => @ifilters,
64
- :prefix => @prefix,
65
- :nick => @nick,
66
- :opts => @opts)
61
+ opts.update(session: self,
62
+ name: name,
63
+ filters: @ifilters,
64
+ prefix: @prefix,
65
+ nick: @nick,
66
+ opts: @opts)
67
67
  channel = Channel.new opts
68
68
  @channels[name] = channel
69
69
  channel
@@ -111,7 +111,7 @@ END
111
111
  load_config
112
112
 
113
113
  @opts = Atig::Option.parse @real
114
- context = OpenStruct.new(:log=>@log, :opts=>@opts)
114
+ context = OpenStruct.new(log:@log, opts:@opts)
115
115
 
116
116
  oauth = OAuth.new(context, @nick)
117
117
  unless oauth.verified? then
@@ -166,12 +166,12 @@ END
166
166
 
167
167
  post server_name, MODE, @nick, "+o"
168
168
 
169
- @db = Atig::Db::Db.new context, :me=>me, :size=> 100, :tmpdir => @tmpdir
169
+ @db = Atig::Db::Db.new context, me:me, size: 100, tmpdir: @tmpdir
170
170
  run_new @@commands, context, self, @api, @db
171
171
  run_new @@agents , context, @api, @db
172
172
  run_new @@channels, context, self, @db
173
173
 
174
- @db.statuses.add :user => me, :source => :me, :status => me.status
174
+ @db.statuses.add user: me, source: :me, status: me.status
175
175
  end
176
176
  end
177
177
 
@@ -210,7 +210,7 @@ END
210
210
  def on_ctcp_action(target, mesg)
211
211
  command, *args = mesg.split(" ")
212
212
  last_match = nil
213
- commond = command.to_s.downcase
213
+ command = command.to_s.downcase
214
214
  _, action = @ctcp_actions.find{|define, f|
215
215
  r = (define === command)
216
216
  last_match = Regexp.last_match
@@ -244,7 +244,7 @@ END
244
244
  end
245
245
 
246
246
  def on_kick(m)
247
- channel, nick, msg = *m.params
247
+ channel, nick, _ = *m.params
248
248
 
249
249
  if not nick.screen_name? or @db.me.screen_name.casecmp(nick).zero?
250
250
  post server_name, ERR_NOSUCHNICK, nick, "No such nick: #{nick}" # or yourself
@@ -9,10 +9,10 @@ module Atig
9
9
  def self.proxy=(proxy)
10
10
  if proxy =~ /\A(?:([^:@]+)(?::([^@]+))?@)?([^:]+)(?::(\d+))?\z/ then
11
11
  @@proxy = OpenStruct.new({
12
- :user => $1,
13
- :password => $2,
14
- :address => $3,
15
- :port => $4.to_i,
12
+ user: $1,
13
+ password: $2,
14
+ address: $3,
15
+ port: $4.to_i,
16
16
  })
17
17
  end
18
18
  end
@@ -18,7 +18,7 @@ module Atig
18
18
  def call(status)
19
19
  target = short_url_regexp
20
20
  entities = (entities = status.entities).nil? ? [] : entities.urls
21
- status.merge :text => status.text.gsub(target) {|url|
21
+ status.merge text: status.text.gsub(target) {|url|
22
22
  unless entities.nil? or entities.empty?
23
23
  @cache[url] ||= search_url_from_entities(url, entities)
24
24
  url = @cache[url] if @cache[url] =~ target
@@ -7,7 +7,7 @@ module Atig
7
7
  def self.call(status)
8
8
  return status unless status.retweeted_status
9
9
  rt = status.retweeted_status
10
- status.merge :text => "#{Prefix}RT @#{rt.user.screen_name}: #{rt.text}"
10
+ status.merge text: "#{Prefix}RT @#{rt.user.screen_name}: #{rt.text}"
11
11
  end
12
12
  end
13
13
  end
@@ -8,7 +8,7 @@ module Atig
8
8
  status
9
9
  else
10
10
  t = Time.gm(*Time.parse(status.retweeted_status.created_at).to_a)
11
- status.merge :text => "#{status.text} \x0310[#{t.strftime "%Y-%m-%d %H:%M"}]\x0F"
11
+ status.merge text: "#{status.text} \x0310[#{t.strftime "%Y-%m-%d %H:%M"}]\x0F"
12
12
  end
13
13
  end
14
14
  end
@@ -12,7 +12,7 @@ module Atig
12
12
  gsub("&lt;", "<").
13
13
  gsub("&amp;", "&").
14
14
  gsub(WSP_REGEX, " ")
15
- status.merge :text => text
15
+ status.merge text: text
16
16
  }
17
17
  end
18
18
  end
@@ -8,7 +8,7 @@ module Atig
8
8
  end
9
9
 
10
10
  def call(status)
11
- status.merge :text => status.text.sub(@rsuffix, "").strip
11
+ status.merge text: status.text.sub(@rsuffix, "").strip
12
12
  end
13
13
  end
14
14
  end
@@ -20,7 +20,7 @@ module Atig
20
20
  unless xid and @opts.send(name)
21
21
  status
22
22
  else
23
- status.merge :text => "#{status.text} #{@format % xid}"
23
+ status.merge text: "#{status.text} #{@format % xid}"
24
24
  end
25
25
  end
26
26
  end
@@ -27,8 +27,8 @@ module Atig
27
27
 
28
28
  @nick = nick
29
29
  @oauth = ::OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, {
30
- :site => site,
31
- :proxy => ENV["HTTP_PROXY"] || ENV["http_proxy"]
30
+ site: site,
31
+ proxy: ENV["HTTP_PROXY"] || ENV["http_proxy"]
32
32
  })
33
33
 
34
34
  if @@profiles.key? @nick
@@ -47,7 +47,7 @@ module Atig
47
47
  end
48
48
 
49
49
  def verify(code)
50
- @access = @request.get_access_token(:oauth_verifier => code)
50
+ @access = @request.get_access_token(oauth_verifier: code)
51
51
  if @access then
52
52
  @@profiles[@nick] = [ @access.token , @access.secret ]
53
53
  end
@@ -19,7 +19,7 @@ module Atig
19
19
  end
20
20
 
21
21
  def call(status)
22
- status.merge(:status => escape_http_urls(status[:status]))
22
+ status.merge(status: escape_http_urls(status[:status]))
23
23
  end
24
24
 
25
25
  def exist_uri?(uri, limit = 1)
@@ -9,7 +9,7 @@ module Atig
9
9
 
10
10
  def call(q)
11
11
  if @opts.footer && !@opts.footer.empty? then
12
- q.merge :status => "#{q[:status]} #{@opts.footer}"
12
+ q.merge status: "#{q[:status]} #{@opts.footer}"
13
13
  else
14
14
  q
15
15
  end
@@ -10,7 +10,7 @@ module Atig
10
10
  def call(q)
11
11
  return q unless @opts.ll
12
12
  lat, long = @opts.ll.split(",", 2)
13
- q.merge :lat => lat.to_f, :long => long.to_f
13
+ q.merge lat: lat.to_f, long: long.to_f
14
14
  end
15
15
  end
16
16
  end
@@ -15,7 +15,7 @@ module Atig
15
15
 
16
16
  def call(status)
17
17
  mesg = status[:status]
18
- status.merge(:status => short_urls(mesg))
18
+ status.merge(status: short_urls(mesg))
19
19
  end
20
20
 
21
21
  def short_urls(mesg)
@@ -30,7 +30,7 @@ module Atig
30
30
  end
31
31
 
32
32
  default_value :api_base, 'https://api.twitter.com/1.1/'
33
- default_value :stream_api_base, 'https://userstream.twitter.com/2/'
33
+ default_value :stream_api_base, 'https://userstream.twitter.com/1.1/'
34
34
  default_value :search_api_base, 'https://search.twitter.com/'
35
35
 
36
36
  def initialize(table)
@@ -6,16 +6,17 @@ module Atig
6
6
  class << self
7
7
  def parse!(argv)
8
8
  opts = {
9
- :port => 16668,
10
- :host => "localhost",
11
- :log => nil,
12
- :debug => false,
13
- :foreground => false,
14
- :tmpdir => ::Dir.tmpdir,
15
- :conf => '~/.atig/config',
9
+ port: 16668,
10
+ host: "localhost",
11
+ log: nil,
12
+ debug: false,
13
+ foreground: false,
14
+ tmpdir: ::Dir.tmpdir,
15
+ conf: '~/.atig/config',
16
16
  }
17
17
 
18
18
  OptionParser.new do |parser|
19
+ parser.version = Atig::VERSION
19
20
  parser.instance_eval do
20
21
  self.banner = <<EOB.gsub(/^\t+/, "")
21
22
  usage: #{$0} [opts]
@@ -23,6 +24,16 @@ EOB
23
24
  separator ""
24
25
 
25
26
  separator "Options:"
27
+ on("--help", "show this help") do
28
+ puts help
29
+ exit
30
+ end
31
+
32
+ on("-v", "--version", "show version") do
33
+ puts version
34
+ exit
35
+ end
36
+
26
37
  on("-p", "--port [PORT=#{opts[:port]}]", "port number to listen") do |port|
27
38
  opts[:port] = port
28
39
  end
@@ -35,20 +46,20 @@ EOB
35
46
  opts[:log] = log
36
47
  end
37
48
 
38
- on("--debug", "Enable debug mode") do |debug|
49
+ on("-d", "--debug", "Enable debug mode") do |debug|
39
50
  opts[:log] ||= $stderr
40
51
  opts[:debug] = true
41
52
  end
42
53
 
43
- on("--tmpdir path", "temporary directory path") do |tmp|
54
+ on("-t", "--tmpdir path", "temporary directory path") do |tmp|
44
55
  opts[:tmpdir] = tmp
45
56
  end
46
57
 
47
- on("--memprof", "Enable memory profiler") do|_|
58
+ on("-m", "--memprof", "Enable memory profiler") do|_|
48
59
  require 'memory_profiler'
49
60
  require 'fileutils'
50
61
  FileUtils.mkdir_p "log"
51
- MemoryProfiler.start(:string_debug => true)
62
+ MemoryProfiler.start(string_debug: true)
52
63
  end
53
64
 
54
65
  on("-c","--conf [file=#{opts[:conf]}]", "atig configuration file; default is '~/.atig/config'") do|name|