rbindkeys 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -7,7 +7,7 @@
7
7
  .bundle
8
8
  .config
9
9
  .yardoc
10
- Gemfile.lock
10
+ /Gemfile.lock
11
11
  InstalledFiles
12
12
  Makefile
13
13
  _yardoc
@@ -21,3 +21,4 @@ spec/reports
21
21
  test/tmp
22
22
  test/version_tmp
23
23
  tmp
24
+ /.ruby-version
data/README.md CHANGED
@@ -19,7 +19,7 @@ Or install it yourself as:
19
19
  ## Usage
20
20
 
21
21
  1. `rbindkeys -e > ~/.rbindkeys.rb`
22
- 2. edit `~.rbindkeys.rb`
22
+ 2. edit `~/.rbindkeys.rb`
23
23
  3. select a keyboard device (see `sudo rbindkeys --evdev-list`)
24
24
  4. `sudo rbindkeys /dev/input/event2` if you selected "/dev/input/event2"
25
25
  as a target keyboard
data/bin/rbindkeys CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "rbindkeys"
4
4
 
5
- Rbindkeys::CLI::main
5
+ Rbindkeys::CLI::main ARGV
data/lib/rbindkeys.rb CHANGED
@@ -1,4 +1,4 @@
1
- # -*- coding:undecided-unix; mode:ruby; -*-
1
+ # -*- coding:utf-8; mode:ruby; -*-
2
2
 
3
3
  require 'rubygems'
4
4
  require 'rbindkeys/version'
data/lib/rbindkeys/cli.rb CHANGED
@@ -24,15 +24,15 @@ module Rbindkeys
24
24
 
25
25
  @@usage = SUMMARY
26
26
 
27
- def main
27
+ def main args
28
28
  begin
29
- parse_opt
29
+ parse_opt args
30
30
  rescue OptionParser::ParseError => e
31
31
  puts "ERROR #{e.to_s}"
32
32
  err
33
33
  end
34
34
 
35
- method(@@cmd).call
35
+ method(@@cmd).call(args)
36
36
  end
37
37
 
38
38
  def err code=1
@@ -40,7 +40,7 @@ module Rbindkeys
40
40
  exit code
41
41
  end
42
42
 
43
- def parse_opt
43
+ def parse_opt args
44
44
  opt = OptionParser.new <<BANNER
45
45
  #{SUMMARY}
46
46
  Usage: sudo #{$0} [--config file] #{EVDEVS}
@@ -57,21 +57,21 @@ BANNER
57
57
  @@cmd = :print_example
58
58
  end
59
59
 
60
- opt.parse! ARGV
60
+ opt.parse! args
61
61
 
62
62
  @@usage = opt.help
63
63
  end
64
64
 
65
- def observe
66
- if ARGV.length != 1
65
+ def observe args
66
+ if args.length != 1
67
67
  puts 'ERROR invalid arguments'
68
68
  err
69
69
  end
70
- evdev = ARGV.first
70
+ evdev = args.first
71
71
  Observer.new(@@config, evdev).start
72
72
  end
73
73
 
74
- def ls
74
+ def ls args
75
75
  require 'revdev'
76
76
  Dir::glob(EVDEVS).sort do |a,b|
77
77
  am = a.match(/[0-9]+$/)
@@ -89,7 +89,7 @@ BANNER
89
89
  end
90
90
  end
91
91
 
92
- def print_example
92
+ def print_example args
93
93
  dir = File.dirname File.expand_path __FILE__
94
94
  dir = File.expand_path File.join dir, '..', '..', 'sample'
95
95
  file = File.join dir, 'emacs.rb'
@@ -1,3 +1,3 @@
1
1
  module Rbindkeys
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/spec/cli_spec.rb CHANGED
@@ -9,12 +9,10 @@ describe CLI do
9
9
  describe '#.main' do
10
10
  context ', when ARGV is empty,' do
11
11
  before do
12
- @stdout = StringIO.new
13
- # stub(STDOUT){@stdout}
14
- ARGV = []
12
+ @args = []
15
13
  end
16
14
  it 'shoud exit with code 1' do
17
- expect { CLI::main }.to raise_error do |e|
15
+ expect { CLI::main @args }.to raise_error do |e|
18
16
  e.should be_a SystemExit
19
17
  e.status.should == 1
20
18
  end
@@ -22,23 +20,23 @@ describe CLI do
22
20
  end
23
21
  context ', when ARGV have an argument,' do
24
22
  before do
25
- ARGV = ['foo']
26
- @observer = mock Observer
23
+ @args = ['foo']
24
+ @observer = double Observer
27
25
  Observer.should_receive(:new){@observer}
