fun_with_gems 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWQ2MWFiMGFiMjIzYWZiYmJjM2UzZDZlZTIxZDZlZDZhNGIxNzc1YQ==
4
+ NDBlNDZkZDFkODc4YmNkNDcxYWU0YmFjNGI4ZjBlNjQ5ZmJlZDRhNQ==
5
5
  data.tar.gz: !binary |-
6
- ZWU1MTRmMDBjMzIzMTZlZjJlYzFhMGMxMWNjNTlmZjQ3MWZkNWQ0OA==
6
+ MGY2YjUxZDM3MjJhM2I1ZDI0YzA4ZjBhNWJlYTAxYTA2NDA0ZTBlMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzYxZDVhYzVmNWMxZGE2NWRmYjZjNmRiYzg2YWZmYTg2NzdmYjMzOTFhNjVm
10
- MDczNWE3NGUyNzZkY2NkNGI2MjQwZDBjMTEyNDgzNDc1ZmNmZTI5NzFiZjkz
11
- NzkzY2E1MDZhODkyYjIyNmQwMDk3NzJlMWM2MDY4Nzc2NGEzODY=
9
+ YTY4YzA1NGI5OWNmODU3NzE5ODY3OGI4NzE0YzA3MmVlZGE0ZTI2ZGQxNzIx
10
+ ZGFjMjhlNjBlZjFkNzhmYjk5Y2YyNmIzOGQzZjQxNDQ5ODExYzRkMzY2NDY5
11
+ Mjc4NDJhNGQ2YzA3MGVmYzdkMzIxMjMxZWMxMzdkZDhkZjMyNjg=
12
12
  data.tar.gz: !binary |-
13
- NzQyMTZkZWYxMDI4N2RlYzY3ZjEzODQyZDUwODVmMzQ4NWQ2MDc5NGVlNjBl
14
- ZjMzMTU0OTZjOWFmYzA5ZTczNGZlNDYwOGI0NGRhMWE3NzRiNTlkOWJmNzAy
15
- MDU4MTAxYTcyOWE0MjQzMGEwMjMxOWZkNDM5MjYxZDk5MDUzZDc=
13
+ NDA2OTNjODAwZWRmNjk4NGY0MjIyNGRhZDYwZjI0Nzc3MDcxNWYxYTQwZGI2
14
+ NjkwNWZlYzQ1NDlmYmZhYWIyYjZmMzgzM2EwMTFkNjJmODdiY2ViYjM3ZDBk
15
+ Zjg0M2RmZmQzMmM1NDRhOWYyNDg4OWEyMzY0MjMzNGU1NzI2MDE=
data/CHANGELOG.markdown CHANGED
@@ -1,11 +1,19 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
+ v0.0.3
5
+ ------
6
+
7
+ Moved some of the standard Rakefile boilerplate into FunWith::Gems::Rakefile. Goal is to simplify rakefiles, add a set of fun_with:gems: rake tasks, etc.
8
+ Removed Mechanic (seemed pretty useless)
9
+
10
+
4
11
  v0.0.2
5
12
  ------
6
13
 
7
14
  Dependent on `fun_with_testing` and `fun_with_files`, even `fun_with_version_strings`. It's all very silly, really.
8
15
 
16
+
9
17
  0.0.1
10
18
  -----
11
19
 
data/Gemfile CHANGED
@@ -16,6 +16,6 @@ group :development do
16
16
  gem "fun_with_testing", "~> 0.0"
17
17
  end
18
18
 
19
- gem "fun_with_files", "~> 0.0", ">= 0.0.7"
19
+ gem "fun_with_files", "~> 0.0", ">= 0.0.13"
20
20
  gem "fun_with_version_strings", "~> 0.0", ">= 0.0.3"
21
21
 
data/Rakefile CHANGED
@@ -1,55 +1,23 @@
1
1
  # encoding: utf-8
2
+ require_relative 'lib/fun_with_gems'
2
3
 
3
- require 'rubygems'
4
- require 'bundler'
5
- begin
6
- Bundler.setup(:default, :development)
7
- rescue Bundler::BundlerError => e
8
- $stderr.puts e.message
9
- $stderr.puts "Run `bundle install` to install missing gems"
10
- exit e.status_code
11
- end
12
- require 'rake'
4
+ FunWith::Gems::Rakefile.setup FunWith::Gems, self
13
5
 
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
6
+ # Completely pointless wrapper for Jeweler::Tasks.new
7
+ FunWith::Gems::Rakefile.specification do |gem|
16
8
  # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
