corundum 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDYzZGYwYjJmYjc5NzM3YmVkZmZiOTkyZWNhMjY0NTAzMjE2ZDVhZg==
4
+ YjUwMDk0ZDAyYzk4MzQ5OTk1MDg2Y2ZmMTgxMTkwNTIyYjg1YTFjNw==
5
5
  data.tar.gz: !binary |-
6
- Y2IwMTI1YTkwYWVmMTQ4MjYwYjBiMGI2ZjM5NDI2Zjg3NmY4NjVkNw==
6
+ M2I5NWQ0OGU4Zjg3MjdiNjZlNGFmNzIwY2M1NTM4YmM2NzU2NDYwOA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjgyNGVmYjRlMTMwYjk3ZWVlNjI0ZDM3NDk3MzEyZjQ2MjY3YmQwZTgxM2I5
10
- ZjI3YzJjZjE5YTIzYWZhNTRhOGM2ODc0YzVmYWYzODcxZDJhOTdkYWNlMTBm
11
- YjZlNmZkMjUwNTY0M2ZlMzk4NmFlMGY5NjdlOTBlMzM0ZTU2NWY=
9
+ MzQ5ODk3NzNlMTM2NjIyMWM1MzY2NjNhYzc1ZWY1MWM1MTFjNWY1NjMxNjMx
10
+ YTY3MWEyZDM5NjA4OGRjMDFiNWJkMzMyMWFmMmQ5OTRkODIwMzRjMGMxNzE3
11
+ ZjdmNDcwN2JlNTBkMmQ5MDJkNWVjMWI3NzRlZWE4ZDMwOGI1ZmM=
12
12
  data.tar.gz: !binary |-
13
- MDRmYmE5ZDcxNjQ0OWQ2YjEyOTllNWE0ZDAzZmYyYTQ0MDc5YjcxNDFhNmE3
14
- MjQzZjc5NjVlNTQxNDA0ZDNiNDI5ZjQ4MmUwNDg2MjA3NGQxNmM4MWYxODI1
15
- MWExZmJjZmMzZDIyMGUzOTFkMThlZDg2YWUwNmI2ZTI2OTM5ZjE=
13
+ NmE4YmZiN2E0NjMzYjQ0NzE0ZTBlZTFjZjEyYTg5YjA1OGJjYmNmMjM0ZTY5
14
+ YmJjYjc4MjM0YWY5ZGJhY2U0NzIwZDBjMmM2MGQ0ZDQzNjJmOGUwNjZiZWY3
15
+ M2Q3ZTE0OGZhY2YwY2RlZWNiNWVmMzE0ODU1OTcxNWQxOWM5NjQ=
data/README.md CHANGED
@@ -1,7 +1,20 @@
1
1
  ## Corundum
2
+ ### Quickstart
3
+
4
+ The corundum-skel executable templates all the basic files necessary for building
5
+ a gem with corundum. It's cautious and will not overwrite existing files.
6
+
7
+
8
+ ```
9
+ gem install corundum
10
+ cd my-new-rubygem
11
+ corundum-skel
12
+ rake -T
13
+ ```
14
+
2
15
  ### Foolproof rubygems
3
16
 
4
- With Corudum added as a developement dependancy to your gemspec, and configured
17
+ With Corundum added as a developement dependency to your gemspec, and configured
5
18
  (quickly) in your Rakefile you can do:
6
19
 
7
20
  rake release
@@ -49,7 +62,7 @@ Corundum certainly wouldn't exist without seattlerb's Hoe.
49
62
 
50
63
  Corundum's default documentation theme is lifted wholesale from Steve Smith's Modernizer theme for github pages.
51
64
 
52
- Obviously, Bundler and Rubygems are a prerequisite, and the team that works on them is pretty much amazing.
65
+ Obviously, Bundler and Rubygems are a prerequisite, and the teams that works on them are pretty much amazing.
53
66
 
54
67
  ### Contributing
55
68
 
@@ -62,3 +75,7 @@ an RCov tasklib, for instance, or a Minitest one. Mercurial.
62
75
  Make a pull request, and I'll get it merged. If you're worried, we can talk it
63
76
  out in Issues or email, and we can hash out the form of a pull request that
64
77
  I'll commit to merging.
78
+
79
+ ### License
80
+
81
+ MIT
@@ -1,53 +1,4 @@
1
- #! /bin/env ruby
1
+ #! /usr/bin/env ruby
2
2
  # vi: set ft=ruby:
3
- require 'optparse'
4
- require 'corundum/configuration-store'
5
- require 'rake/application'
6
-
7
- skelfiles = [ {
8
- :source => 'skel-files/rakefile',
9
- :target => 'Rakefile',
10
- :unless => Rake::Application::DEFAULT_RAKEFILES,
11
- },
12
- {
13
- :source => 'skel-files/simplecov',
14
- :target => '.simplecov',
15
- :unless => ['.simplecov']
16
- },
17
- {
18
- :source => 'skel-files/travis',
19
- :target => '.travis.yml',
20
- :unless => ['.travis.yml']
21
- },
22
- {
23
- :source => 'skel-files/gemspec',
24
- :target => 'gem.gemspec',
25
- :unless => ['gemspec.rb', '*.gemspec'],
26
- },
27
- {
28
- :source => 'skel-files/gemfile',
29
- :target => 'Gemfile',
30
- :unless => ['Gemfile'],
31
- } ]
32
-
33
- if %w{-h --help -help help}.include?(ARGV[0])
34
- puts "Spits out skeleton files to start a gem with."
35
- puts
36
- puts "Will emit these files:"
37
- puts skelfiles.map{|desc| desc[:target]}.join(", ")
38
- puts
39
- puts "Files are copied from the skel-files directory out of this search path:"
40
- puts Corundum.configuration_store.valise
41
- exit 0
42
- end
43
-
44
- skelfiles.each do |desc|
45
- unless (found = desc[:unless].map{|pattern| Dir.glob(pattern)}.flatten).empty?
46
- puts "Refusing to clobber existing '#{found.first}'"
47
- else
48
- File::open(desc[:target], "w") do |file|
49
- file.write(Corundum.configuration_store.loaded[desc[:source]])
50
- end
51
- puts "Created #{desc[:target]}"
52
- end
53
- end
3
+ require 'corundum/cli/skelfiles'
4
+ Corundum::CLI::Skelfiles.new(ARGV).go
@@ -0,0 +1,95 @@
1
+ require 'optparse'
2
+ require 'corundum/configuration-store'
3
+ require 'rake/application'
4
+
5
+ module Corundum
6
+ module CLI
7
+ class Skelfiles
8
+ class Skelfile
9
+ def initialize(source, target, exclude)
10
+ @source, @target, @exclude = source, target, exclude
11
+ @message = "No attempt to create yet"
12
+ end
13
+ attr_reader :source, :target, :exclude, :message
14
+
15
+ def templates
16
+ Corundum.configuration_store.valise.templates("skel-files")
17
+ end
18
+
19
+ def create!(scope)
20
+ unless (found = exclude.map{|pattern| Dir.glob(pattern)}.flatten).empty?
21
+ @message = "Refusing to clobber existing '#{found.first}'"
22
+ else
23
+ File::open(target, "w") do |file|
24
+ contents = templates.contents(source)
25
+ case contents
26
+ when Tilt::Template
27
+ file.write(contents.render(scope, {}))
28
+ else
29
+ file.write(contents)
30
+ end
31
+ end
32
+ @message = "Created #{target}"
33
+ end
34
+ end
35
+ end
36
+
37
+ def initialize(args)
38
+ @args = args
39
+ end
40
+ attr_reader :args
41
+
42
+ SkelfileScope = Struct.new(:project_name)
43
+
44
+ def options
45
+ @options ||= OptionParser.new do |opti|
46
+ opti.banner = "Spits out skeleton files to start a gem with.\nUsage: #$0 [options]"
47
+ opti.on("-h", "--help", "This help message") do
48
+ puts opti
49
+ puts "Will emit these files:"
50
+ puts skelfiles.map{|desc| desc.target}.join(", ")
51
+ puts
52
+ puts "Files are copied from the skel-files directory out of this search path:"
53
+ puts Corundum.configuration_store.valise
54
+ exit 0
55
+ end
56
+
57
+ opti.on("-p", "--project NAME", "Sets the name of the project (defaults to dirname, i.e. '#{default_project_name}')") do |name| #ok
58
+ scope.project_name = name
59
+ end
60
+ end
61
+ end
62
+
63
+ def default_project_name
64
+ File.basename(Dir.pwd)
65
+ end
66
+
67
+ def scope
68
+ @scope ||= SkelfileScope.new(default_project_name)
69
+ end
70
+
71
+ def skelfiles
72
+ @skelfiles ||= [
73
+ Skelfile.new( 'rakefile', 'Rakefile', Rake::Application::DEFAULT_RAKEFILES),
74
+ Skelfile.new( 'simplecov', '.simplecov', %w[.simplecov] ),
75
+ Skelfile.new( 'travis', '.travis.yml', %w[.travis.yml] ),
76
+ Skelfile.new( 'gemspec', "#{scope.project_name}.gemspec", %w{gemspec.rb *.gemspec} ),
77
+ Skelfile.new( 'gemfile', 'Gemfile', %w[Gemfile] )
78
+ ]
79
+ end
80
+
81
+ def parse_args
82
+ options.parse(args)
83
+ end
84
+
85
+ def go
86
+ parse_args
87
+
88
+ skelfiles.each do |skelfile|
89
+ skelfile.create!(scope)
90
+ puts skelfile.message
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'corundum'
4
+ gemspec :name => "<%= project_name %>" #points to default '<%= project_name %>.gemspec'
@@ -1,5 +1,5 @@
1
1
  Gem::Specification.new do |spec|