28
26
  @observer.should_receive(:start){nil}
29
27
  end
30
28
  it 'should call Observer#new#start' do
31
29
  config = CLI::config
32
- CLI::main
30
+ CLI::main @args
33
31
  CLI::config.should == config
34
32
  end
35
33
  end
36
34
  context ', when ARGV have an invalid option (--config),' do
37
35
  before do
38
- ARGV = ['--config']
36
+ @args = ['--config']
39
37
  end
40
38
  it 'should exit with code 1' do
41
- expect { CLI::main }.to raise_error do |e|
39
+ expect { CLI::main @args }.to raise_error do |e|
42
40
  e.should be_a SystemExit
43
41
  e.status.should == 1
44
42
  end
@@ -47,21 +45,21 @@ describe CLI do
47
45
  context ', when ARGV have an option (--config) and an event device,' do
48
46
  before do
49
47
  @config = 'a_config_file'
50
- ARGV = ['--config', @config,'foodev']
51
- @observer = mock Observer
48
+ @args = ['--config', @config,'foodev']
49
+ @observer = double Observer
52
50
  Observer.should_receive(:new){@observer}
53
51
  @observer.should_receive(:start){nil}
54
52
  end
55
53
  it 'should call Observer#new#start ' do
56
- CLI::main
54
+ CLI::main @args
57
55
  CLI::config.should == @config
58
56
  end
59
57
  end
60
58
  context ', when ARGV have an option (--evdev-list),' do
61
59
  before do
62
- ARGV = ['--evdev-list']
63
- @evdev = mock Revdev::EventDevice
64
- @id = mock Object
60
+ @args = ['--evdev-list']
61
+ @evdev = double Revdev::EventDevice
62
+ @id = double Object
65
63
  @evdev.stub(:device_name){"foo"}
66
64
  @evdev.stub(:device_id){@id}
67
65
  @id.stub(:hr_bustype){'bar'}
@@ -69,12 +67,9 @@ describe CLI do
69
67
  Dir.should_receive(:glob).with(CLI::EVDEVS).
70
68
  and_return(['/dev/input/event4','/dev/input/event2',
71
69
  '/dev/input/event13'])
72
- # @stdout = StringIO.new
73
- # $stdout = @stdout
74
70
  end
75
71
  it 'should pring device info' do
76
- CLI::main
77
- # @stdout.string.should match(%r!^/dev/input/event2!)
72
+ CLI::main @args
78
73
  end
79
74
  end
80
75
  end
@@ -7,8 +7,8 @@ include Rbindkeys
7
7
 
8
8
  describe DeviceOperator do
9
9
  before do
10
- @dev = mock Device
11
- @vdev = mock VirtualDevice
10
+ @dev = double Device
11
+ @vdev = double VirtualDevice
12
12
  @operator = DeviceOperator.new @dev, @vdev
13
13
  end
14
14
 
@@ -18,7 +18,7 @@ describe KeyEventHandler do
18
18
  end
19
19
 
20
20
  before do
21
- @ope = mock DeviceOperator
21
+ @ope = double DeviceOperator
22
22
  end
23
23
 
24
24
  describe "bind keys methods" do
@@ -26,7 +26,7 @@ describe KeyEventHandler do
26
26
  before do
27
27
  @defval = :hoge
28
28
  @bind_set = []
29
- @res = mock Rbindkeys::BindResolver
29
+ @res = double Rbindkeys::BindResolver
30
30
 
31
31
  # define stubs
32
32
  @res.stub(:bind) do |i, o|
@@ -49,7 +49,7 @@ describe KeyEventHandler do
49
49
  @res.stub(:kind_of?) do |klass|
50
50
  klass == Rbindkeys::BindResolver
51
51
  end
52
- Rbindkeys::BindResolver.stub!(:new).and_return(@res)
52
+ Rbindkeys::BindResolver.stub(:new).and_return(@res)
53
53
 
54
54
  @handler = KeyEventHandler.new @ope
55
55
  end
@@ -159,7 +159,7 @@ describe KeyEventHandler do
159
159
  end
160
160
  context 'with a BindResolver and a regex' do
161
161
  before do
162
- @arg_resolver = mock BindResolver
162
+ @arg_resolver = double BindResolver
163
163
  @arg_resolver.stub(:kind_of?).and_return(false)
164
164
  @arg_resolver.stub(:kind_of?).with(BindResolver).and_return(true)
165
165
  end
@@ -7,12 +7,12 @@ include Rbindkeys
7
7
 
8
8
  describe KeyEventHandler do
9
9
  before do
10
- @ope = mock DeviceOperator
10
+ @ope = double DeviceOperator
11
11
  @ope.stub(:pressed_key_set){ [] }