- gem.name = "fun_with_gems"
18
- gem.homepage = "http://github.com/darthschmoo/fun_with_gems"
19
- gem.license = "MIT"
20
- gem.summary = "Dependency for most of my FunWith:: gems. Not much use standalone."
9
+ gem.name = "fun_with_gems"
10
+ gem.homepage = "http://github.com/darthschmoo/fun_with_gems"
11
+ gem.license = "MIT"
12
+ gem.summary = "Dependency for most of my FunWith:: gems. Not much use standalone."
21
13
  gem.description = "Dependency for FunWith gems, simplifies the setup of new gems, installing version data, root filepath, and default requirements."
22
- gem.email = "keeputahweird@gmail.com"
23
- gem.authors = ["Bryce Anderson"]
14
+ gem.email = "keeputahweird@gmail.com"
15
+ gem.authors = ["Bryce Anderson"]
24
16
  # dependencies defined in Gemfile
25
17
 
26
18
  gem.files = Dir.glob( File.join( ".", "lib", "**", "*.rb" ) ) +
27
19
  Dir.glob( File.join( ".", "test", "**", "*" ) ) +
28
20
  %w( Gemfile Rakefile LICENSE.txt README.rdoc VERSION CHANGELOG.markdown )
29
21
  end
30
- Jeweler::RubygemsDotOrgTasks.new
31
-
32
- require 'rake/testtask'
33
- Rake::TestTask.new(:test) do |test|
34
- test.libs << 'lib' << 'test'
35
- test.pattern = 'test/**/test_*.rb'
36
- test.verbose = true
37
- end
38
-
39
- desc "Code coverage detail"
40
- task :simplecov do
41
- ENV['COVERAGE'] = "true"
42
- Rake::Task['test'].execute
43
- end
44
-
45
- task :default => :test
46
22
 
47
- require 'rdoc/task'
48
- Rake::RDocTask.new do |rdoc|
49
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
50
-
51
- rdoc.rdoc_dir = 'rdoc'
52
- rdoc.title = "fun_with_gems #{version}"
53
- rdoc.rdoc_files.include('README*')
54
- rdoc.rdoc_files.include('lib/**/*.rb')
55
- end
23
+ FunWith::Gems::Rakefile.setup_gem_boilerplate
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -6,11 +6,17 @@ module FunWith
6
6
  end
7
7
 
8
8
  def validate_gem
9
- FunWith::Gems::Validator.new( self ).validate
9
+ errors = FunWith::Gems::Validator.validate self
10
+ errors
10
11
  end
11
12
 
12
13
  def valid_gem?
13
- self.validate_gem.fwf_blank?
14
+ errors = self.validate_gem
15
+ errors.fwf_blank?
16
+ end
17
+
18
+ def passes_tests?
19
+ TestSuiteRunner.new( self ).passes_tests?
14
20
  end
15
21
 
16
22
  def gem_test_mode?
@@ -33,6 +39,38 @@ module FunWith
33
39
  def say_if_verbose( msg, stream = $stdout )
34
40
  stream.puts( msg ) if gem_verbose?
35
41
  end
42
+
43
+
44
+ def load_tasks
45
+ load_internal_tasks
46
+ load_external_tasks
47
+ end
48
+
49
+ # Tasks in gem/tasks should be those which are specific to the gem itself.
50
+ # Tasks located here will not be made available to gems which depend on it.
51
+ # Made accessible during the Rakefile.setup
52
+ def load_internal_tasks
53
+ _load_tasks_from_directory self.root( "tasks" )
54
+ end
55
+
56
+ # Tasks in gem/lib/tasks will be usable by gems which have this gem as a dependency.
57
+ def load_external_tasks
58
+ _load_tasks_from_directory self.root( "lib", "tasks" )
59
+ end
60
+
61
+ def _load_tasks_from_directory dir
62
+ if _rake_gem_loaded?
63
+ dir.glob do |file|
64
+ if file.file? && ( file.ext == "rb" || file.ext == "rake" )
65
+ Rake.load_rakefile file
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ def _rake_gem_loaded?
72
+ defined?( Gem ) && Gem.respond_to?( :loaded_specs ) && defined?( Rake ) && Gem.loaded_specs.keys.include?( "rake" )
73
+ end
36
74
  end
37
75
  end
38
76
  end
@@ -25,6 +25,9 @@ module FunWith
25
25
  set_gem_root
26
26
  set_gem_version
27
27
  require_libs
28
+ extend_constant_with_gem_api
29
+ @gem_const.gem_verbose = opts[:verbose]
30
+ @gem_const.load_external_tasks # Nothing happens unless 'rake' gem is active
28
31
  end
29
32
 
30
33
  protected
@@ -80,6 +83,12 @@ module FunWith
80
83
  end
81
84
  end
82
85
  end
86
+
87
+ def extend_constant_with_gem_api
88
+ if defined?( @gem_const::GemAPI )
89
+ @gem_const.extend( @gem_const::GemAPI )
90
+ end
91
+ end
83
92
  end
