talks 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,7 @@ rvm:
3
3
  - 1.8.7
4
4
  - 1.9.2
5
5
  - 1.9.3
6
+ - 2.0.0
6
7
  - jruby-18mode # JRuby in 1.8 mode
7
8
  - jruby-19mode # JRuby in 1.9 mode
8
9
  - rbx-18mode
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.4.1
4
+
5
+ * Refactoring and codeclimate added
6
+
3
7
  ## 0.4.0
4
8
 
5
9
  * Added options for Talks#say: :notify, :detach (@kossnocorp)
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ talks (0.4.0)
5
+ notifier
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.2.3)
11
+ multi_json (1.7.2)
12
+ notifier (0.4.1)
13
+ rake (10.0.4)
14
+ rspec (2.13.0)
15
+ rspec-core (~> 2.13.0)
16
+ rspec-expectations (~> 2.13.0)
17
+ rspec-mocks (~> 2.13.0)
18
+ rspec-core (2.13.1)
19
+ rspec-expectations (2.13.0)
20
+ diff-lcs (>= 1.1.3, < 2.0)
21
+ rspec-mocks (2.13.1)
22
+ simplecov (0.7.1)
23
+ multi_json (~> 1.0)
24
+ simplecov-html (~> 0.7.1)
25
+ simplecov-html (0.7.1)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ rake
32
+ rspec
33
+ simplecov
34
+ talks!
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Talks gem — now your ruby and command-line tools can talk with you
2
2
 
3
- ### Build Status ![http://travis-ci.org/ruby-talks/talks](https://secure.travis-ci.org/ruby-talks/talks.png)
3
+ ### Build Status ![http://travis-ci.org/gazay/talks](https://secure.travis-ci.org/gazay/talks.png) ![https://codeclimate.com/github/gazay/talks](https://codeclimate.com/github/gazay/talks.png)
4
4
 
5
5
  If you want to HEAR some response from your code or command-line tools, just use this gem.
6
6
 
@@ -13,11 +13,11 @@ find what notifier you want to use - there is support for every OS!
13
13
 
14
14
  I added in all sections of this readme notes about usage notifier
15
15
  functionality. And small
