mutagem 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gemfiles ADDED
@@ -0,0 +1,32 @@
1
+ .gemfiles
2
+ .gitattributes
3
+ .gitignore
4
+ .yardopts
5
+ Gemfile
6
+ Gemfile.lock
7
+ HISTORY.markdown
8
+ LICENSE
9
+ README.markdown
10
+ Rakefile
11
+ TODO.markdown
12
+ VERSION
13
+ config/cucumber.yml
14
+ features/mutex.feature
15
+ features/step_definitions/.gitignore
16
+ features/step_definitions/mutagem_steps.rb
17
+ features/support/env.rb
18
+ features/task.feature
19
+ lib/mutagem.rb
20
+ lib/mutagem/lockfile.rb
21
+ lib/mutagem/mutex.rb
22
+ lib/mutagem/task.rb
23
+ mutagem.gemspec
24
+ spec/aruba_helper.rb
25
+ spec/basic_gem/aruba_helper_spec.rb
26
+ spec/basic_gem/basic_gem_spec.rb
27
+ spec/basic_gem/gemspec_spec.rb
28
+ spec/mutagem/lockfile_spec.rb
29
+ spec/mutagem/mutex_spec.rb
30
+ spec/spec.opts
31
+ spec/spec_helper.rb
32
+ spec/watchr.rb
data/.gitignore CHANGED
@@ -8,4 +8,3 @@ rerun.txt
8
8
  tags
9
9
  tmp/fixtures
10
10
  tmp/aruba
11
-
data/.yardopts CHANGED
@@ -1,5 +1,5 @@
1
1
  --verbose
2
- --list-undoc
3
2
  -
4
3
  LICENSE
5
4
  HISTORY.markdown
5
+ VERSION
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :gemcutter
1
+ source :rubygems
2
2
 
3
3
  # Specify your gem's dependencies in the .gemspec file
4
4
  gemspec