84
93
  end
85
94
  end
@@ -0,0 +1,98 @@
1
+ module FunWith
2
+ module Gems
3
+ module RakeClassMethods
4
+ attr_accessor :gem
5
+
6
+ def setup this_gem, rake_main
7
+ set_gem this_gem
8
+ set_rake_main rake_main
9
+ run_bundler_setup
10
+
11
+ # Internal tasks are set up in the Rakefile.
12
+ # External tasks (visible to the gems that depend on your fungem) are setup during the normal gem setup, if the 'rake' gem is present.
13
+ get_gem.load_internal_tasks
14
+ end
15
+
16
+ def set_gem g
17
+ @gem = g
18
+ end
19
+
20
+ def get_gem
21
+ @gem
22
+ end
23
+
24
+ def set_rake_main m
25
+ @rake_main = m
26
+ end
27
+
28
+ def run_bundler_setup
29
+ jeweler_requirements
30
+ rake_requirements
31
+
32
+ begin
33
+ Bundler.setup(:default, :development)
34
+ rescue Bundler::BundlerError => e
35
+ $stderr.puts e.message
36
+ $stderr.puts "Run `bundle install` to install missing gems"
37
+ exit e.status_code
38
+ end
39
+ end
40
+
41
+ def specification &block
42
+ Jeweler::Tasks.new do |gem|
43
+ yield gem
44
+ end
45
+ end
46
+
47
+ def setup_gem_boilerplate
48
+ run_in_rakefile do
49
+ Jeweler::RubygemsDotOrgTasks.new
50
+
51
+ Rake::TestTask.new(:test) do |test|
52
+ test.libs << 'lib' << 'test'
53
+ test.pattern = 'test/**/test_*.rb'
54
+ test.verbose = true
55
+ end
56
+
57
+ desc "Code coverage detail"
58
+ task :simplecov do
59
+ ENV['COVERAGE'] = "true"
60
+ Rake::Task['test'].execute
61
+ end
62
+
63
+ task :default => :test
64
+
65
+ Rake::RDocTask.new do |rdoc|
66
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
67
+
68
+ rdoc.rdoc_dir = 'rdoc'
69
+ rdoc.title = "fun_with_gems #{version}"
70
+ rdoc.rdoc_files.include('README*')
71
+ rdoc.rdoc_files.include('lib/**/*.rb')
72
+ end
73
+ end
74
+ end
75
+
76
+ def jeweler_requirements
77
+ require 'rake'
78
+ require 'jeweler'
79
+ end
80
+
81
+ def rake_requirements
82
+ require 'rdoc/task'
83
+ require 'rake/testtask'
84
+ end
85
+
86
+ def run_in_rakefile &block
87
+ if @rake_main.nil?
88
+ raise "Did you forget the line FunWith::Gems::Rakefile.set_rake_main by any chance?"
89
+ elsif ! block_given?
90
+ raise ArgumentError.new("Block must be given")
91
+ else
92
+ @rake_main.instance_eval &block
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+
@@ -0,0 +1,6 @@
1
+ module FunWith
2
+ module Gems
3
+ module Rakefile
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,38 @@
1
+ module FunWith
2
+ module Gems
3
+ class TestResults
4
+ TEST_SUITE_DATA_REGEX = /(?<tests>\d+) (?:tests|runs), (?<assertions>\d+) assertions, (?<failures>\d+) failures, (?<errors>\d+) errors, (?<skips>\d+) skips/
5
+
6
+ attr_accessor :output, :test_results_found, :gem_const, :fail_count
7
+
8
+ def initialize g
9
+ self.gem_const = g
10
+ end
11
+
12
+ def passed?
13
+ self.scan_test_results
14
+ self.test_results_found? && no_failures_or_errors?
15
+ end
16
+
17
+ def test_results_found?
18
+ self.test_results_found
19
+ end
20
+
21
+ def no_failures_or_errors?
22
+ fail_count == 0
23
+ end
24
+
25
+ def scan_test_results
26
+ raise "No output to scan!" if self.output.nil?
27
+
28
+ if m = self.output.match( TEST_SUITE_DATA_REGEX )
29
+ self.test_results_found = true
30
+ self.fail_count = m[:failures].to_i + m[:errors].to_i
31
+ else
32
+ self.fail_count = -1
33
+ self.test_results_found = false
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,26 @@
1
+ module FunWith
2
+ module Gems
3
+ class TestSuiteRunner
4
+ attr_accessor :gem_const
5
+
6
+ def initialize fwgem
7
+ self.gem_const = fwgem
8
+ end
9
+
10
+ def passes_tests?
11
+ result = self.run_tests
12
+ result.passed?
13
+ end
14
+
15
+ def run_tests
16
+ filepath = self.gem_const.root
17
+
18
+ results = TestResults.new( self.gem_const )
19
+
20
+ puts "running tests on #{self.gem_const} from #{filepath}"
21
+ results.output = `cd #{filepath} && rake test`
22
+ results
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,8 +1,6 @@
1
1
  module FunWith
