capy 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/.gitignore +18 -0
  2. data/README.md +1 -4
  3. data/lib/capy.rb +15 -14
  4. data/lib/capy/version.rb +1 -1
  5. metadata +46 -75
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.log
data/README.md CHANGED
@@ -21,6 +21,7 @@ Write script
21
21
  visit 'http://www.wikipedia.org/'
22
22
  fill_in 'search', :with => 'ruby'
23
23
  click_on ' → '
24
+ stop
24
25
 
25
26
  and
26
27
 
@@ -30,10 +31,6 @@ Change the browser:
30
31
 
31
32
  $ capy -b firefox example.capy
32
33
 
33
- Run as nonstop mode:
34
-
35
- $ capy -n example.capy
36
-
37
34
  ## Contributing
38
35
 
39
36
  1. Fork it
data/lib/capy.rb CHANGED
@@ -12,18 +12,16 @@ module Capy
12
12
  @opts = Slop.parse!(args, :help => true) do
13
13
  banner "capy [script.capy]\n"
14
14
  on :b, :browser=, 'chrome, firefox', :default => 'chrome'
15
- on :h, :host=, 'app host'
16
- on :n, :nonstop
17
15
  end
18
16
  exit if opts.help?
19
17
 
18
+ trap('INT') { exit }
19
+
20
20
  Capybara.register_driver :selenium do |app|
21
21
  Capybara::Selenium::Driver.new(app, :browser => opts[:browser].to_sym)
22
22
  end
23
23
  Capybara.current_driver = :selenium
24
24
 
25
- Capybara.app_host = opts[:host] if opts[:host]
26
-
27
25
  if args.empty?
28
26
  start_shell
29
27
  else
@@ -35,11 +33,14 @@ module Capy
35
33
  end
36
34
  end
37
35
 
36
+ EXIT_COMMANDS = %w(exit quit)
37
+
38
38
  def start_shell(evaluater = Evaluater.new)
39
- exit_commands = %w(exit quit)
39
+ return if @_start_shell
40
+ @_start_shell = true
40
41
 
41
42
  Readline.completion_proc = lambda do |text|
42
- (Evaluater.instance_methods - Object.methods + exit_commands).grep(/^#{Regexp.quote(text.strip)}/)
43
+ (Evaluater.instance_methods - Object.methods + EXIT_COMMANDS).grep(/^#{Regexp.quote(text.strip)}/)
43
44
  end
44
45
 
45
46
  history_file = File.expand_path('~/.capy_history')
@@ -50,20 +51,18 @@ module Capy
50
51
  each { |line| Readline::HISTORY << line }
51
52
  end
52
53
 
53
- puts 'Type `exit` to exit'
54
-
55
54
  while buf = Readline.readline('> ', true)
56
55
  unless Readline::HISTORY.count == 1
57
56
  Readline::HISTORY.pop if buf.empty? || Readline::HISTORY[-1] == Readline::HISTORY[-2]
58
57
  end
59
58
 
60
59
  case buf.strip
61
- when *exit_commands
60
+ when *EXIT_COMMANDS
62
61
  File.open(history_file, 'w') do |file|
63
62
  lines = Readline::HISTORY.to_a[([Readline::HISTORY.size - 1000, 0].max)..-1]
64
63
  file.print(lines.join("\n"))
65
64
  end
66
- exit
65
+ return
67
66
  else
68
67
  begin
69
68
  result = evaluater.instance_eval(buf)
@@ -73,6 +72,8 @@ module Capy
73
72
  end
74
73
  end
75
74
  end
75
+
76
+ @_start_shell = false
76
77
  end
77
78
 
78
79
  def eval_script(script_file)
@@ -80,10 +81,6 @@ module Capy
80
81
  evaluater.instance_eval(File.read(script_file), script_file, 1)
81
82
  rescue => e
82
83
  error e
83
- ensure
84
- unless opts.nonstop?
85
- start_shell(evaluater)
86
- end
87
84
  end
88
85
 
89
86
  private
@@ -100,5 +97,9 @@ module Capy
100
97
  def host(app_host)
101
98
  Capybara.app_host = app_host
102
99
  end
100
+
101
+ def stop
102
+ Capy.start_shell(self)
103
+ end
103
104
  end
104
105
  end
data/lib/capy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Capy
2
- VERSION = "1.1.2"
2
+ VERSION = "1.2.0"
3
3
  end
metadata CHANGED
@@ -1,76 +1,58 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: capy
3
- version: !ruby/object:Gem::Version
4
- hash: 23
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 1
9
- - 2
10
- version: 1.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.2.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - jugyo
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-04-24 00:00:00 +09:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2012-04-24 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: slop
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70095394509140 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
18
+ requirements:
27
19
  - - ~>
28
- - !ruby/object:Gem::Version
29
- hash: 5
30
- segments:
31
- - 3
32
- - 1
33
- version: "3.1"
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: capybara
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70095394509140
25
+ - !ruby/object:Gem::Dependency
26
+ name: capybara
27
+ requirement: &70095394508720 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
48
33
  type: :runtime
49
- version_requirements: *id002
50
- - !ruby/object:Gem::Dependency
51
- name: colored
52
34
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70095394508720
36
+ - !ruby/object:Gem::Dependency
37
+ name: colored
38
+ requirement: &70095394508260 !ruby/object:Gem::Requirement
54
39
  none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
62
44
  type: :runtime
63
- version_requirements: *id003
45
+ prerelease: false
46
+ version_requirements: *70095394508260
64
47
  description: Capybara Script Runner
65
- email:
48
+ email:
66
49
  - jugyo.org@gmail.com
67
- executables:
50
+ executables:
68
51
  - capy
69
52
  extensions: []
70
-
71
53
  extra_rdoc_files: []
72
-
73
- files:
54
+ files:
55
+ - .gitignore
74
56
  - Gemfile
75
57
  - LICENSE
76
58
  - README.md
@@ -81,39 +63,28 @@ files:
81
63
  - examples/wikipedia_search.capy
82
64
  - lib/capy.rb
83
65
  - lib/capy/version.rb
84
- has_rdoc: true
85
66
  homepage: https://github.com/jugyo
86
67
  licenses: []
87
-
88
68
  post_install_message:
89
69
  rdoc_options: []
90
-
91
- require_paths:
70
+ require_paths:
92
71
  - lib
93
- required_ruby_version: !ruby/object:Gem::Requirement
72
+ required_ruby_version: !ruby/object:Gem::Requirement
94
73
  none: false
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- hash: 3
99
- segments:
100
- - 0
101
- version: "0"
102
- required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
79
  none: false
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- hash: 3
108
- segments:
109
- - 0
110
- version: "0"
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
111
84
  requirements: []
112
-
113
85
  rubyforge_project:
114
- rubygems_version: 1.3.7
86
+ rubygems_version: 1.8.10
115
87
  signing_key:
116
88
  specification_version: 3
117
89
  summary: The capy command to run the script written in Capybara DSL.
118
90
  test_files: []
119
-