16
- [readme](https://github.com/ruby-talks/talks#using-talks-with-growl) about usage with Growl notifier.
16
+ [readme](https://github.com/gazay/talks#using-talks-with-growl) about usage with Growl notifier.
17
17
 
18
18
  ### Here is a small [screencast](http://www.youtube.com/watch?v=PaUpwQMBvOY) about talks
19
19
 
20
- Soon we will finish the [wiki](https://github.com/ruby-talks/talks/wiki) and it will be (I hope) delimited and clear for understand.
20
+ Soon we will finish the [wiki](https://github.com/gazay/talks/wiki) and it will be (I hope) delimited and clear for understand.
21
21
 
22
22
  Sponsored by Evil Martians <http://evilmartians.com>
23
23
 
@@ -40,6 +40,10 @@ You can find some examples of `talks` usage in organization [ruby-talks](https:/
40
40
  * [bundler-talks](https://github.com/ruby-talks/bundler-talks)
41
41
  * [spec-talks](https://github.com/ruby-talks/spec-talks)
42
42
 
43
+ Examples from other people:
44
+
45
+ * [Autotesting tool on mocha, guard, rake and talks](https://gist.github.com/3150108) by @kossnocorp
46
+
43
47
  ## How?
44
48
 
45
49
  On MacOS X this gem is just using the native MacOS X `say` command line tool.
@@ -47,7 +51,7 @@ On linix/unix this gem is using espeak speech synthesis.
47
51
 
48
52
  For notifications this gem uses [notifier](https://github.com/fnando/notifier/blob/master/README.rdoc) gem.
49
53
 
50
- ### In all examples below I've used MacOS X voice types. For espeak you can read section [Using talks with espeak](https://github.com/ruby-talks/talks#using-talks-with-espeak)
54
+ ### In all examples below I've used MacOS X voice types. For espeak you can read section [Using talks with espeak](https://github.com/gazay/talks#using-talks-with-espeak)
51
55
 
52
56
  ### Configuration
53
57
 
@@ -57,7 +61,12 @@ You can configure default voices and messages for `talks` with `~/.talksrc` file
57
61
  ```yml
58
62
  default_voice: 'whisper'
59
63
  engine: 'say'
60
- notifier: 'off' # if this option passed - you will not receive notifications at all
64
+ notifier: 'off' # if this option passed - you will not receive notifications at all
65
+ notifier_options:
66
+ title: 'Not talks'
67
+ image: 'path/to/okay.png'
68
+ detach: true # added ' &' to command line command
69
+ notify_by_default: true # everytime when you call Talks#say - it will call Talks#notify
61
70
  voices:
62
71
  info: 'pipe'
63
72
  messages:
@@ -218,7 +227,7 @@ I did it myself.
218
227
 
219
228
  ### A lot of thanks
220
229
 
221
- * @kossnocorp - for idea with notifiers.
230
+ * @kossnocorp - for idea with notifiers and his pulls.
222
231
 
223
232
  * @shime - for grammar fixes in readme and better explanation of my idea.
224
233
 
@@ -1,5 +1,6 @@
1
1
  require File.expand_path('../talks/configuration.rb', __FILE__)
2
2
  require File.expand_path('../talks/hooks.rb', __FILE__)
3
+
3
4
  require 'notifier'
4
5
 
5
6
  module Talks
@@ -30,15 +30,8 @@ module Talks
30
30
 
31
31
  def initialize(opts)
32
32
  @options = symbolize_hash_keys(opts)
33
- @engine = options[:engine] || default_engine_for_os
34
- @notifier_options = options[:notifier_options] || {}
35
- @detach = options[:detach]
36
- @notify_by_default = options[:notify_by_default]
37
- @default_voice = options[:default_voice] || default_voice_for(engine)
38
- @voices = options[:voices] && DEFAULT_VOICES[engine.to_sym].merge(options[:voices]) ||
39
- DEFAULT_VOICES[engine.to_sym]
40
- @messages = options[:messages] && DEFAULT_MESSAGES.merge(options[:messages]) ||
41
- DEFAULT_MESSAGES
33
+
34
+ set_default_options
42
35
  end
43
36
 
44
37
  def voice(type)
@@ -57,10 +50,16 @@ module Talks
57
50
  "#{command_name} task #{position == :before ? 'started' : 'ended'}"
58
51
  end
59
52
 
60
- def message_for(command_name, position = :after)
53
+ def message_for(command_name, position = :after, kind = 'message')
61
54
  command = command_name.to_sym
62
- options[command] &&
63
- options[command][(position == :before ? :before_message : :after_message)]
55
+ message = \
56
+ position == :before ? "before_#{kind}" : "after_#{kind}"
57
+
58
+ options[command][message.to_sym] if options[command]
59
+ end
60
+
61
+ def notify_message_for(command_name, position = :after)
62
+ message_for(command_name, position, 'notify')
64
63
  end
65
64
 
66
65
  def notifier_for(command_name)
@@ -73,12 +72,6 @@ module Talks
73
72
  )
74
73
  end
75
74
 
76
- def notify_message_for(command_name, position = :after)
77
- command = command_name.to_sym
78
- options[command] &&
79
- options[command][(position == :before ? :before_notify : :after_notify)]
80
- end
81
-
82
75
  def voice_for(command_name)
83
76
  command = command_name.to_sym
84
77
  options[command] &&
@@ -87,6 +80,28 @@ module Talks
87
80
 
88
81
  private
89
82
 
83
+ def set_default_options
84
+ @engine = options[:engine] || default_engine_for_os
85
+ @notifier_options = options[:notifier_options] || {}
86
+ @detach = options[:detach]
87
+ @notify_by_default = options[:notify_by_default]
88
+ @default_voice = options[:default_voice] || default_voice_for(engine)
89
+ @voices = voice_options
90
+ @messages = messages_options
91
+ end
92
+
93
+ def voice_options
94
+ options[:voices] &&
95
+ DEFAULT_VOICES[engine.to_sym].merge(options[:voices]) ||
96
+ DEFAULT_VOICES[engine.to_sym]
97
+ end
98
+
99
+ def messages_options
100
+ options[:messages] &&
101
+ DEFAULT_MESSAGES.merge(options[:messages]) ||
102
+ DEFAULT_MESSAGES
103
+ end
104
+
90
105
  def default_voice_for(talks_engine)
91
106
  case talks_engine
92
107
  when 'say'
@@ -1,3 +1,10 @@
1
+ require File.expand_path('../hooks/base', __FILE__)
2
+ require File.expand_path('../hooks/voice', __FILE__)
3
+ require File.expand_path('../hooks/before_message', __FILE__)
4
+ require File.expand_path('../hooks/after_message', __FILE__)
5
+ require File.expand_path('../hooks/before_notify', __FILE__)
6
+ require File.expand_path('../hooks/after_notify', __FILE__)
7
+
1
8
  module Talks
2
9
  module Hooks
3
10
  class << self
@@ -42,32 +49,18 @@ module Talks
42
49
  end
43
50
  end
44
51
 
45
- def parse(options, command_name)
46
- voice = options['-v'] || options['--voice'] ||
47
- Talks.config.voice_for(command_name.to_sym) ||
48
- Talks.config.default_voice
49
-
50
- before_message = options['-bm'] || options['--before-message'] ||
51
- Talks.config.message_for(command_name, :before) ||
52
- Talks.config.default_message_for(command_name, :before)
53
-
54
- after_message = options['-am'] || options['--after-message'] ||
55
- Talks.config.message_for(command_name, :after) ||
56
- Talks.config.default_message_for(command_name, :after)
57
-
58
- before_notify = Talks.config.notifier_for(command_name) &&
59
- (
60
- options['-bn'] || options['--before-notify'] ||
61
- Talks.config.notify_message_for(command_name, :before) ||
62
- Talks.config.default_message_for(command_name, :before)
63
- )
64
-
65
- after_notify = Talks.config.notifier_for(command_name) &&
66
- (
67
- options['-an'] || options['--after-notify'] ||
68
- Talks.config.notify_message_for(command_name, :after) ||
69
- Talks.config.default_message_for(command_name, :after)
70
- )
52
+ def parse(opts, cmd)
53
+ voice = Talks::Hooks::Voice.to_hook opts, cmd
54
+
55
+ before_message = Talks::Hooks::BeforeMessage.to_hook opts, cmd
56
+
57
+ after_message = Talks::Hooks::AfterMessage.to_hook opts, cmd
58
+
59
+ before_notify = Talks.config.notifier_for(cmd) &&
60
+ Talks::Hooks::BeforeNotify.to_hook(opts, cmd)
61
+
62
+ after_notify = Talks.config.notifier_for(cmd) &&
63
+ Talks::Hooks::AfterNotify.to_hook(opts, cmd)
71
64
 
72
65
  [voice, before_message, after_message, before_notify, after_notify]
73
66
  end
@@ -0,0 +1,15 @@
1
+ module Talks
2
+ module Hooks
3
+ class AfterMessage < Talks::Hooks::Base
4
+
5
+ class << self
6
+
7
+ def one_dash_argv; '-am'; end
8
+ def two_dashes_argv; '--after-message'; end
9
+ def message_name; :after; end
10
+
11
+ end
12
+
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ module Talks
2
+ module Hooks
3
+ class AfterNotify < Talks::Hooks::Base
4
+
5
+ class << self
6
+
7
+ def one_dash_argv; '-an'; end
8
+ def two_dashes_argv; '--after-notify'; end
9
+ def message_method; :notify_message_for; end
10
+ def default_message_method; :default_message_for; end
11
+ def message_name; :after; end
12
+
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ module Talks
2
+ module Hooks
3
+ class Base
4
+ class << self
5
+
6
+ def one_dash_argv; ''; end
7
+ def two_dashes_argv; ''; end
8
+ def message_method; :message_for; end
9
+ def default_message_method; "default_#{message_method}"; end
10
+ def message_name; :before; end
11
+
12
+ def to_hook(opts, cmd)
13
+ opts[one_dash_argv] || opts[two_dashes_argv] ||
14
+ Talks.config.send(message_method, cmd, message_name) ||
15
+ Talks.config.send(default_message_method, cmd, message_name)
16
+ end
17
+
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ module Talks
2
+ module Hooks
3
+ class BeforeMessage < Talks::Hooks::Base
4
+
5
+ class << self
6
+
7
+ def one_dash_argv; '-bm'; end
8
+ def two_dashes_argv; '--before-message'; end
9
+
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module Talks
2
+ module Hooks
3
+ class BeforeNotify < Talks::Hooks::Base
4
+
5
+ class << self
6
+
7
+ def one_dash_argv; '-bn'; end
8
+ def two_dashes_argv; '--before-notify'; end
9
+ def message_method; :notify_message_for; end
10
+ def default_message_method; :default_message_for; end
11
+ def message_name; :before; end
12
+
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module Talks
2
+ module Hooks
3
+ class Voice < Talks::Hooks::Base
4
+
5
+ class << self
6
+
7
+ def one_dash_argv; '-v'; end
8
+ def two_dashes_argv; '--voice'; end
9
+
10
+ def to_hook(opts, cmd)
11
+ opts[one_dash_argv] || opts[two_dashes_argv] ||
12
+ Talks.config.voice_for(cmd.to_sym) || Talks.config.default_voice
13
+ end
14
+
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Talks
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ['gazay']
10
10
  s.email = ['alex.gaziev@gmail.com']
11
- s.homepage = "https://github.com/ruby-talks/talks"
11
+ s.homepage = "https://github.com/gazay/talks"
12
12
  s.summary = %q{Gem for talking ruby code and command-line tools}
13
13
  s.description = %q{This gem can be used for wraping command-lines with `talks` command or for adding hooks in ruby code which would tell you something}
14
14
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: talks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-20 00:00:00.000000000 Z
12
+ date: 2013-04-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: notifier
@@ -73,6 +73,7 @@ files:
73
73
  - .travis.yml
74
74
  - CHANGELOG.md
75
75
  - Gemfile
76
+ - Gemfile.lock
76
77
  - README.md
77
78
  - Rakefile
78
79
  - bin/talking
@@ -80,12 +81,18 @@ files:
80
81
  - lib/talks.rb
81
82
  - lib/talks/configuration.rb
82
83
  - lib/talks/hooks.rb
84
+ - lib/talks/hooks/after_message.rb
85
+ - lib/talks/hooks/after_notify.rb
86
+ - lib/talks/hooks/base.rb
87
+ - lib/talks/hooks/before_message.rb
88
+ - lib/talks/hooks/before_notify.rb
89
+ - lib/talks/hooks/voice.rb
83
90
  - lib/talks/runner.rb
84
91
  - lib/talks/version.rb
85
92
  - spec/talks/basic_spec.rb
86
93
  - spec/test_data/talksrc
87
94
  - talks.gemspec
88
- homepage: https://github.com/ruby-talks/talks
95
+ homepage: https://github.com/gazay/talks
89
96
  licenses: []
90
97
  post_install_message:
91
98
  rdoc_options: []
@@ -105,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
112
  version: '0'
106
113
  requirements: []
107
114
  rubyforge_project: talks
108
- rubygems_version: 1.8.24
115
+ rubygems_version: 1.8.23
109
116
  signing_key:
110
117
  specification_version: 3
111
118
  summary: Gem for talking ruby code and command-line tools