2
2
  module Gems
3
3
  class Validator
4
- TEST_SUITE_DATA_REGEX = /(<?tests>\d+) tests, (<?assertions>\d+) assertions, (<?failures>\d+) failures, (<?errors>\d+) errors, (<?skips>\d+) skips/
5
-
6
4
  def self.validate( gem_const )
7
5
  self.new( gem_const ).validate
8
6
  end
@@ -28,9 +26,7 @@ module FunWith
28
26
  @fun_gem_errors << "doesn't respond to .root()"
29
27
  end
30
28
 
31
- if @gem_const.respond_to?(:version)
32
-
33
- else
29
+ if ! @gem_const.respond_to?(:version)
34
30
  @fun_gem_errors << "doesn't respond to .version()"
35
31
  end
36
32
 
@@ -41,21 +37,6 @@ module FunWith
41
37
  @fun_gem_errors
42
38
  end
43
39
 
44
-
45
- def passes_tests?( filepath )
46
- @test_output = `cd #{filepath} && rake`
47
- results = scan_results( @test_output )
48
- end
49
-
50
- def scan_results( str )
51
- if m = str.match( TEST_SUITE_DATA_REGEX )
52
- m[0]
53
- else
54
- "TEST STATS NOT FOUND"
55
- end
56
- end
57
-
58
-
59
40
  def git_up_to_date?( filepath )
60
41
  # On branch master
61
42
  # Your branch is ahead of 'origin/master' by 1 commit.
data/lib/fun_with_gems.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  require "fun_with_version_strings"
2
2
  require "fun_with_files"
3
3
 
4
+ # require 'debugger'
5
+ # debugger
6
+
4
7
  # FunWith::VersionStrings.versionize( FunWith::Files )
5
8
 
6
9
  lib_dir = __FILE__.fwf_filepath.dirname
@@ -16,5 +19,7 @@ FunWith::Gems.extend( FunWith::Gems::GemAPI )
16
19
  # rootifies
17
20
  # requir's the lib/fun_with directory
18
21
  # Do this because FunWithFiles doesn't do it itself.
19
- FunWith::Gems.make_gem_fun( FunWith::Files, :require => false, :set_root => false, :set_version => false )
20
- FunWith::Gems.make_gem_fun( "FunWith::Gems" )
22
+ FunWith::Gems.make_gem_fun FunWith::Files, :require => false, :set_root => false, :set_version => false
23
+ FunWith::Gems.make_gem_fun FunWith::Gems, :verbose => true
24
+
25
+ FunWith::Gems::Rakefile.extend FunWith::Gems::RakeClassMethods
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fun_with_gems
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryce Anderson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fun_with_files
@@ -16,7 +16,7 @@ dependencies:
16
16
  requirements:
17
17
  - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.0.7
19
+ version: 0.0.13
20
20
  - - ~>
21
21
  - !ruby/object:Gem::Version
22
22
  version: '0.0'
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.0.7
29
+ version: 0.0.13
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
32
  version: '0.0'
@@ -76,7 +76,10 @@ files:
76
76
  - ./lib/fun_with/gems/core_extensions/module.rb
77
77
  - ./lib/fun_with/gems/fun_gem_api.rb
78
78
  - ./lib/fun_with/gems/gem_api.rb
79
- - ./lib/fun_with/gems/mechanic.rb
79
+ - ./lib/fun_with/gems/rake_class_methods.rb
80
+ - ./lib/fun_with/gems/rakefile.rb
81
+ - ./lib/fun_with/gems/test_results.rb
82
+ - ./lib/fun_with/gems/test_suite_runner.rb
80
83
  - ./lib/fun_with/gems/validator.rb
81
84
  - ./lib/fun_with_gems.rb
82
85
  - ./test/helper.rb
@@ -1,27 +0,0 @@
1
- module FunWith
2
- module Gems
3
-
4
- class Mechanic
5
- def bump_version( gem_const )
6
- if Validator.new.validate( gem_const )
7
- # if tests pass and gem is valid
8
-
9
- # run rake version:bump:patch
10
-
11
- # git commit
12
-
13
- # git push
14
-
15
- # add branch v<VERSION>
16
-
17
- # rake install
18
-
19
- # gem push
20
-
21
- else
22
- puts "Failed"
23
- end
24
- end
25
- end
26
- end
27
- end