oct 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ *.rb diff=ruby
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ coverage
5
+ rdoc
6
+ .yardoc
7
+ rerun.txt
8
+ tags
9
+ tmp/fixtures
10
+ tmp/aruba
data/.yardopts ADDED
@@ -0,0 +1,6 @@
1
+ --verbose
2
+ --list-undoc
3
+ -
4
+ LICENSE
5
+ HISTORY.markdown
6
+ VERSION
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in the .gemspec file
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ oct (0.1.0)
5
+ configatron (>= 2.5.1)
6
+ term-ansicolor (>= 1.0.4)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ aruba (0.2.3)
12
+ background_process
13
+ cucumber (~> 0.9.0)
14
+ background_process (1.2)
15
+ builder (2.1.2)
16
+ configatron (2.6.3)
17
+ yamler (>= 0.1.0)
18
+ cucumber (0.9.0)
19
+ builder (~> 2.1.2)
20
+ diff-lcs (~> 1.1.2)
21
+ gherkin (~> 2.2.2)
22
+ json (~> 1.4.6)
23
+ term-ansicolor (~> 1.0.5)
24
+ diff-lcs (1.1.2)
25
+ gherkin (2.2.4)
26
+ json (~> 1.4.6)
27
+ term-ansicolor (~> 1.0.5)
28
+ trollop (~> 1.16.2)
29
+ json (1.4.6)
30
+ rake (0.8.7)
31
+ rdiscount (1.6.5)
32
+ rspec (1.3.0)
33
+ term-ansicolor (1.0.5)
34
+ trollop (1.16.2)
35
+ yamler (0.1.0)
36
+ yard (0.6.1)
37
+
38
+ PLATFORMS
39
+ ruby
40
+
41
+ DEPENDENCIES
42
+ aruba (>= 0.2.0)
43
+ bundler (>= 1.0.0)
44
+ configatron (>= 2.5.1)
45
+ cucumber (>= 0.6)
46
+ oct!
47
+ rake (>= 0.8.7)
48
+ rdiscount (>= 1.6.5)
49
+ rspec (>= 1.2.9)
50
+ term-ansicolor (>= 1.0.4)
51
+ yard (>= 0.6.1)
data/HISTORY.markdown ADDED
@@ -0,0 +1,11 @@
1
+ History
2
+ =======
3
+ Most recent changes are at the top
4
+
5
+
6
+ Changes
7
+ -------
8
+
9
+ ### 0.1.0 - 03/12/2010 ###
10
+
11
+ * Initial release
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 GearheadForHire, LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,101 @@
1
+ Oct
2
+ ===
3
+
4
+ Command line octal file permissions
5
+
6
+
7
+ Why?
8
+ ----
9
+
10
+ Oct is a sample RubyGem application cloned from BasicApp.
11
+ See <http://github.com/robertwahler/basic_app> for more information.
12
+
13
+ Oct does scratch an itch. 'Chmod' is easier to drive in octal and I can't
14
+ convince 'ls -l' to output permissions in octal.
15
+
16
+ Here is an equivalent bash script
17
+
18
+ #!/bin/bash
19
+ # octal file listing
20
+
21
+ if [ "$1" == "" ]
22
+ then
23
+ PARAM="*"
24
+ else
25
+ PARAM="$@"
26
+ fi
27
+
28
+ for file in $PARAM
29
+ do
30
+
31
+ if [ ! -e "$file" ] # Check if file exists.
32
+ then
33
+ echo "$file does not exist."; echo
34
+ continue # On to next.
35
+ fi
36
+
37
+ stat --format='%a,%U,%G,%t %n' $file
38
+ done
39
+
40
+
41
+ Run-time dependencies
42
+ ---------------------
43
+
44
+ * Term-ansicolor for optional color output <http://github.com/flori/term-ansicolor>
45
+ * Configatron for configuration support <http://github.com/markbates/configatron>
46
+
47
+
48
+ Development dependencies
49
+ ------------------------
50
+
51
+ * Bundler for dependency management <http://github.com/carlhuda/bundler>
52
+ * Rspec for unit testing <http://github.com/dchelimsky/rspec>
53
+ * Cucumber for functional testing <http://github.com/aslakhellesoy/cucumber>
54
+ * Aruba for CLI testing <http://github.com/aslakhellesoy/aruba>
55
+ * YARD for documentation generation <http://github.com/lsegal/yard>
56
+
57
+
58
+ Installation
59
+ ------------
60
+
61
+ This gem has been published on RubyGems.org
62
+
63
+ gem install oct
64
+
65
+
66
+ Usage
67
+ -----
68
+
69
+ oct --help
70
+
71
+ Octal file listing
72
+
73
+ Usage: oct [options] [FILES]
74
+
75
+ Options:
76
+
77
+ -v, --[no-]verbose Run verbosely
78
+ -c, --[no-]coloring Ansi color in output
79
+ --version Display current version
80
+ -h, --help Show this message
81
+
82
+
83
+ Example
84
+ -------
85
+
86
+ ls -l
87
+
88
+ total 0
89
+ -rw-r--r-- 1 robert robert 0 2010-03-12 10:37 file1.txt
90
+ -rw-r--r-- 1 robert robert 0 2010-03-12 10:37 file2.txt
91
+
92
+ oct
93
+
94
+ 0644 file1.txt
95
+ 0644 file2.txt
96
+
97
+
98
+ Copyright
99
+ ---------
100
+
101
+ Copyright (c) 2010 GearheadForHire, LLC. See [LICENSE](LICENSE) for details.
data/Rakefile ADDED
@@ -0,0 +1,55 @@
1
+ # encoding: utf-8
2
+
3
+ # bundler/setup is managing $LOAD_PATH, any gem needed by this Rakefile must
4
+ # be listed as a development dependency in the gemspec
5
+
6
+ require 'rubygems'
7
+ require 'bundler/setup'
8
+
9
+ Bundler::GemHelper.install_tasks
10
+
11
+ def gemspec
12
+ @gemspec ||= begin
13
+ file = File.expand_path('../oct.gemspec', __FILE__)
14
+ eval(File.read(file), binding, file)
15
+ end
16
+ end
17
+
18
+ require 'spec'
19
+ require 'spec/rake/spectask'
20
+ Spec::Rake::SpecTask.new(:spec) do |spec|
21
+ spec.libs << 'lib' << 'spec'
22
+ spec.spec_files = FileList['spec/**/*_spec.rb']
23
+ end
24
+
25
+ require 'cucumber'
26
+ require 'cucumber/rake/task'
27
+ Cucumber::Rake::Task.new(:features) do |task|
28
+ task.cucumber_opts = ["features"]
29
+ end
30
+
31
+ desc "Run specs and features"
32
+ task :test => [:spec, :features]
33
+
34
+ task :default => :test
35
+
36
+ namespace :doc do
37
+ project_root = File.expand_path(File.dirname(__FILE__))
38
+ doc_destination = File.join(project_root, 'rdoc')
39
+
40
+ require 'yard'
41
+ require 'yard/rake/yardoc_task'
42
+
43
+ YARD::Rake::YardocTask.new(:generate) do |yt|
44
+ yt.options = ['--markup-provider', 'rdiscount',
45
+ '--output-dir', doc_destination
46
+ ] +
47
+ gemspec.rdoc_options - ['--line-numbers', '--inline-source']
48
+ end
49
+
50
+ desc "Remove generated documenation"
51
+ task :clean do
52
+ rm_r doc_destination if File.exists?(doc_destination)
53
+ end
54
+
55
+ end
data/TODO.markdown ADDED
@@ -0,0 +1,3 @@
1
+ TODO
2
+ ====
3
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/bin/oct ADDED
@@ -0,0 +1,73 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
4
+
5
+ require 'oct'
6
+ require 'optparse'
7
+ require 'term/ansicolor'
8
+
9
+ available_actions = Oct::AVAILABLE_ACTIONS
10
+
11
+ banner = <<BANNER
12
+ Octal file listing
13
+
14
+ Usage: oct [options] [FILES]
15
+ BANNER
16
+ banner << "\nActions: #{available_actions.join(' ')}\n" unless available_actions.empty?
17
+
18
+ help = banner
19
+ help += <<HELP
20
+
21
+ Options:
22
+
23
+ HELP
24
+
25
+ options = {}
26
+ OptionParser.new do |opts|
27
+ opts.banner = help
28
+
29
+ # set defaults
30
+ options[:verbose] = false
31
+ options[:coloring] = true
32
+
33
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
34
+ options[:verbose] = v
35
+ end
36
+
37
+ opts.on("-c", "--[no-]coloring", "Ansi color in output") do |c|
38
+ options[:coloring] = c
39
+ end
40
+
41
+ opts.on("--version", "Display current version") do
42
+ puts "oct, version " + Oct.version
43
+ exit 0
44
+ end
45
+
46
+ # opts.on("--config FILE", "Load configuration options from FILE") do |file|
47
+ # options[:config] = file
48
+ # end
49
+
50
+ # no argument, shows at tail. This will print an options summary.
51
+ opts.on_tail("-h", "--help", "Show this message") do
52
+ puts opts
53
+ exit 0
54
+ end
55
+
56
+ begin
57
+ opts.parse!
58
+ rescue OptionParser::InvalidOption => e
59
+ puts "oct #{e}"
60
+ puts "oct --help for more information"
61
+ exit 1
62
+ end
63
+
64
+ end
65
+
66
+ if STDOUT.isatty
67
+ Term::ANSIColor::coloring = options[:coloring]
68
+ else
69
+ Term::ANSIColor::coloring = false
70
+ end
71
+
72
+ app = Oct::App.new(FileUtils.pwd, options)
73
+ app.run
@@ -0,0 +1,7 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format pretty features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %>
7
+ wip: --tags @wip:3 --wip features
@@ -0,0 +1,35 @@
1
+ @announce
2
+ Feature: Options via a command line interface (CLI)
3
+
4
+ As an interactive user or automated script
5
+ The application should accept options on the command line
6
+ These options should override hard coded defaults
7
+ In order to configure options
8
+
9
+ Scenario: Version info
10
+ When I run "oct --version"
11
+ Then the exit status should be 0
12
+ And the output should match /oct, version ([\d]+\.[\d]+\.[\d]+$)/
13
+
14
+ Scenario: Help
15
+ When I run "oct --help"
16
+ Then the exit status should be 0
17
+ And the output should match:
18
+ """
19
+ .*
20
+ Usage: .*
21
+ .*
22
+ Options:
23
+ .*
24
+ -v, --\[no-\]verbose Run verbosely
25
+ """
26
+
27
+ Scenario: Invalid option
28
+ When I run "oct --non-existing-option"
29
+ Then the exit status should be 1
30
+ And the output should match:
31
+ """
32
+ ^.* invalid option: --non-existing-option
33
+ ^.* --help for more information
34
+
35
+ """
@@ -0,0 +1,34 @@
1
+ @announce
2
+ Feature: Octal file listing
3
+
4
+ As an interactive user or automated script
5
+ The application should accept a list of files on the command line
6
+ and return a sorted listing of files with octal file permissions
7
+ because working with chmod is easier in octal
8
+
9
+ Background: A bunch of files
10
+ Given an empty file named "file2.txt"
11
+ And file "file2.txt" is chmod 0644
12
+ Given an empty file named "file1.txt"
13
+ And file "file1.txt" is chmod 0644
14
+
15
+ Scenario: No files on the command line
16
+ When I run "oct"
17
+ Then the exit status should be 0
18
+ And the output should contain:
19
+ """
20
+ 0644 file1.txt
21
+ 0644 file2.txt
22
+ """
23
+
24
+ Scenario: Files on the command line
25
+ When I run "oct file1*"
26
+ Then the exit status should be 0
27
+ And the output should contain:
28
+ """
29
+ 0644 file1.txt
30
+ """
31
+ And the output should not contain:
32
+ """
33
+ 0644 file2.txt
34
+ """
File without changes
@@ -0,0 +1,5 @@
1
+ Given /^file "([^"]*)" is chmod (\d+)$/ do |filename, permissions|
2
+ in_current_dir do
3
+ FileUtils.chmod permissions.to_i(8), filename
4
+ end
5
+ end
@@ -0,0 +1,21 @@
1
+ require 'aruba'
2
+ require 'fileutils'
3
+
4
+ APP_BIN_PATH = File.join(ENV['PWD'], 'bin', 'oct')
5
+
6
+ module Aruba
7
+ module Api
8
+
9
+ alias_method :old_run, :run
10
+
11
+ # override aruba
12
+ def run(cmd, fail_on_error=true)
13
+
14
+ # run development version in verbose mode
15
+ cmd = cmd.gsub(/^oct/, "#{APP_BIN_PATH} --verbose")
16
+
17
+ # run original aruba 'run'
18
+ old_run(cmd, fail_on_error)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'oct'
3
+ require 'aruba'
4
+ require 'spec/expectations'
data/lib/oct/app.rb ADDED
@@ -0,0 +1,102 @@
1
+ require 'configatron'
2
+ require 'term/ansicolor'
3
+
4
+ class String
5
+ include Term::ANSIColor
6
+ end
7
+
8
+ module Oct
9
+
10
+ AVAILABLE_ACTIONS = %w[]
11
+
12
+ class App
13
+
14
+ def initialize(base_dir, options={})
15
+ @base_dir = base_dir
16
+ @options = options
17
+ if @options[:verbose]
18
+ puts "base_dir: #{@base_dir}".cyan
19
+ puts "options: #{@options.inspect}".cyan
20
+ end
21
+ configure(options)
22
+ end
23
+
24
+ def run
25
+ begin
26
+
27
+ if action_argument_required?
28
+ action = ARGV.shift
29
+ unless AVAILABLE_ACTIONS.include?(action)
30
+ if action.nil?
31
+ puts "oct action required"
32
+ else
33
+ puts "oct invalid action: #{action}"
34
+ end
35
+ puts "oct --help for more information"
36
+ exit 1
37
+ end
38
+ puts "oct run action: #{action}".cyan if @options[:verbose]
39
+ raise "action #{action} not implemented" unless respond_to?(action)
40
+ result = send(action)
41
+ else
42
+ #
43
+ # default action if action_argument_required? is false
44
+ #
45
+ files = ARGV.empty? ? Dir.glob('*') : ARGV
46
+ result = Oct::FileStat.new.mode(files, @options)
47
+ end
48
+
49
+ exit(result ? 0 : 1)
50
+
51
+ rescue SystemExit => e
52
+ # This is the normal exit point, exit code from the send result
53
+ # or exit from another point in the system
54
+ puts "oct run system exit: #{e}, status code: #{e.status}".green if @options[:verbose]
55
+ exit(e.status)
56
+ rescue Exception => e
57
+ STDERR.puts("oct command failed, error(s) follow:")
58
+ STDERR.puts("#{e.message}".red)
59
+ STDERR.puts(e.backtrace.join("\n")) if @options[:verbose]
60
+ exit(1)
61
+ end
62
+ end
63
+
64
+ #
65
+ # app commands start
66
+ #
67
+
68
+
69
+ #
70
+ # app commands end
71
+ #
72
+
73
+ private
74
+
75
+ # true if application requires an action to be specified on the command line
76
+ def action_argument_required?
77
+ !AVAILABLE_ACTIONS.empty?
78
+ end
79
+
80
+ # read options for YAML config with ERB processing and initialize configatron
81
+ def configure(options)
82
+ config = @options[:config]
83
+ config = File.join(@base_dir, 'oct.conf') unless config
84
+ if File.exists?(config)
85
+ # load configatron options from the config file
86
+ puts "loading config file: #{config}".cyan if @options[:verbose]
87
+ configatron.configure_from_yaml(config)
88
+ else
89
+ # user specified a config file?
90
+ raise "config file not found" if @options[:config]
91
+ # no error if user did not specify config file
92
+ puts "#{config} not found".yellow if @options[:verbose]
93
+ end
94
+
95
+ #
96
+ # set defaults, these will NOT override setting read from YAML
97
+ #
98
+
99
+ end
100
+
101
+ end
102
+ end
data/lib/oct/oct.rb ADDED
@@ -0,0 +1,27 @@
1
+ module Oct
2
+
3
+ class FileStat
4
+
5
+ # print octal file listing
6
+ #
7
+ # @param [Array] files files to be listed
8
+ def mode(files, options={})
9
+ puts "oct mode files: #{files.inspect}".cyan if options[:verbose]
10
+ files.sort.each do |file|
11
+ stat = File.stat(file)
12
+ printf("%04o ", stat.mode & 07777)
13
+ if stat.directory?
14
+ puts file.blue
15
+ elsif stat.executable?
16
+ puts file.green
17
+ elsif stat.symlink?
18
+ puts file.cyan
19
+ else
20
+ puts file
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+
data/lib/oct.rb ADDED
@@ -0,0 +1,21 @@
1
+ # require all files here
2
+ require 'rubygems'
3
+ require 'oct/app'
4
+ require 'oct/oct'
5
+
6
+ # Master namespace
7
+ module Oct
8
+
9
+ # Contents of the VERSION file
10
+ #
11
+ # Example format: 0.0.1
12
+ #
13
+ # @return [String] the contents of the version file in #.#.# format
14
+ def self.version
15
+ version_info_file = File.join(File.dirname(__FILE__), *%w[.. VERSION])
16
+ File.open(version_info_file, "r") do |f|
17
+ f.read
18
+ end
19
+ end
20
+
21
+ end
data/oct.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ #
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "oct"
7
+ s.version = File.open(File.join(File.dirname(__FILE__), *%w[VERSION]), "r") { |f| f.read }
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Robert Wahler"]
10
+ s.email = ["robert@gearheadforhire.com"]
11
+ s.homepage = "http://rubygems.org/gems/oct"
12
+ s.summary = "Command line octal file permissions"
13
+ s.description = "Command line octal file permissions"
14
+
15
+ s.required_rubygems_version = ">= 1.3.6"
16
+ s.rubyforge_project = "oct"
17
+
18
+ s.add_dependency 'term-ansicolor', '>= 1.0.4'
19
+ s.add_dependency 'configatron', '>= 2.5.1'
20
+
21
+ s.add_development_dependency "bundler", ">= 1.0.0"
22
+ s.add_development_dependency "rspec", ">= 1.2.9"
23
+ s.add_development_dependency "cucumber", ">= 0.6"
24
+ s.add_development_dependency "aruba", ">= 0.2.0"
25
+ s.add_development_dependency "rake", ">= 0.8.7"
26
+ s.add_development_dependency "yard", ">= 0.6.1"
27
+ s.add_development_dependency "rdiscount", ">= 1.6.5"
28
+
29
+ s.files = `git ls-files`.split("\n")
30
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
31
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
32
+ s.require_path = 'lib'
33
+
34
+ s.has_rdoc = 'yard'
35
+ s.rdoc_options = [
36
+ '--title', 'Oct Documentation',
37
+ '--main', 'README.markdown',
38
+ '--line-numbers',
39
+ '--inline-source'
40
+ ]
41
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Oct do
4
+
5
+ describe 'version' do
6
+
7
+ it "should return a string formatted '#.#.#'" do
8
+ Oct::version.should match(/(^[\d]+\.[\d]+\.[\d]+$)/)
9
+ end
10
+
11
+ end
12
+
13
+ end
data/spec/spec.opts ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format nested
@@ -0,0 +1,19 @@
1
+ $LOAD_PATH.unshift File.expand_path('..', __FILE__) unless
2
+ $LOAD_PATH.include? File.expand_path('..', __FILE__)
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) unless
4
+ $LOAD_PATH.include? File.expand_path('../../lib', __FILE__)
5
+
6
+ require 'rubygems'
7
+ require 'oct'
8
+ require 'spec'
9
+ require 'spec/autorun'
10
+ require 'aruba/api'
11
+
12
+ # aruba helper, returns full path to files in the aruba tmp folder
13
+ def fullpath(filename)
14
+ File.expand_path(File.join(current_dir, filename))
15
+ end
16
+
17
+ Spec::Runner.configure do |config|
18
+ config.include Aruba::Api
19
+ end
data/spec/watchr.rb ADDED
@@ -0,0 +1,143 @@
1
+ # Watchr: Autotest like functionality
2
+ #
3
+ # gem install watchr
4
+ #
5
+ # Run me with:
6
+ #
7
+ # $ watchr spec/watchr.rb
8
+
9
+ require 'term/ansicolor'
10
+
11
+ $c = Term::ANSIColor
12
+
13
+ def getch
14
+ state = `stty -g`
15
+ begin
16
+ `stty raw -echo cbreak`
17
+ $stdin.getc
18
+ ensure
19
+ `stty #{state}`
20
+ end
21
+ end
22
+
23
+ # --------------------------------------------------
24
+ # Convenience Methods
25
+ # --------------------------------------------------
26
+ def all_feature_files
27
+ Dir['features/*.feature']
28
+ end
29
+
30
+ def all_spec_files
31
+ files = Dir['spec/**/*_spec\.rb']
32
+ end
33
+
34
+ def run(cmd)
35
+
36
+ pid = fork do
37
+ puts "\n"
38
+ print $c.cyan, cmd, $c.clear, "\n"
39
+ exec(cmd)
40
+ end
41
+ Signal.trap('INT') do
42
+ puts "sending KILL to pid: #{pid}"
43
+ Process.kill("KILL", pid)
44
+ end
45
+ Process.waitpid(pid)
46
+
47
+ prompt
48
+ end
49
+
50
+ def run_all
51
+ run_all_specs
52
+ run_default_cucumber
53
+ end
54
+
55
+ # allow cucumber rerun.txt smarts
56
+ def run_default_cucumber
57
+ cmd = "cucumber"
58
+ run(cmd)
59
+ end
60
+
61
+ def run_all_features
62
+ cmd = "cucumber #{all_feature_files.join(' ')}"
63
+ run(cmd)
64
+ end
65
+
66
+ def run_feature(feature)
67
+ cmd = "cucumber #{feature}"
68
+ $last_feature = feature
69
+ run(cmd)
70
+ end
71
+
72
+ def run_last_feature
73
+ run_feature($last_feature) if $last_feature
74
+ end
75
+
76
+ def run_default_spec
77
+ cmd = "spec --color --format s ./spec"
78
+ run(cmd)
79
+ end
80
+
81
+ def run_all_specs
82
+ cmd = "spec --color --format s #{all_spec_files.join(' ')}"
83
+ p cmd
84
+ run(cmd)
85
+ end
86
+
87
+ def run_spec(spec)
88
+ cmd = "spec --color --format s #{spec}"
89
+ $last_spec = spec
90
+ run(cmd)
91
+ end
92
+
93
+ def run_last_spec
94
+ run_spec($last_spec) if $last_spec
95
+ end
96
+
97
+ def prompt
98
+ puts "Ctrl-\\ for menu, Ctrl-C to quit"
99
+ end
100
+
101
+ # init
102
+ $last_feature = nil
103
+ prompt
104
+
105
+ # --------------------------------------------------
106
+ # Watchr Rules
107
+ # --------------------------------------------------
108
+ watch( '^features/(.*)\.feature' ) { run_default_cucumber }
109
+
110
+ watch( '^bin/(.*)' ) { run_default_cucumber }
111
+ watch( '^lib/(.*)' ) { run_default_cucumber }
112
+
113
+ watch( '^features/step_definitions/(.*)\.rb' ) { run_default_cucumber }
114
+ watch( '^features/support/(.*)\.rb' ) { run_default_cucumber }
115
+
116
+ watch( '^spec/(.*)_spec\.rb' ) { |m| run_spec(m[0]) }
117
+ # specify just the lib files that have specs
118
+ # TODO: This can be determined automatically from the spec file naming convention
119
+ watch( '^lib/oct.rb' ) { run_default_spec }
120
+
121
+ # --------------------------------------------------
122
+ # Signal Handling
123
+ # --------------------------------------------------
124
+
125
+ # Ctrl-\
126
+ Signal.trap('QUIT') do
127
+
128
+ puts "\n\nMENU: a = all , f = features s = specs, l = last feature (#{$last_feature ? $last_feature : 'none'}), q = quit\n\n"
129
+ c = getch
130
+ puts c.chr
131
+ if c.chr == "a"
132
+ run_all
133
+ elsif c.chr == "f"
134
+ run_default_cucumber
135
+ elsif c.chr == "s"
136
+ run_all_specs
137
+ elsif c.chr == "q"
138
+ abort("exiting\n")
139
+ elsif c.chr == "l"
140
+ run_last_feature
141
+ end
142
+
143
+ end
metadata ADDED
@@ -0,0 +1,243 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: oct
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Robert Wahler
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-05 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ hash: 31
28
+ segments:
29
+ - 1
30
+ - 0
31
+ - 4
32
+ version: 1.0.4
33
+ type: :runtime
34
+ name: term-ansicolor
35
+ prerelease: false
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 25
44
+ segments:
45
+ - 2
46
+ - 5
47
+ - 1
48
+ version: 2.5.1
49
+ type: :runtime
50
+ name: configatron
51
+ prerelease: false
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 23
60
+ segments:
61
+ - 1
62
+ - 0
63
+ - 0
64
+ version: 1.0.0
65
+ type: :development
66
+ name: bundler
67
+ prerelease: false
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 13
76
+ segments:
77
+ - 1
78
+ - 2
79
+ - 9
80
+ version: 1.2.9
81
+ type: :development
82
+ name: rspec
83
+ prerelease: false
84
+ version_requirements: *id004
85
+ - !ruby/object:Gem::Dependency
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 7
92
+ segments:
93
+ - 0
94
+ - 6
95
+ version: "0.6"
96
+ type: :development
97
+ name: cucumber
98
+ prerelease: false
99
+ version_requirements: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ requirement: &id006 !ruby/object:Gem::Requirement
102
+ none: false
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ hash: 23
107
+ segments:
108
+ - 0
109
+ - 2
110
+ - 0
111
+ version: 0.2.0
112
+ type: :development
113
+ name: aruba
114
+ prerelease: false
115
+ version_requirements: *id006
116
+ - !ruby/object:Gem::Dependency
117
+ requirement: &id007 !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ hash: 49
123
+ segments:
124
+ - 0
125
+ - 8
126
+ - 7
127
+ version: 0.8.7
128
+ type: :development
129
+ name: rake
130
+ prerelease: false
131
+ version_requirements: *id007
132
+ - !ruby/object:Gem::Dependency
133
+ requirement: &id008 !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ hash: 5
139
+ segments:
140
+ - 0
141
+ - 6
142
+ - 1
143
+ version: 0.6.1
144
+ type: :development
145
+ name: yard
146
+ prerelease: false
147
+ version_requirements: *id008
148
+ - !ruby/object:Gem::Dependency
149
+ requirement: &id009 !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ hash: 5
155
+ segments:
156
+ - 1
157
+ - 6
158
+ - 5
159
+ version: 1.6.5
160
+ type: :development
161
+ name: rdiscount
162
+ prerelease: false
163
+ version_requirements: *id009
164
+ description: Command line octal file permissions
165
+ email:
166
+ - robert@gearheadforhire.com
167
+ executables:
168
+ - oct
169
+ extensions: []
170
+
171
+ extra_rdoc_files: []
172
+
173
+ files:
174
+ - .gitattributes
175
+ - .gitignore
176
+ - .yardopts
177
+ - Gemfile
178
+ - Gemfile.lock
179
+ - HISTORY.markdown
180
+ - LICENSE
181
+ - README.markdown
182
+ - Rakefile
183
+ - TODO.markdown
184
+ - VERSION
185
+ - bin/oct
186
+ - config/cucumber.yml
187
+ - features/bin.feature
188
+ - features/oct.feature
189
+ - features/step_definitions/.gitignore
190
+ - features/step_definitions/oct_steps.rb
191
+ - features/support/aruba.rb
192
+ - features/support/env.rb
193
+ - lib/oct.rb
194
+ - lib/oct/app.rb
195
+ - lib/oct/oct.rb
196
+ - oct.gemspec
197
+ - spec/basic_gem/basic_gem_spec.rb
198
+ - spec/spec.opts
199
+ - spec/spec_helper.rb
200
+ - spec/watchr.rb
201
+ has_rdoc: yard
202
+ homepage: http://rubygems.org/gems/oct
203
+ licenses: []
204
+
205
+ post_install_message:
206
+ rdoc_options:
207
+ - --title
208
+ - Oct Documentation
209
+ - --main
210
+ - README.markdown
211
+ - --line-numbers
212
+ - --inline-source
213
+ require_paths:
214
+ - lib
215
+ required_ruby_version: !ruby/object:Gem::Requirement
216
+ none: false
217
+ requirements:
218
+ - - ">="
219
+ - !ruby/object:Gem::Version
220
+ hash: 3
221
+ segments:
222
+ - 0
223
+ version: "0"
224
+ required_rubygems_version: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ hash: 23
230
+ segments:
231
+ - 1
232
+ - 3
233
+ - 6
234
+ version: 1.3.6
235
+ requirements: []
236
+
237
+ rubyforge_project: oct
238
+ rubygems_version: 1.3.7
239
+ signing_key:
240
+ specification_version: 3
241
+ summary: Command line octal file permissions
242
+ test_files: []
243
+