automated-commands 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in automated-commands.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Raphael Randschau
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # AutomatedCommands
2
+
3
+ Still using TestUnit? Great! This gem helps automate DHHs [commands][1] gem which runs all test inside your Rails console.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'automated-commands', require: 'automated_commands'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install automated-commands
18
+
19
+ ## Usage
20
+
21
+ You basically need to follow two steps to get it up and running:
22
+
23
+ $ bundle exec rake automated_commands:watch &
24
+ $ RAILS_ENV=test bundle exec rails c
25
+ irb(main):001:0> start_test_listener
26
+
27
+ That's it! Now when you are changing any files located under `test` your tests will be automatically be run.
28
+
29
+ ## TODO
30
+
31
+ - tests
32
+ - display test results in :watch task output
33
+
34
+ ## Contributing
35
+
36
+ 1. Fork it
37
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
38
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
39
+ 4. Push to the branch (`git push origin my-new-feature`)
40
+ 5. Create new Pull Request
41
+
42
+ [1]:https://github.com/rails/commands
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'automated_commands/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "automated-commands"
8
+ gem.version = AutomatedCommands::VERSION
9
+ gem.authors = ["Raphael Randschau"]
10
+ gem.email = ["nicolai86@me.com"]
11
+ gem.description = %q{Insanely fast TestUnit tests using Rails & Commands}
12
+ gem.summary = %q{Insanely fast TestUnit tests using Rails & Commands}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'listen', '~> 0.7.2'
21
+ gem.add_dependency 'commands', '~> 0.2.1'
22
+ gem.add_development_dependency 'rake', '~> 10.0.3'
23
+ end
@@ -0,0 +1,9 @@
1
+ require "automated_commands/version"
2
+
3
+ require "automated_commands/rails/console_methods"
4
+
5
+ require "automated_commands/railtie" if defined?(Rails)
6
+
7
+ if defined?(Rake)
8
+ Dir[File.join(File.dirname(__FILE__), "../tasks/*.rake")].each { |ext| load ext }
9
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+ module AutomatedCommands
3
+ module Rails
4
+ module ConsoleMethods
5
+ def start_test_listener
6
+ original_trap = Signal.trap("SIGINT", proc { raise "exit" })
7
+
8
+ loop do
9
+ begin
10
+ input = open(::Rails.root.join("test_pipe"), "r+")
11
+
12
+ path = input.gets # e.g. test/unit/some_test.rb
13
+
14
+ if path =~ /test\/(.*)\/.*\.rb/
15
+ p "test '#{$1}'"
16
+ test $1
17
+ end
18
+ rescue => e
19
+ break
20
+ end
21
+ end
22
+
23
+ Signal.trap("SIGINT", &original_trap)
24
+ nil
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ module AutomatedCommands
3
+ class Railtie < ::Rails::Railtie
4
+ initializer "automated_commands.environment" do |app|
5
+ if ::Rails.env.test?
6
+ ::IRB::ExtendCommandBundle.send :include, ::AutomatedCommands::Rails::ConsoleMethods
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module AutomatedCommands
2
+ VERSION = "0.0.1"
3
+ end
data/tasks/watch.rake ADDED
@@ -0,0 +1,20 @@
1
+ namespace :automated_commands do
2
+ desc "watch TestUnit files for changes"
3
+ task :watch do
4
+ require 'listen'
5
+ require 'pathname'
6
+
7
+ %x[mkfifo ./test_pipe]
8
+ at_exit {
9
+ %x[rm ./test_pipe]
10
+ }
11
+
12
+ Listen.to('test', :filter => /.*_test\.rb$/, :latency => 0.2) do |modified, added, removed|
13
+ output = open("test_pipe", "w+")
14
+ path = Pathname.new(modified.first)
15
+
16
+ output.puts path.relative_path_from(Pathname.pwd)
17
+ output.flush
18
+ end
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: automated-commands
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Raphael Randschau
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ version_requirements: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.2
20
+ none: false
21
+ name: listen
22
+ type: :runtime
23
+ prerelease: false
24
+ requirement: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ version: 0.7.2
29
+ none: false
30
+ - !ruby/object:Gem::Dependency
31
+ version_requirements: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 0.2.1
36
+ none: false
37
+ name: commands
38
+ type: :runtime
39
+ prerelease: false
40
+ requirement: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 0.2.1
45
+ none: false
46
+ - !ruby/object:Gem::Dependency
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ~>
50
+ - !ruby/object:Gem::Version
51
+ version: 10.0.3
52
+ none: false
53
+ name: rake
54
+ type: :development
55
+ prerelease: false
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ version: 10.0.3
61
+ none: false
62
+ description: Insanely fast TestUnit tests using Rails & Commands
63
+ email:
64
+ - nicolai86@me.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - automated-commands.gemspec
75
+ - lib/automated_commands.rb
76
+ - lib/automated_commands/rails/console_methods.rb
77
+ - lib/automated_commands/railtie.rb
78
+ - lib/automated_commands/version.rb
79
+ - tasks/watch.rake
80
+ homepage: ''
81
+ licenses: []
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ none: false
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ none: false
98
+ requirements: []
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.23
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Insanely fast TestUnit tests using Rails & Commands
104
+ test_files: []
105
+ has_rdoc: