projecter 0.0.2
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 +7 -0
- data/.gitignore +19 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/projector.iml +91 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +354 -0
- data/.rubocop.yml +18 -0
- data/Gemfile +3 -0
- data/MIT-LICENSE +19 -0
- data/README.md +40 -0
- data/Rakefile +4 -0
- data/bin/projecter +24 -0
- data/files/Gemfile +3 -0
- data/files/Guardfile +27 -0
- data/files/Rakefile +37 -0
- data/files/dot-gitignore +21 -0
- data/files/dot-metrics +4 -0
- data/files/dot-rspec +1 -0
- data/files/dot-rubocop.yml +13 -0
- data/lib/commands/create.rb +116 -0
- data/lib/commands/version.rb +6 -0
- data/lib/projecter.rb +5 -0
- data/lib/version.rb +3 -0
- data/projector.gemspec +38 -0
- data/templates/README.md.tt +44 -0
- data/templates/gemspec.tt +39 -0
- data/templates/mainapp.tt +29 -0
- data/templates/mainlib.rb.tt +13 -0
- data/templates/reek.tt +5 -0
- data/templates/spec_fixtures.rb.tt +8 -0
- data/templates/spec_helper.rb.tt +12 -0
- data/templates/spec_resources.rb.tt +7 -0
- data/templates/version-cmd.rb.tt +6 -0
- data/templates/version.rb.tt +3 -0
- metadata +323 -0
data/bin/projecter
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'thor'
|
5
|
+
|
6
|
+
# Set up the load path so we can load things from our own lib
|
7
|
+
$: << File.expand_path("../../lib", __FILE__)
|
8
|
+
|
9
|
+
require 'projecter'
|
10
|
+
|
11
|
+
# Skeleton CLI class
|
12
|
+
class ProjecterCLI < Thor
|
13
|
+
check_unknown_options!
|
14
|
+
end
|
15
|
+
|
16
|
+
# load all commands
|
17
|
+
cmd_root = "../../lib/commands/*"
|
18
|
+
Dir[File.expand_path(cmd_root, __FILE__)].each do |cmd|
|
19
|
+
require cmd
|
20
|
+
end
|
21
|
+
|
22
|
+
unless $0 =~ /rspec/
|
23
|
+
ProjecterCLI.start
|
24
|
+
end
|
data/files/Gemfile
ADDED
data/files/Guardfile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# vim: ft=ruby
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
#
|
4
|
+
# More info also at https://github.com/guard/guard-rspec -- this one in
|
5
|
+
# particular details configuration options such as whether to run all tests
|
6
|
+
# after a failing test starts passing
|
7
|
+
|
8
|
+
guard :rspec, cli: '--tag ~slow' do
|
9
|
+
watch(/^spec\/.+_spec\.rb/)
|
10
|
+
watch(/^lib\/(.+)\.rb$/) do |match|
|
11
|
+
%w(unit integration acceptance).map do |kind|
|
12
|
+
"spec/#{kind}/lib/#{match[1]}_spec.rb"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
16
|
+
watch(%r{^spec/(fixtures|resources)(/|.rb)}) { 'spec' }
|
17
|
+
end
|
18
|
+
|
19
|
+
guard :rubocop, all_on_start: false do
|
20
|
+
watch('Guardfile')
|
21
|
+
watch(/.+\.rb$/)
|
22
|
+
watch(/(?:.+\/)?\.rubocop\.yml$/) { |m| File.dirname(m[0]) }
|
23
|
+
end
|
24
|
+
|
25
|
+
guard :reek do
|
26
|
+
watch(/^lib\/(.+)\.rb$/)
|
27
|
+
end
|
data/files/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# rubocop: disable LeadingCommentSpace
|
2
|
+
#! /usr/bin/env rake
|
3
|
+
# rubocop: enable LeadingCommentSpace
|
4
|
+
require 'bundler/gem_tasks'
|
5
|
+
require 'yard'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
require 'reek/rake/task'
|
8
|
+
require 'rubocop/rake_task'
|
9
|
+
|
10
|
+
task default: :build
|
11
|
+
|
12
|
+
# If there are test failures, you'll need to write code to address them.
|
13
|
+
# So no point in continuing to run the style tests.
|
14
|
+
desc 'Runs all spec tests'
|
15
|
+
RSpec::Core::RakeTask.new(:spec)
|
16
|
+
|
17
|
+
desc 'Runs yard'
|
18
|
+
YARD::Rake::YardocTask.new(:yard)
|
19
|
+
|
20
|
+
desc 'smells the lib directory, which Reek defaults to anyway'
|
21
|
+
Reek::Rake::Task.new(:reek_lib) do |task|
|
22
|
+
task.verbose = true
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'smells the spec directory, which is less important than lib'
|
26
|
+
Reek::Rake::Task.new(:reek_spec) do |task|
|
27
|
+
task.source_files = 'spec/**/*.rb'
|
28
|
+
task.verbose = true
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'runs Rubocop'
|
32
|
+
RuboCop::RakeTask.new
|
33
|
+
|
34
|
+
desc 'Runs test and code cleanliness suite: RuboCop, Reek, rspec, and yard'
|
35
|
+
task run_guards: [:spec, :yard, :reek_lib, :rubocop]
|
36
|
+
|
37
|
+
task build: :run_guards
|
data/files/dot-gitignore
ADDED
data/files/dot-metrics
ADDED
data/files/dot-rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'find'
|
2
|
+
|
3
|
+
class ProjecterCLI < Thor
|
4
|
+
include Thor::Actions
|
5
|
+
|
6
|
+
desc 'create PROJECT', 'Create a new Thor CLI skeleton in ./PROJECT'
|
7
|
+
method_options :uses_templates => false, :uses_files => false, :library => false
|
8
|
+
|
9
|
+
def create(project)
|
10
|
+
@project = project
|
11
|
+
|
12
|
+
ProjecterCLI::source_root(File.expand_path('../../..', __FILE__))
|
13
|
+
run "git init #{@project}", :capture => true unless File.exist?(File.join(@project, '.git'))
|
14
|
+
|
15
|
+
create_project_dirs
|
16
|
+
|
17
|
+
projecter_file({
|
18
|
+
'Gemfile' => 'Gemfile',
|
19
|
+
'Guardfile' => 'Guardfile',
|
20
|
+
'Rakefile' => 'Rakefile',
|
21
|
+
'dot-gitignore' => '.gitignore',
|
22
|
+
'dot-metrics' => '.metrics',
|
23
|
+
'dot-rspec' => '.rspec',
|
24
|
+
'dot-rubocop.yml' => '.rubocop.yml',
|
25
|
+
})
|
26
|
+
|
27
|
+
lib_templates = {
|
28
|
+
'gemspec.tt' => "#{project}.gemspec",
|
29
|
+
'README.md.tt' => 'README.md',
|
30
|
+
'reek.tt' => "#{project}.reek",
|
31
|
+
'mainlib.rb.tt' => ['lib', "#{project}.rb"],
|
32
|
+
'version.rb.tt' => ['lib', project, 'version.rb'],
|
33
|
+
'spec_helper.rb.tt' => %w(spec spec_helper.rb),
|
34
|
+
'spec_fixtures.rb.tt' => %w(spec fixtures.rb),
|
35
|
+
'spec_resources.rb.tt' => %w(spec resources.rb),
|
36
|
+
}
|
37
|
+
|
38
|
+
app_templates = {
|
39
|
+
'mainapp.tt' => ['bin', project],
|
40
|
+
'version-cmd.rb.tt' => %w(lib commands version.rb),
|
41
|
+
}
|
42
|
+
|
43
|
+
templates = lib_templates
|
44
|
+
templates.merge(app_templates) unless options.library?
|
45
|
+
|
46
|
+
projecter_template(
|
47
|
+
templates,
|
48
|
+
{
|
49
|
+
:project => project,
|
50
|
+
:classname => project
|
51
|
+
.split(/[_-]/)
|
52
|
+
.map(&:capitalize)
|
53
|
+
.join,
|
54
|
+
:library_only => options.library?
|
55
|
+
}
|
56
|
+
)
|
57
|
+
|
58
|
+
inside(@project) do
|
59
|
+
# XXX: KLUDGE: Add an empty .gitignore file in each empty directory
|
60
|
+
# XXX: KLUDGE: so that git can track the dir.
|
61
|
+
Find.find('.') do |path|
|
62
|
+
next if path.start_with?('./.git/')
|
63
|
+
next unless FileTest.directory?(path)
|
64
|
+
next unless Dir.entries(path) == %w(. ..)
|
65
|
+
|
66
|
+
create_file File.join(path, '.gitignore'), ''
|
67
|
+
end
|
68
|
+
|
69
|
+
run "git add .gitignore", :capture => true
|
70
|
+
run "git add .", :capture => true
|
71
|
+
run "git commit --allow-empty -m 'Created #{@project} using Projecter #{Projecter::VERSION}.'", :capture => true
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def projecter_file(mapping)
|
79
|
+
mapping.each do |src, dst|
|
80
|
+
copy_file(File.join('files', src), File.join(@project, dst))
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def projecter_template(mapping, bindings)
|
85
|
+
mapping.each do |src, dst|
|
86
|
+
dst = [dst] unless dst.is_a?(Array)
|
87
|
+
|
88
|
+
srcname = File.join('templates', src)
|
89
|
+
dstname = File.join(*[@project, dst].flatten)
|
90
|
+
|
91
|
+
template(srcname, dstname, bindings)
|
92
|
+
|
93
|
+
if dst.include?('bin')
|
94
|
+
chmod(dstname, 0755) unless (File.stat(dstname).mode & 0755) == 0755
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def create_project_dirs
|
100
|
+
source_dirs = ['lib', "lib/#{@project}"]
|
101
|
+
source_dirs << %w(bin lib/commands) unless options.library?
|
102
|
+
|
103
|
+
test_resource_dirs = %w(fixtures resources)
|
104
|
+
test_kinds = %w(unit integration acceptance)
|
105
|
+
test_dirs = (test_resource_dirs + test_kinds.product(source_dirs)).map { |path| ['spec', path].join('/') }
|
106
|
+
|
107
|
+
project_dirs = source_dirs + test_dirs
|
108
|
+
project_dirs << 'templates' if options.uses_templates?
|
109
|
+
project_dirs << 'files' if options.uses_files?
|
110
|
+
|
111
|
+
project_dirs.each do |dir|
|
112
|
+
empty_directory File.join(@project, dir)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
data/lib/projecter.rb
ADDED
data/lib/version.rb
ADDED
data/projector.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.expand_path('../lib/version', __FILE__)
|
2
|
+
Gem::Specification.new do |gem|
|
3
|
+
gem.authors = ['Greg Poirier']
|
4
|
+
gem.email = ['grep@gray.industries']
|
5
|
+
gem.description = 'Projecter - Stub Ruby projects'
|
6
|
+
gem.summary = <<-EOF
|
7
|
+
Projecter allows for easily stubbing Ruby projects from simply RubyGems to
|
8
|
+
larger Thor applications. It is based largely off of the work of Jesse
|
9
|
+
Kempf at Opower.
|
10
|
+
EOF
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(/^bin\//).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
14
|
+
gem.name = 'projecter'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = Projecter::VERSION
|
17
|
+
|
18
|
+
# dependencies...
|
19
|
+
gem.add_dependency('thor', '0.18.1')
|
20
|
+
gem.add_dependency('sysexits', '1.0.2')
|
21
|
+
gem.add_dependency('awesome_print', '~> 1.1.0')
|
22
|
+
gem.add_dependency('abstract_type', '~> 0.0.7')
|
23
|
+
gem.add_dependency('multi_json', '~> 1.10.1')
|
24
|
+
|
25
|
+
# development dependencies.
|
26
|
+
gem.add_development_dependency('rspec', '~> 3.0.0')
|
27
|
+
gem.add_development_dependency('simplecov', '~> 0.7.0')
|
28
|
+
gem.add_development_dependency('guard', '~> 2.1.0')
|
29
|
+
gem.add_development_dependency('guard-rspec', '~> 4.2.10')
|
30
|
+
gem.add_development_dependency('rubocop', '~> 0.20')
|
31
|
+
gem.add_development_dependency('guard-rubocop', '~> 1.1.0')
|
32
|
+
gem.add_development_dependency('rainbow', '2.0')
|
33
|
+
gem.add_development_dependency('metric_fu', '~> 4.2.0')
|
34
|
+
gem.add_development_dependency('guard-reek', '~> 0.0.4')
|
35
|
+
gem.add_development_dependency('rake', '~> 10.0.1')
|
36
|
+
gem.add_development_dependency('yard', '~> 0.8.7')
|
37
|
+
gem.add_development_dependency('redcarpet', '~> 2.3.0')
|
38
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# <%= config[:project].capitalize %>
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem '<%= config[:project] %>'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install <%= config[:project] %>
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
30
|
+
|
31
|
+
|
32
|
+
## Testing
|
33
|
+
|
34
|
+
TODO: Add information specific to your gem's test suite.
|
35
|
+
|
36
|
+
The Rakefile comes with several convenience tasks for running tests as well. By rake task:
|
37
|
+
|
38
|
+
+ `spec`: Runs all rspec tests in the spec directory.
|
39
|
+
+ `yard`: Generates yard documentation.
|
40
|
+
+ `reek_lib`: Runs reek on the lib directory only.
|
41
|
+
+ `rubocop`: Runs rubocop.
|
42
|
+
+ `run_guards`: Runs all guards.
|
43
|
+
|
44
|
+
`run_guards` is the one you're most likely to want to run, since it runs all the other test-related tasks.
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: ft=ruby
|
3
|
+
|
4
|
+
require File.expand_path('../lib/<%= config[:project] %>/version', __FILE__)
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.authors = ["SET ME"]
|
8
|
+
gem.email = ["SET ME"]
|
9
|
+
gem.description = %q{I am an application stub}
|
10
|
+
gem.summary = %q{app stub}
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = '<%= config[:project] %>'
|
16
|
+
gem.require_paths = %w(lib)
|
17
|
+
gem.version = <%= config[:classname] %>::VERSION
|
18
|
+
|
19
|
+
# dependencies...
|
20
|
+
gem.add_dependency('thor', '0.18.1')
|
21
|
+
gem.add_dependency('sysexits', '1.0.2')
|
22
|
+
gem.add_dependency('awesome_print', '~> 1.1.0')
|
23
|
+
gem.add_dependency('abstract_type', '~> 0.0.7')
|
24
|
+
gem.add_dependency('multi_json', '~> 1.10.1')
|
25
|
+
|
26
|
+
# development dependencies.
|
27
|
+
gem.add_development_dependency('rspec', '~> 3.0.0')
|
28
|
+
gem.add_development_dependency('simplecov', '~> 0.7.0')
|
29
|
+
gem.add_development_dependency('guard', '~> 2.1.0')
|
30
|
+
gem.add_development_dependency('guard-rspec', '~> 4.2.10')
|
31
|
+
gem.add_development_dependency('rubocop', '~> 0.20')
|
32
|
+
gem.add_development_dependency('guard-rubocop', '~> 1.1.0')
|
33
|
+
gem.add_development_dependency('rainbow', '2.0')
|
34
|
+
gem.add_development_dependency('metric_fu', '~> 4.2.0')
|
35
|
+
gem.add_development_dependency('guard-reek', '~> 0.0.4')
|
36
|
+
gem.add_development_dependency('rake', '~> 10.0.1')
|
37
|
+
gem.add_development_dependency('yard', '~> 0.8.7')
|
38
|
+
gem.add_development_dependency('redcarpet', '~> 2.3.0')
|
39
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
# Set up the load path so we can load things from our own lib
|
6
|
+
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
7
|
+
|
8
|
+
require '<%= config[:project] %>'
|
9
|
+
|
10
|
+
# Skeleton CLI class
|
11
|
+
class <%= config[:classname] %>CLI < Thor
|
12
|
+
check_unknown_options!
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Load all commands
|
17
|
+
#
|
18
|
+
|
19
|
+
<%= config[:classname] %>.before_command_load
|
20
|
+
|
21
|
+
cmd_root = '../../lib/commands/*'
|
22
|
+
Dir[File.expand_path(cmd_root, __FILE__)].each do |cmd|
|
23
|
+
require cmd
|
24
|
+
end
|
25
|
+
|
26
|
+
<%= config[:classname] %>.after_command_load
|
27
|
+
|
28
|
+
# Janky way of avoiding starting the CLI if we're running under rspec.
|
29
|
+
<%= config[:classname] %>CLI.start unless $PROGRAM_NAME =~ /rspec/
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require '<%= config[:project] %>/version'
|
2
|
+
|
3
|
+
module <%= config[:classname] %>
|
4
|
+
<% unless config[:library_only] -%>
|
5
|
+
# Callback invoked before the CLI loads all its command modules.
|
6
|
+
def self.before_command_load
|
7
|
+
end
|
8
|
+
|
9
|
+
# Callback invoked after the CLI loads all its command modules.
|
10
|
+
def self.after_command_load
|
11
|
+
end
|
12
|
+
<% end -%>
|
13
|
+
end
|
data/templates/reek.tt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
pid = Process.pid
|
5
|
+
SimpleCov.at_exit do
|
6
|
+
SimpleCov.result.format! if Process.pid == pid
|
7
|
+
end
|
8
|
+
|
9
|
+
$LOAD_PATH << File.expand_path('../../lib', __FILE__)
|
10
|
+
|
11
|
+
require File.expand_path('../fixtures.rb', __FILE__)
|
12
|
+
require File.expand_path('../resources.rb', __FILE__)
|