12
- @resolver = mock BindResolver
12
+ @resolver = double BindResolver
13
13
  @resolver2 = BindResolver.new
14
- BindResolver.stub!(:new){@resolver}
15
- @resolver.stub!(:two_stroke?){false}
14
+ BindResolver.stub(:new){@resolver}
15
+ @resolver.stub(:two_stroke?){false}
16
16
 
17
17
  @handler = KeyEventHandler.new @ope
18
18
  end
@@ -187,10 +187,10 @@ describe KeyEventHandler do
187
187
 
188
188
  describe '#active_window_changed' do
189
189
  before do
190
- @window = mock ActiveWindowX::Window
190
+ @window = double ActiveWindowX::Window
191
191
  @window.stub(:app_name).and_return('qux');
192
- @resolver2 = mock BindResolver
193
- BindResolver.stub!(:new){@resolver2}
192
+ @resolver2 = double BindResolver
193
+ BindResolver.stub(:new){@resolver2}
194
194
  end
195
195
  context 'with a Window, which contains "foo" in the title,' do
196
196
  before do
metadata CHANGED
@@ -1,116 +1,120 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rbindkeys
3
- version: !ruby/object:Gem::Version
4
- hash: 27
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 2
10
- version: 0.0.2
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Keiichiro Ui
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-08-04 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2014-02-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: revdev
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
32
22
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: ruinput
36
23
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
38
25
  none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: ruinput
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
46
38
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: active_window_x
50
39
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
52
41
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- hash: 3
57
- segments:
58
- - 0
59
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: active_window_x
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
60
54
  type: :runtime
61
- version_requirements: *id003
62
- - !ruby/object:Gem::Dependency
63
- name: bundler
64
55
  prerelease: false
65
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
66
65
  none: false
67
- requirements:
68
- - - ">="
69
- - !ruby/object:Gem::Version
70
- hash: 3
71
- segments:
72
- - 0
73
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
74
70
  type: :development
75
- version_requirements: *id004
76
- - !ruby/object:Gem::Dependency
77
- name: rake
78
71
  prerelease: false
79
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
80
73
  none: false
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- hash: 3
85
- segments:
86
- - 0
87
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rake
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
88
86
  type: :development
89
- version_requirements: *id005
90
- - !ruby/object:Gem::Dependency
91
- name: rspec
92
87
  prerelease: false
93
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
94
89
  none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: 3
99
- segments:
100
- - 0
101
- version: "0"
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rspec
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
102
  type: :development
103
- version_requirements: *id006
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
104
110
  description: key remap
105
- email:
111
+ email:
106
112
  - keiichiro.ui@gmail.com
107
- executables:
113
+ executables:
108
114
  - rbindkeys
109
115
  extensions: []
110
-
111
116
  extra_rdoc_files: []
112
-
113
- files:
117
+ files:
114
118
  - .gitignore
115
119
  - Gemfile
116
120
  - LICENSE
@@ -145,40 +149,31 @@ files:
145
149
  - spec/fix_resolver_spec.rb
146
150
  - spec/key_event_handler/configurer_spec.rb
147
151
  - spec/key_event_handler/handle_spec.rb
148
- homepage: ""
152
+ homepage: ''
149
153
  licenses: []
150
-
151
154
  post_install_message:
152
155
  rdoc_options: []
153
-
154
- require_paths:
156
+ require_paths:
155
157
  - lib
156
- required_ruby_version: !ruby/object:Gem::Requirement
158
+ required_ruby_version: !ruby/object:Gem::Requirement
157
159
  none: false
158
- requirements:
159
- - - ">="
160
- - !ruby/object:Gem::Version
161
- hash: 3
162
- segments:
163
- - 0
164
- version: "0"
165
- required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ! '>='
162
+ - !ruby/object:Gem::Version
163
+ version: '0'
164
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
165
  none: false
167
- requirements:
168
- - - ">="
169
- - !ruby/object:Gem::Version
170
- hash: 3
171
- segments:
172
- - 0
173
- version: "0"
166
+ requirements:
167
+ - - ! '>='
168
+ - !ruby/object:Gem::Version
169
+ version: '0'
174
170
  requirements: []
175
-
176
171
  rubyforge_project:
177
- rubygems_version: 1.8.15
172
+ rubygems_version: 1.8.23
178
173
  signing_key:
179
174
  specification_version: 3
180
175
  summary: key remap
181
- test_files:
176
+ test_files:
182
177
  - spec/bind_resolver_spec.rb
183
178
  - spec/bind_tree_bind_spec.rb
184
179
  - spec/bind_tree_resolve_for_pressed_event_spec.rb