data/Gemfile.lock CHANGED
@@ -1,44 +1,39 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mutagem (0.1.3)
4
+ mutagem (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
- aruba (0.2.3)
10
- background_process
11
- cucumber (~> 0.9.0)
12
- background_process (1.2)
9
+ aruba (0.2.2)
13
10
  builder (2.1.2)
14
- cucumber (0.9.0)
11
+ cucumber (0.9.4)
15
12
  builder (~> 2.1.2)
16
13
  diff-lcs (~> 1.1.2)
17
- gherkin (~> 2.2.2)
14
+ gherkin (~> 2.2.9)
18
15
  json (~> 1.4.6)
19
16
  term-ansicolor (~> 1.0.5)
20
17
  diff-lcs (1.1.2)
21
- gherkin (2.2.4)
18
+ gherkin (2.2.9)
22
19
  json (~> 1.4.6)
23
20
  term-ansicolor (~> 1.0.5)
24
- trollop (~> 1.16.2)
25
21
  json (1.4.6)
22
+ kramdown (0.12.0)
26
23
  rake (0.8.7)
27
- rdiscount (1.6.5)
28
- rspec (1.3.0)
24
+ rspec (1.3.1)
29
25
  term-ansicolor (1.0.5)
30
- trollop (1.16.2)
31
- yard (0.6.1)
26
+ yard (0.6.2)
32
27
 
33
28
  PLATFORMS
34
29
  ruby
35
30
 
36
31
  DEPENDENCIES
37
- aruba (>= 0.2.0)
38
- bundler (>= 1.0.0)
39
- cucumber (>= 0.6)
32
+ aruba (>= 0.2.2)
33
+ bundler (>= 1.0.7)
34
+ cucumber (>= 0.9.4)
35
+ kramdown (>= 0.12.0)
40
36
  mutagem!
41
37
  rake (>= 0.8.7)
42
- rdiscount (>= 1.6.5)
43
- rspec (>= 1.2.9)
44
- yard (>= 0.6.1)
38
+ rspec (= 1.3.1)
39
+ yard (>= 0.6.2)
data/HISTORY.markdown CHANGED
@@ -6,6 +6,10 @@ Most recent changes are at the top
6
6
  Changes
7
7
  -------
8
8
 
9
+ ### 0.2.0 - 12/29/2010 ###
10
+
11
+ * running IO tasks directly without threads for Windows compatibility
12
+
9
13
  ### 0.1.3 - 10/01/2010 ###
10
14
 
11
15
  * initial release
data/README.markdown CHANGED
@@ -6,12 +6,13 @@ A Ruby gem for file based mutexes with a simple external process management wrap
6
6
 
7
7
  Overview
8
8
  --------
9
- The Mutagem library provides file based mutexes for recursion protection and wrapper classes for
10
- threading of external processes with support for output and exit status capturing.
9
+ The Mutagem library provides file based mutexes for recursion protection and wrapper classes for
10
+ external processes with support for output and exit status capturing.
11
11
 
12
- A test suite is provided for both unit testing with [RSpec](http://github.com/dchelimsky/rspec)
13
- and functional testing with [Cucumber](http://github.com/aslakhellesoy/cucumber). The code is
14
- documented using [YARD](http://github.com/lsegal/yard).
12
+ A test suite is provided for both unit testing with [RSpec](http://github.com/dchelimsky/rspec)
13
+ and functional testing with [Cucumber](http://github.com/aslakhellesoy/cucumber). The code is
14
+ documented using [YARD](http://github.com/lsegal/yard). Mutagem development was jump-started by
15
+ cloning [BasicGem](http://github.com/robertwahler/basic_gem).
15
16
 
16
17
 
17
18
  Example Usage
@@ -20,13 +21,13 @@ The following Ruby code is used to run a word by word diff on two folders of com
20
21
  Each folder contains before and after CSV dumps from a SQL database. The CSV files have the same name
21
22
  in each of the two folders.
22
23
 
23
- Mutagem is providing recursion protection. The recursion protection is very useful if the script is
24
- run in an automated environment (ex. cron). Mutagem is also capturing output and exit status for the
25
- diff processes allowing customized output.
24
+ Mutagem is providing recursion protection. The recursion protection is very useful if the script is
25
+ run in an automated environment (ex. cron). Mutagem is also capturing output and exit status for the
26
+ diff processes allowing customized output.
26
27
 
27
- Standard diff is quick but it can't give you a word by word diff of CSV data. Word by word
28
- colorized diffing with support for custom delimiters is provided
29
- by [dwdiff](http://os.ghalkes.nl/dwdiff.html).
28
+ Standard diff is quick but it can't give you a word by word diff of CSV data. Word by word
29
+ colorized diffing with support for custom delimiters is provided
30
+ by [dwdiff](http://os.ghalkes.nl/dwdiff.html).
30
31
 
31
32
 
32
33
  #!/usr/bin/env ruby
@@ -48,23 +49,23 @@ by [dwdiff](http://os.ghalkes.nl/dwdiff.html).
48
49
  before_files.each do |bf|
49
50
 
50
51
  af = 'test/dump/after/' + Pathname.new(bf).basename.to_s
51
-
52
+
52
53
  # quick diff
53
54
  cmd = "diff #{bf} #{af}"
54
55
  task = Mutagem::Task.new(cmd)
55
- task.join
56
+ task.run
56
57
 
57
58
  if (task.exitstatus == 0)
58
59
  # no changes, show a "still working" indicator
59
60
  print ".".green
60
61
  else
61
- # we have changes, slow diff, word based and CSV (comma) sensitive
62
+ # we have changes, slow diff, word based and CSV (comma) sensitive
62
63
  print "D".red
63
64
  puts "\n#{af}"
64
-
65
+
65
66
  cmd = "dwdiff --color --context=0 --delimiters=, #{bf} #{af}"
66
67
  task = Mutagem::Task.new(cmd)
67
- task.join
68
+ task.run
68
69
 
69
70
  puts task.output
70
71
  end
@@ -92,7 +93,7 @@ Development
92
93
  -----------
93
94
 
94
95
  Mutagem uses [Bundler](http://github.com/carlhuda/bundler) to manage dependencies, the gemspec
95
- file is maintained by hand.
96
+ file is maintained by hand.
96
97
 
97
98
  git clone http://github.com/robertwahler/mutagem
98
99
  cd mutagem
data/Rakefile CHANGED
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
 
3
- # bundler/setup is managing $LOAD_PATH, any gem needed by this Rakefile must
3
+ # bundler/setup is managing $LOAD_PATH, any gem needed by this Rakefile must
4
4
  # be listed as a development dependency in the gemspec
5
5
 
6
6
  require 'rubygems'
7
- require 'bundler/setup'
7
+ require 'bundler/setup'
8
8
 
9
9
  Bundler::GemHelper.install_tasks
10
10
 
@@ -41,8 +41,7 @@ namespace :doc do
41
41
  require 'yard/rake/yardoc_task'
42
42
 
43
43
  YARD::Rake::YardocTask.new(:generate) do |yt|
44
- yt.options = ['--markup-provider', 'rdiscount',
45
- '--output-dir', doc_destination
44
+ yt.options = ['--output-dir', doc_destination
46
45
  ] +
47
46
  gemspec.rdoc_options - ['--line-numbers', '--inline-source']
48
47
  end
@@ -52,4 +51,9 @@ namespace :doc do
52
51
  rm_r doc_destination if File.exists?(doc_destination)
53
52
  end
54
53
 
54
+ desc "List undocumented objects"
55
+ task :undocumented do
56
+ system('yard stats --list-undoc')
57
+ end
58
+
55
59
  end
data/TODO.markdown CHANGED
@@ -1,6 +1,4 @@
1
1
  TODO
2
2
  ====
3
3
 
4
- * update readme with examples of dwdiff usage
5
- * add tasker
6
- * test under Windows/Cygwin
4
+ * use kramdown, instead of rdiscount when yard patch pulled
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -9,7 +9,7 @@
9
9
  require 'mutagem'
10
10
 
11
11
  # make sure we are working with the expected gem
12
- raise "unexpected mutagem version" unless Mutagem::VERSION == '#{Mutagem::VERSION}'
12
+ raise "unexpected mutagem version" unless Mutagem::version == '#{Mutagem::version}'
13
13
 
14
14
  mutext = Mutagem::Mutex.new
15
15
  mutext.execute do
@@ -31,14 +31,14 @@
31
31
  require 'mutagem'
32
32
 
33
33
  # make sure we are working with the expected gem
34
- raise "unexpected mutagem version" unless Mutagem::VERSION == '#{Mutagem::VERSION}'
34
+ raise "unexpected mutagem version" unless Mutagem::version == '#{Mutagem::version}'
35
35
 
36
36
  cmd = %q[ruby -e 'puts "hello world"; exit 2']
37
37
  task = Mutagem::Task.new(cmd)
38
38
  task.join
39
39
 
40
40
  puts task.output
41
- exit task.exitstatus
41
+ exit task.exitstatus
42
42
  """
43
43
  }
44
44
  end
@@ -1,4 +1,6 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'rubygems'
2
3
  require 'mutagem'
3
- require 'aruba'
4
4
  require 'spec/expectations'
5
+ require 'aruba'
6
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec/aruba_helper')
data/lib/mutagem.rb CHANGED
@@ -1,9 +1,29 @@
1
- require 'mutagem/version'
1
+ # require all files here
2
+ require 'rbconfig'
2
3
  require 'mutagem/lockfile'
3
4
  require 'mutagem/mutex'
4
5
  require 'mutagem/task'
5
6
 
7
+ # Master namespace
6
8
  module Mutagem
7
9
 
10
+ # Contents of the VERSION file
11
+ #
12
+ # Example format: 0.0.1
13
+ #
14
+ # @return [String] the contents of the version file in #.#.# format
15
+ def self.version
16
+ version_info_file = File.join(File.dirname(__FILE__), *%w[.. VERSION])
17
+ File.open(version_info_file, "r") do |f|
18
+ f.read.strip
19
+ end
20
+ end
21
+
22
+ # Platform constants
23
+ unless defined?(Mutagem::WINDOWS)
24
+ WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/i
25
+ CYGWIN = Config::CONFIG['host_os'] =~ /cygwin/i
26
+ end
27
+
8
28
  end
9
29
 
data/lib/mutagem/task.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'thread'
2
2
 
3
3
  module Mutagem
4
-
4
+
5
5
  # A simple external process management wrapper
6
6
  #
7
7
  # @example
@@ -16,26 +16,15 @@ module Mutagem
16
16
  class Task
17
17
  # @return [String] command to run
18
18
  attr_reader :cmd
19
- attr_accessor :thread
20
19
 
21
20
  # Create a new Task
22
21
  #
23
22
  # @param [String] cmd the cmd to execute
24
23
  def initialize(cmd)
24
+ $stdout.sync = true
25
25
  @cmd = cmd
26
- @thread = Thread.new do
27
- pipe = IO.popen(cmd + " 2>&1")
28
- @pid = pipe.pid
29
- begin
30
- @output = pipe.readlines
31
- pipe.close
32
- @exitstatus = $?.exitstatus
33
- rescue => e
34
- @exception = e
35
- end
36
- end
37
26
  end
38
-
27
+
39
28
  # @return [Array] array of strings from the subprocess output
40
29
  def output
41
30
  @output
@@ -46,7 +35,7 @@ def exitstatus
46
35
  @exitstatus
47
36
  end
48
37
 
49
- # @return subprocess pid
38
+ # @return subprocess pid
50
39
  def pid
51
40
  @pid
52
41
  end
@@ -55,11 +44,20 @@ def pid
55
44
  def exception
56
45
  @exception
57
46
  end
58
-
59
- # join the task's thead and wait for it to finish
60
- def join
61
- thread.join
47
+
48
+ # run the cmd
49
+ def run
50
+ pipe = IO.popen(@cmd + " 2>&1")
51
+ @pid = pipe.pid
52
+ begin
53
+ @output = pipe.readlines
54
+ pipe.close
55
+ @exitstatus = $?.exitstatus
56
+ rescue => e
57
+ @exception = e
58
+ end
62
59
  end
60
+ alias :join :run
63
61
 
64
62
  end
65
63
 
data/mutagem.gemspec CHANGED
@@ -1,40 +1,67 @@
1
1
  # -*- encoding: utf-8 -*-
2
- require File.expand_path("../lib/mutagem/version", __FILE__)
2
+ #
3
+ #
3
4
 
4
5
  Gem::Specification.new do |s|
6
+
7
+ # wrap 'git' so we can get gem files even on systems without 'git'
8
+ #
9
+ # @see spec/gemspec_spec.rb
10
+ #
11
+ @gemfiles ||= begin
12
+ filename = File.join(File.dirname(__FILE__), '.gemfiles')
13
+ # backticks blows up on Windows w/o valid binary, use system instead
14
+ if File.directory?('.git') && system('git ls-files bogus-filename')
15
+ files = `git ls-files`
16
+ cached_files = File.exists?(filename) ? File.open(filename, "r") {|f| f.read} : nil
17
+ # maintain EOL
18
+ files.gsub!(/\n/, "\r\n") if cached_files && cached_files.match("\r\n")
19
+ File.open(filename, 'wb') {|f| f.write(files)} if cached_files != files
20
+ else
21
+ files = File.open(filename, "r") {|f| f.read}
22
+ end
23
+ raise "unable to process gemfiles" unless files
24
+ files.gsub(/\r\n/, "\n")
25
+ end
26
+
5
27
  s.name = "mutagem"
6
- s.version = Mutagem::VERSION
28
+ s.version = File.open(File.join(File.dirname(__FILE__), 'VERSION'), "r") { |f| f.read }
7
29
  s.platform = Gem::Platform::RUBY
8
30
  s.authors = ["Robert Wahler"]
9
31
  s.email = ["robert@gearheadforhire.com"]
10
32
  s.homepage = "http://rubygems.org/gems/mutagem"
11
33
  s.summary = "File based mutexes with a simple external process management wrapper"
12
- s.description = "The Mutagem library provides file based mutexes for recursion protection and
13
- classes for threading of external processes with support for output and
34
+ s.description = "The Mutagem library provides file based mutexes for recursion protection and
35
+ classes for threading of external processes with support for output and
14
36
  exit status capturing. A test suite is provided for both unit and functional testing.
15
37
  The code is documented using YARD."
16
38
 
17
39
  s.required_rubygems_version = ">= 1.3.6"
18
40
  s.rubyforge_project = "mutagem"
19
41
 
20
- s.add_development_dependency "bundler", ">= 1.0.0"
21
- s.add_development_dependency "rspec", ">= 1.2.9"
22
- s.add_development_dependency "cucumber", ">= 0.6"
23
- s.add_development_dependency "aruba", ">= 0.2.0"
42
+ s.add_development_dependency "bundler", ">= 1.0.7"
43
+ s.add_development_dependency "rspec", "= 1.3.1"
44
+ s.add_development_dependency "cucumber", ">= 0.9.4"
45
+ s.add_development_dependency "aruba", ">= 0.2.2"
24
46
  s.add_development_dependency "rake", ">= 0.8.7"
25
- s.add_development_dependency "yard", ">= 0.6.1"
26
- s.add_development_dependency "rdiscount", ">= 1.6.5"
47
+ s.add_development_dependency "yard", ">= 0.6.2"
48
+
49
+ # Specify a markdown gem for rake doc:generate
50
+ #
51
+ # Without the development dependency, running yard rake
52
+ # tasks will fail. Kramdown chosen to provide a pure Ruby solution.
53
+ s.add_development_dependency "kramdown", ">= 0.12.0"
54
+
55
+ s.files = @gemfiles.split("\n")
56
+ s.executables = @gemfiles.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
27
57
 
28
- s.files = `git ls-files`.split("\n")
29
- s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
30
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
31
58
  s.require_path = 'lib'
32
59
 
33
60
  s.has_rdoc = 'yard'
34
- s.rdoc_options = [
35
- '--title', 'Mutagem Documentation',
36
- '--main', 'README.markdown',
61
+ s.rdoc_options = [
62
+ '--title', 'Mutagem Documentation',
63
+ '--main', 'README.markdown',
37
64
  '--line-numbers',
38
- '--inline-source'
65
+ '--inline-source'
39
66
  ]
40
67
  end
@@ -0,0 +1,25 @@
1
+ module Aruba
2
+ module Api
3
+
4
+ # @return full path to files in the aruba tmp folder
5
+ def fullpath(filename)
6
+ path = File.expand_path(File.join(current_dir, filename))
7
+ if path.match(/^\/cygdrive/)
8
+ # match /cygdrive/c/path/to and return c:\\path\\to
9
+ path = `cygpath -w #{path}`.chomp
10
+ elsif path.match(/.\:/)
11
+ # match c:/path/to and return c:\\path\\to
12
+ path = path.gsub(/\//, '\\')
13
+ end
14
+ path
15
+ end
16
+
17
+ # @return the contents of "filename" in the aruba tmp folder
18
+ def get_file_contents(filename)
19
+ in_current_dir do
20
+ IO.read(filename)
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Mutagem do
4
+
5
+ before(:each) do
6
+ @filename = 'input.txt'
7
+ create_file(@filename, "the quick brown fox")
8
+ end
9
+
10
+ describe 'aruba current_dir' do
11
+
12
+ it "should return the current dir as 'tmp/aruba'" do
13
+ current_dir.should match(/^tmp\/aruba$/)
14
+ end
15
+ end
16
+
17
+ describe "aruba_helper fullpath('input.txt')" do
18
+
19
+ it "should return a valid expanded path to 'input.txt'" do
20
+ path = fullpath('input.txt')
21
+ path.should match(/tmp..*aruba/)
22
+ File.exists?(path).should == true
23
+ end
24
+ end
25
+
26
+ describe "aruba_helper get_file_contents('input.txt')" do
27
+
28
+ it "should return the contents of 'input.txt' as a String" do
29
+ get_file_contents('input.txt').should == 'the quick brown fox'
30
+ end
31
+ end
32
+
33
+ end
@@ -1,13 +1,79 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe Mutagem do
4
-
5
- describe 'VERSION' do
4
+
5
+ describe 'version' do
6
6
 
7
7
  it "should return a string formatted '#.#.#'" do
8
- Mutagem::VERSION.should match(/(^[\d]+\.[\d]+\.[\d]+$)/)
8
+ Mutagem::version.should match(/(^[\d]+\.[\d]+\.[\d]+$)/)
9
9
  end
10
10
 
11
11
  end
12
12
 
13
+ # VIM autocmd to remove trailing whitespace
14
+ # autocmd BufWritePre * :%s/\s\+$//e
15
+ #
16
+ describe "code" do
17
+
18
+ before(:each) do
19
+ @gemfiles_filename = File.expand_path(File.dirname(__FILE__) + '/../../.gemfiles')
20
+ @gemfiles = File.open(@gemfiles_filename, "r") {|f| f.read}
21
+ @eol = @gemfiles.match("\r\n") ? "\r\n" : "\n"
22
+ end
23
+
24
+ def binary?(filename)
25
+ open filename do |f|
26
+ f.each_byte { |x|
27
+ x.nonzero? or return true
28
+ }
29
+ end
30
+ false
31
+ end
32
+
33
+ def check_for_tab_characters(filename)
34
+ failing_lines = []
35
+ File.readlines(filename).each_with_index do |line,number|
36
+ failing_lines << number + 1 if line =~ /\t/
37
+ end
38
+
39
+ unless failing_lines.empty?
40
+ "#{filename} has tab characters on lines #{failing_lines.join(', ')}"
41
+ end
42
+ end
43
+
44
+ def check_for_extra_spaces(filename)
45
+ failing_lines = []
46
+ File.readlines(filename).each_with_index do |line,number|
47
+ next if line =~ /^\s+#.*\s+#{@eol}$/
48
+ failing_lines << number + 1 if line =~ /\s+#{@eol}$/
49
+ end
50
+
51
+ unless failing_lines.empty?
52
+ "#{filename} has spaces on the EOL on lines #{failing_lines.join(', ')}"
53
+ end
54
+ end
55
+
56
+ Spec::Matchers.define :be_well_formed do
57
+ failure_message_for_should do |actual|
58
+ actual.join("\n")
59
+ end
60
+
61
+ match do |actual|
62
+ actual.empty?
63
+ end
64
+ end
65
+
66
+ it "has no malformed whitespace" do
67
+ error_messages = []
68
+ @gemfiles.split(@eol).each do |filename|
69
+ filename = File.expand_path(File.join(File.dirname(__FILE__), ["..", "..", filename]))
70
+ next if filename =~ /\.gitmodules/
71
+ next if binary?(filename)
72
+ error_messages << check_for_tab_characters(filename)
73
+ error_messages << check_for_extra_spaces(filename)
74
+ end
75
+ error_messages.compact.should be_well_formed
76
+ end
77
+
78
+ end
13
79
  end
@@ -0,0 +1,68 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe Mutagem do
4
+
5
+ def load_gemspec
6
+ filename = File.expand_path('../../../mutagem.gemspec', __FILE__)
7
+ eval(File.read(filename), nil, filename)
8
+ end
9
+
10
+ describe 'gemspec' do
11
+
12
+ it "should return the gem VERSION" do
13
+ @gemspec = load_gemspec
14
+ Mutagem::version.should_not be_nil
15
+ @gemspec.version.to_s.should == Mutagem::version
16
+ end
17
+
18
+ describe 'files' do
19
+
20
+ it "should return 'files' array" do
21
+ @gemspec = load_gemspec
22
+ @gemspec.files.is_a?(Array).should == true
23
+ @gemspec.files.include?('VERSION').should == true
24
+ end
25
+ it "should return 'executables' array" do
26
+ @gemspec = load_gemspec
27
+ @gemspec.executables.is_a?(Array).should == true
28
+ end
29
+
30
+ describe 'without a git repo' do
31
+ before(:each) do
32
+ File.stub!('directory?').and_return false
33
+ @gemspec = load_gemspec
34
+ end
35
+
36
+ it "should return 'files' from cache" do
37
+ File.directory?(File.expand_path('../../../.git', __FILE__)).should == false
38
+ @gemspec.files.is_a?(Array).should == true
39
+ @gemspec.files.include?('VERSION').should == true
40
+ end
41
+ it "should return 'executables' from cache" do
42
+ File.directory?(File.expand_path('../../../.git', __FILE__)).should == false
43
+ @gemspec.executables.is_a?(Array).should == true
44
+ end
45
+ end
46
+
47
+ describe 'without git binary' do
48
+
49
+ before(:each) do
50
+ stub!(:system).and_return false
51
+ @gemspec = load_gemspec
52
+ end
53
+
54
+ it "should return 'files' from cache" do
55
+ system('git --version').should == false
56
+ @gemspec.files.is_a?(Array).should == true
57
+ @gemspec.files.include?('VERSION').should == true
58
+ end
59
+ it "should return 'executables' from cache" do
60
+ system('git --version').should == false
61
+ @gemspec.executables.is_a?(Array).should == true
62
+ end
63
+
64
+ end
65
+ end
66
+
67
+ end
68
+ end
@@ -1,12 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe Mutagem::Lockfile do
4
-
4
+
5
5
  before(:each) do
6
6
  # remove tmp/aruba
7
7
  FileUtils.rm_rf(current_dir)
8
8
  end
9
-
9
+
10
10
  it "should raise ArgumentError if initialized without a lock filename" do
11
11
  in_current_dir do
12
12
  lambda {Mutagem::Lockfile.new}.should raise_error(ArgumentError, 'lockfile not specified')
@@ -1,12 +1,12 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
3
  describe Mutagem::Mutex do
4
-
4
+
5
5
  before(:each) do
6
6
  # remove tmp/aruba
7
7
  FileUtils.rm_rf(current_dir)
8
8
  end
9
-
9
+
10
10
  it "should create a mutex, yield, and clean up" do
11
11
  in_current_dir do
12
12
  mutex = Mutagem::Mutex.new
data/spec/spec_helper.rb CHANGED
@@ -8,11 +8,7 @@
8
8
  require 'spec'
9
9
  require 'spec/autorun'
10
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
11
+ require 'aruba_helper'
16
12
 
17
13
  Spec::Runner.configure do |config|
18
14
  config.include Aruba::Api
data/spec/watchr.rb CHANGED
@@ -1,12 +1,25 @@
1
1
  # Watchr: Autotest like functionality
2
2
  #
3
+ # gem install watchr
4
+ #
3
5
  # Run me with:
4
6
  #
5
7
  # $ watchr spec/watchr.rb
6
8
 
7
9
  require 'term/ansicolor'
10
+ require 'rbconfig'
11
+
12
+ WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/i unless defined?(WINDOWS)
13
+ require 'win32/process' if WINDOWS
8
14
 
9
- $c = Term::ANSIColor
15
+ if WINDOWS
16
+ begin
17
+ require 'Win32/Console/ANSI'
18
+ $c = Term::ANSIColor
19
+ rescue LoadError
20
+ STDERR.puts 'WARNING: You must "gem install win32console" (1.2.0 or higher) to get color output on MRI/Windows'
21
+ end
22
+ end
10
23
 
11
24
  def getch
12
25
  state = `stty -g`
@@ -26,21 +39,27 @@ def all_feature_files
26
39
  end
27
40
 
28
41
  def all_spec_files
29
- files = Dir['spec/revenc/*.rb']
42
+ files = Dir['spec/**/*_spec\.rb']
30
43
  end
31
44
 
32
45
  def run(cmd)
33
46
 
34
47
  pid = fork do
48
+
35
49
  puts "\n"
36
- print $c.cyan, cmd, $c.clear, "\n"
50
+ if $c
51
+ print $c.cyan, cmd, $c.clear, "\n"
52
+ else
53
+ puts cmd
54
+ end
55
+
37
56
  exec(cmd)
38
57
  end
39
58
  Signal.trap('INT') do
40
59
  puts "sending KILL to pid: #{pid}"
41
60
  Process.kill("KILL", pid)
42
61
  end
43
- Process.waitpid(pid)
62
+ Process.waitpid(pid) if (pid > 0)
44
63
 
45
64
  prompt
46
65
  end
@@ -72,18 +91,17 @@ def run_last_feature
72
91
  end
73
92
 
74
93
  def run_default_spec
75
- cmd = "spec --color --format s ./spec"
94
+ cmd = "spec _1.3.1_ --color --format s ./spec"
76
95
  run(cmd)
77
96
  end
78
97
 
79
98
  def run_all_specs
80
- cmd = "spec --color --format s #{all_spec_files.join(' ')}"
81
- p cmd
99
+ cmd = "spec _1.3.1_ --color --format s #{all_spec_files.join(' ')}"
82
100
  run(cmd)
83
101
  end
84
102
 
85
103
  def run_spec(spec)
86
- cmd = "spec --color --format s #{spec}"
104
+ cmd = "spec _1.3.1_ --color --format s #{spec}"
87
105
  $last_spec = spec
88
106
  run(cmd)
89
107
  end
@@ -93,7 +111,10 @@ def run_last_spec
93
111
  end
94
112
 
95
113
  def prompt
96
- puts "Ctrl-\\ for menu, Ctrl-C to quit"
114
+ menu = "Ctrl-C to quit"
115
+ menu = menu + ", Ctrl-\\ for menu" if Signal.list.include?('QUIT')
116
+
117
+ puts menu
97
118
  end
98
119
 
99
120
  # init
@@ -103,7 +124,6 @@ def prompt
103
124
  # --------------------------------------------------
104
125
  # Watchr Rules
105
126
  # --------------------------------------------------
106
- #watch( '^features/(.*)\.feature' ) { |m| run_feature(m[0]) }
107
127
  watch( '^features/(.*)\.feature' ) { run_default_cucumber }
108
128
 
109
129
  watch( '^bin/(.*)' ) { run_default_cucumber }
@@ -113,30 +133,32 @@ def prompt
113
133
  watch( '^features/support/(.*)\.rb' ) { run_default_cucumber }
114
134
 
115
135
  watch( '^spec/(.*)_spec\.rb' ) { |m| run_spec(m[0]) }
116
- # watch( '^lib/revenc/io.rb' ) { run_default_spec }
117
- watch( '^lib/revenc/errors.rb' ) { run_default_spec }
118
- watch( '^lib/revenc/lockfile.rb' ) { run_default_spec }
136
+ # specify just the lib files that have specs
137
+ # TODO: This can be determined automatically from the spec file naming convention
138
+ watch( '^lib/mutagem/lockfile.rb' ) { run_default_spec }
139
+ watch( '^lib/mutagem/mutex.rb' ) { run_default_spec }
119
140
 
120
141
  # --------------------------------------------------
121
- # Signal Handling
142
+ # Signal Handling (May not be supported on Windows)
122
143
  # --------------------------------------------------
144
+ if Signal.list.include?('QUIT')
145
+ # Ctrl-\
146
+ Signal.trap('QUIT') do
147
+
148
+ puts "\n\nMENU: a = all , f = features s = specs, l = last feature (#{$last_feature ? $last_feature : 'none'}), q = quit\n\n"
149
+ c = getch
150
+ puts c.chr
151
+ if c.chr == "a"
152
+ run_all
153
+ elsif c.chr == "f"
154
+ run_default_cucumber
155
+ elsif c.chr == "s"
156
+ run_all_specs
157
+ elsif c.chr == "q"
158
+ abort("exiting\n")
159
+ elsif c.chr == "l"
160
+ run_last_feature
161
+ end
123
162
 
124
- # Ctrl-\
125
- Signal.trap('QUIT') do
126
-
127
- puts "\n\nMENU: a = all , f = features s = specs, l = last feature (#{$last_feature ? $last_feature : 'none'}), q = quit\n\n"
128
- c = getch
129
- puts c.chr
130
- if c.chr == "a"
131
- run_all
132
- elsif c.chr == "f"
133
- run_default_cucumber
134
- elsif c.chr == "s"
135
- run_all_specs
136
- elsif c.chr == "q"
137
- abort("exiting\n")
138
- elsif c.chr == "l"
139
- run_last_feature
140
163
  end
141
-
142
164
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mutagem
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 23
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 1
8
- - 3
9
- version: 0.1.3
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Robert Wahler
@@ -14,116 +15,124 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-10-01 00:00:00 -04:00
18
+ date: 2011-01-13 00:00:00 -05:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
22
+ type: :development
21
23
  name: bundler
22
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
23
26
  none: false
24
27
  requirements:
25
28
  - - ">="
26
29
  - !ruby/object:Gem::Version
30
+ hash: 25
27
31
  segments:
28
32
  - 1
29
33
  - 0
30
- - 0
31
- version: 1.0.0
32
- type: :development
33
- prerelease: false
34
- version_requirements: *id001
34
+ - 7
35
+ version: 1.0.7
36
+ requirement: *id001
35
37
  - !ruby/object:Gem::Dependency
38
+ type: :development
36
39
  name: rspec
37
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ prerelease: false
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
38
42
  none: false
39
43
  requirements:
40
- - - ">="
44
+ - - "="
41
45
  - !ruby/object:Gem::Version
46
+ hash: 25
42
47
  segments:
43
48
  - 1
44
- - 2
45
- - 9
46
- version: 1.2.9
47
- type: :development
48
- prerelease: false
49
- version_requirements: *id002
49
+ - 3
50
+ - 1
51
+ version: 1.3.1
52
+ requirement: *id002
50
53
  - !ruby/object:Gem::Dependency
54
+ type: :development
51
55
  name: cucumber
52
- requirement: &id003 !ruby/object:Gem::Requirement
56
+ prerelease: false
57
+ version_requirements: &id003 !ruby/object:Gem::Requirement
53
58
  none: false
54
59
  requirements:
55
60
  - - ">="
56
61
  - !ruby/object:Gem::Version
62
+ hash: 51
57
63
  segments:
58
64
  - 0
59
- - 6
60
- version: "0.6"
61
- type: :development
62
- prerelease: false
63
- version_requirements: *id003
65
+ - 9
66
+ - 4
67
+ version: 0.9.4
68
+ requirement: *id003
64
69
  - !ruby/object:Gem::Dependency
70
+ type: :development
65
71
  name: aruba
66
- requirement: &id004 !ruby/object:Gem::Requirement
72
+ prerelease: false
73
+ version_requirements: &id004 !ruby/object:Gem::Requirement
67
74
  none: false
68
75
  requirements:
69
76
  - - ">="
70
77
  - !ruby/object:Gem::Version
78
+ hash: 19
71
79
  segments:
72
80
  - 0
73
81
  - 2
74
- - 0
75
- version: 0.2.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: *id004
82
+ - 2
83
+ version: 0.2.2
84
+ requirement: *id004
79
85
  - !ruby/object:Gem::Dependency
86
+ type: :development
80
87
  name: rake
81
- requirement: &id005 !ruby/object:Gem::Requirement
88
+ prerelease: false
89
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
90
  none: false
83
91
  requirements:
84
92
  - - ">="
85
93
  - !ruby/object:Gem::Version
94
+ hash: 49
86
95
  segments:
87
96
  - 0
88
97
  - 8
89
98
  - 7
90
99
  version: 0.8.7
91
- type: :development
92
- prerelease: false
93
- version_requirements: *id005
100
+ requirement: *id005
94
101
  - !ruby/object:Gem::Dependency
102
+ type: :development
95
103
  name: yard
96
- requirement: &id006 !ruby/object:Gem::Requirement
104
+ prerelease: false
105
+ version_requirements: &id006 !ruby/object:Gem::Requirement
97
106
  none: false
98
107
  requirements:
99
108
  - - ">="
100
109
  - !ruby/object:Gem::Version
110
+ hash: 3
101
111
  segments:
102
112
  - 0
103
113
  - 6
104
- - 1
105
- version: 0.6.1
114
+ - 2
115
+ version: 0.6.2
116
+ requirement: *id006
117
+ - !ruby/object:Gem::Dependency
106
118
  type: :development
119
+ name: kramdown
107
120
  prerelease: false
108
- version_requirements: *id006
109
- - !ruby/object:Gem::Dependency
110
- name: rdiscount
111
- requirement: &id007 !ruby/object:Gem::Requirement
121
+ version_requirements: &id007 !ruby/object:Gem::Requirement
112
122
  none: false
113
123
  requirements:
114
124
  - - ">="
115
125
  - !ruby/object:Gem::Version
126
+ hash: 47
116
127
  segments:
117
- - 1
118
- - 6
119
- - 5
120
- version: 1.6.5
121
- type: :development
122
- prerelease: false
123
- version_requirements: *id007
128
+ - 0
129
+ - 12
130
+ - 0
131
+ version: 0.12.0
132
+ requirement: *id007
124
133
  description: |-
125
- The Mutagem library provides file based mutexes for recursion protection and
126
- classes for threading of external processes with support for output and
134
+ The Mutagem library provides file based mutexes for recursion protection and
135
+ classes for threading of external processes with support for output and
127
136
  exit status capturing. A test suite is provided for both unit and functional testing.
128
137
  The code is documented using YARD.
129
138
  email:
@@ -135,6 +144,7 @@ extensions: []
135
144
  extra_rdoc_files: []
136
145
 
137
146
  files:
147
+ - .gemfiles
138
148
  - .gitattributes
139
149
  - .gitignore
140
150
  - .yardopts
@@ -145,6 +155,7 @@ files:
145
155
  - README.markdown
146
156
  - Rakefile
147
157
  - TODO.markdown
158
+ - VERSION
148
159
  - config/cucumber.yml
149
160
  - features/mutex.feature
150
161
  - features/step_definitions/.gitignore
@@ -155,9 +166,11 @@ files:
155
166
  - lib/mutagem/lockfile.rb
156
167
  - lib/mutagem/mutex.rb
157
168
  - lib/mutagem/task.rb
158
- - lib/mutagem/version.rb
159
169
  - mutagem.gemspec
170
+ - spec/aruba_helper.rb
171
+ - spec/basic_gem/aruba_helper_spec.rb
160
172
  - spec/basic_gem/basic_gem_spec.rb
173
+ - spec/basic_gem/gemspec_spec.rb
161
174
  - spec/mutagem/lockfile_spec.rb
162
175
  - spec/mutagem/mutex_spec.rb
163
176
  - spec/spec.opts
@@ -182,7 +195,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
182
195
  requirements:
183
196
  - - ">="
184
197
  - !ruby/object:Gem::Version
185
- hash: 723877775
198
+ hash: 3
186
199
  segments:
187
200
  - 0
188
201
  version: "0"
@@ -191,6 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
204
  requirements:
192
205
  - - ">="
193
206
  - !ruby/object:Gem::Version
207
+ hash: 23
194
208
  segments:
195
209
  - 1
196
210
  - 3
@@ -1,3 +0,0 @@
1
- module Mutagem
2
- VERSION = "0.1.3" unless defined?(::Mutagem::VERSION)
3
- end