2
- spec.name = ""
2
+ spec.name = "<%= project_name %>"
3
3
  #{MAJOR: incompatible}.{MINOR added feature}.{PATCH bugfix}-{LABEL}
4
4
  spec.version = "0.0.1"
5
5
  author_list = {
@@ -1,38 +1,82 @@
1
1
  # vim: set ft=ruby :
2
2
  require 'corundum/tasklibs'
3
3
 
4
+ # This Rakefile makes use of the Corundum tasklibs to parameterize lots and
5
+ # lots of tasks to build your gem. Most of this is (minimal) boilerplate, but
6
+ # there are some places where you can configure exactly how the tasks should
7
+ # work.
8
+ #
9
+ # If you haven't seen the pattern before, simply instantiating the tasklib
10
+ # class (i.e. SomeTasklib.new) is enough to create all the tasks it's
11
+ # responsible for. If you do need to configure a tasklib, you can give ::new a
12
+ # block which will receive the tasklib to configure. c.f. QuestionableContent
13
+ # for an example.
14
+ #
15
+ # (Further docs for all the Corundum tasklibs will be coming to an Internet
16
+ # near you real soon now.)
4
17
  module Corundum
5
18
  Corundum::register_project(__FILE__)
6
19
 
20
+ # The Core tasklib coordinates the other tasks. Generally it doesn't need any
21
+ # configuration.
7
22
  core = Core.new
8
23
 
9
24
  core.in_namespace do
25
+ # The GemspecFiles tasklib is responsible for checking that all the files
26
+ # necessary for your gem are listed in the Gemfile. Usually you don't need
27
+ # to add any configuration. Of note is the "extra_files" configuration - a
28
+ # list of files that need to be included but that Corundum might not be
29
+ # able to detect on its own.
10
30
  GemspecFiles.new(core)
11
31
 
12
- #Also available: 'unfinished': TODO and XXX
32
+ # QuestionableContent searches codefiles for words (especially in comments)
33
+ # that you might not want going out into the world. Note that QC is added 4
34
+ # times by default with different types of text.
35
+ #
36
+ # If QC is wrong about something (e.g. there's a completely legitimate
37
+ # reason that 'p' appears on a line) You can tag the line with an '#ok'
38
+ # comment to have QC ignore it.
39
+
40
+ # This default checks for unacceptable language (of both the profanity
41
+ # and -ism varieties) before release, as well as debugging statements
42
+ # like debugger, byebug, puts, p, etc. accidentally left in the code.
43
+ #
44
+ # Also available: 'unfinished': TODO and XXX
13
45
  ["debug", "profanity", "ableism", "racism"].each do |type|
14
46
  QuestionableContent.new(core) do |content|
15
47
  content.type = type
16
48
  end
17
49
  end
50
+
51
+ # Corundum won't let you release a gem where any tests fail. By default, it
52
+ # assumes RSpec is used to test the project (alternative implementations
53
+ # are anxiously encouraged!)
18
54
  rspec = RSpec.new(core)
19
- cov = SimpleCov.new(core, rspec) do |cov|
20
- cov.threshold = 70
21
- end
22
55
 
23
- gem = GemBuilding.new(core)
24
- cutter = GemCutter.new(core,gem)
25
- email = Email.new(core)
26
- vc = Git.new(core) do |vc|
27
- vc.branch = "master"
56
+ # To make sure that tests don't just pass because they're incomplete,
57
+ # Corundum also requires a coverage threshold, which we measure with
58
+ # Simplecov. Coverage also figures into how we determine that files should
59
+ # be in the gemspec (covered files should be included, and included files
60
+ # should be covered)
61
+ SimpleCov.new(core, rspec) do |cov|
62
+ cov.threshold = 85
28
63
  end
29
64
 
30
- yd = YARDoc.new(core)
65
+ # The tasks to actually take code + gemspec and package into a gem. All its
66
+ # configuration should be determined by the gemspec itself.
67
+ gem = GemBuilding.new(core)
31
68
 
32
- docs = DocumentationAssembly.new(core, yd, rspec, cov)
69
+ # Tasks for uploading gems to rubygems.com - called GemCutter for
70
+ # historical reasons.
71
+ GemCutter.new(core,gem)
33
72
 
34
- pages = GithubPages.new(docs)
73
+ # We require that the code for a gem be pushed before releasing, and tag
74
+ # the branch with the version of the gem automatically. Corundum assumes
75
+ # Git for version control - alternatives encouraged.
76
+ Git.new(core) do |vc|
77
+ vc.branch = "master"
78
+ end
35
79
  end
36
80
  end
37
81
 
38
- task :default => [:release, :publish_docs]
82
+ task :default => [:release]
@@ -2,4 +2,5 @@ SimpleCov.start do
2
2
  coverage_dir "corundum/docs/coverage"
3
3
  add_filter "./spec"
4
4
  add_filter "/vendor/bundle/"
5
+ formatter SimpleCov::Formatter::JSONFormatter
5
6
  end
@@ -5,7 +5,6 @@ module Corundum
5
5
  class GemCutter < Mattock::TaskLib
6
6
  default_namespace :gemcutter
7
7
 
8
- setting(:gem_path, nil)
9
8
  setting(:build)
10
9
  setting(:gemspec)
11
10
  setting(:qa_rejections)
@@ -85,6 +85,11 @@ module Corundum
85
85
  end
86
86
  unless config_string =~ /SimpleCov::Formatter::JSONFormatter/
87
87
  problems << ".simplecov doesn't refer to SimpleCov::Formatter::JSONFormatter"
88
+ problems << "in your .simplecov file, either: "
89
+ problems << " add 'formatter SimpleCov::Formatter::JSONFormatter'"
90
+ problems << " or"
91
+ problems << " add 'SimpleCov::Formatter::JSONFormatter' to an existing"
92
+ problems << " 'formatter SimpleCov::Formatter::MultiFormatter'"
88
93
  end
89
94
  fail problems.join("\n") unless problems.empty?
90
95
  end
@@ -83,7 +83,7 @@ module Corundum
83
83
  merge = git("config", "--get", "branch.#{branch}.merge").first.split("/").last.chomp
84
84
 
85
85
  ancestor = git("merge-base", branch, "#{remote}/#{merge}").first.chomp
86
- remote_rev = File::read(".git/refs/remotes/#{remote}/#{merge}").chomp
86
+ remote_rev = git("ls-remote", remote, merge).first.split(/\s+/).first
87
87
 
88
88
  unless ancestor == remote_rev
89
89
  fail "Unmerged changes with remote branch #{remote}/#{merge}\n#{ancestor.inspect}\n#{remote_rev.inspect}"
@@ -18,7 +18,7 @@ module Corundum
18
18
  end
19
19
 
20
20
  it "should have some tasks" do
21
- true.should be_true
21
+ expect(true).to be(true)
22
22
  end
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corundum
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Judson Lester
8
+ - Evan Dorn
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2014-08-25 00:00:00.000000000 Z
12
+ date: 2015-07-25 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: corundum
@@ -135,6 +136,7 @@ description: ! " A corundum is a synthetic gemstone - including synthetic rubie
135
136
  \ packaging and releasing the gem\n"
136
137
  email:
137
138
  - nyarly@gmail.com
139
+ - evan@lrdesign.com
138
140
  executables:
139
141
  - corundum-skel
140
142
  extensions: []
@@ -194,6 +196,7 @@ extra_rdoc_files:
194
196
  files:
195
197
  - bin/corundum-skel
196
198
  - lib/corundum.rb
199
+ - lib/corundum/cli/skelfiles.rb
197
200
  - lib/corundum/configuration-store.rb
198
201
  - lib/corundum/core.rb
199
202
  - lib/corundum/qa-report.rb
@@ -212,8 +215,8 @@ files:
212
215
  - lib/corundum/version_control/git.rb
213
216
  - lib/corundum/default_configuration/preferences.yaml
214
217
  - lib/corundum/default_configuration/skel-files/rakefile
215
- - lib/corundum/default_configuration/skel-files/gemspec
216
- - lib/corundum/default_configuration/skel-files/gemfile
218
+ - lib/corundum/default_configuration/skel-files/gemspec.erb
219
+ - lib/corundum/default_configuration/skel-files/gemfile.erb
217
220
  - lib/corundum/default_configuration/skel-files/travis
218
221
  - lib/corundum/default_configuration/skel-files/simplecov
219
222
  - README.md
@@ -281,7 +284,7 @@ metadata: {}
281
284
  post_install_message:
282
285
  rdoc_options:
283
286
  - --title
284
- - corundum-0.4.1 RDoc
287
+ - corundum-0.5.0 RDoc
285
288
  require_paths:
286
289
  - lib/
287
290
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem 'corundum'
4
- gemspec :name => "gem" #points to default 'gem.gemspec'