createproj 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -6
- data/lib/createproj/creator/creator.rb +19 -0
- data/lib/createproj/creator/haskell.rb +1 -0
- data/lib/createproj/creator/ruby.rb +33 -8
- data/lib/createproj/version.rb +1 -1
- data/lib/createproj.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce879aa2ccb1c26f3c594c5a1491469aa0d53efe
|
4
|
+
data.tar.gz: 066aa7e8ecbc2f812c9110e6588864d7de7c0c13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3850a0bab57d66cb9aadd4decc954ffac0a68eeec00c56ed8e89c7a69e415ba684e365da2fd6a7baad2e50a0b0d1c71fc740a54627f08c75b25b9324ba71cfc0
|
7
|
+
data.tar.gz: 50a7d6ab776a60409ff20f30059ed5e93e873a70f1256ab45006ec04af5eccdb1b98475c375d60a3a9b1f4834c8e10045db2bbb517c170fb2b58135760b10817
|
data/README.md
CHANGED
@@ -20,10 +20,4 @@ Read more on my [blog](http://mattjmcnaughton.com/createproject).
|
|
20
20
|
I built this largely for my personal use so there are a couple of assumptions made.
|
21
21
|
The first is that RVM and Cabal are installed.
|
22
22
|
|
23
|
-
## Todo
|
24
|
-
- Setup Travis CI
|
25
|
-
- Setup test coverage metric and add test
|
26
|
-
- Integrate with one of the libraries for git pre-commit hooks?
|
27
|
-
- Multiple pre-commit hooks. Lint and test.
|
28
|
-
- Add other languages/frameworks (starting w/ Rails)
|
29
23
|
|
@@ -17,6 +17,9 @@ module CreateProj
|
|
17
17
|
def initialize(name, options)
|
18
18
|
@name = name
|
19
19
|
@options = options
|
20
|
+
@precommit_template = ''
|
21
|
+
@precommit_options = {}
|
22
|
+
@gitignore_files = []
|
20
23
|
end
|
21
24
|
|
22
25
|
# Run instance of creator to create a project with the
|
@@ -36,6 +39,7 @@ module CreateProj
|
|
36
39
|
Dir.chdir(dir_name) do
|
37
40
|
init_git_repository
|
38
41
|
add_pre_commit_hook(@precommit_template, @precommit_options)
|
42
|
+
gitignore(@gitignore_files)
|
39
43
|
install_sandbox
|
40
44
|
install_dependencies
|
41
45
|
extra_setup
|
@@ -74,6 +78,8 @@ module CreateProj
|
|
74
78
|
#
|
75
79
|
# @return nothing.
|
76
80
|
def add_pre_commit_hook(template, options)
|
81
|
+
return if @precommit_template.empty? || @precommit_options.empty?
|
82
|
+
|
77
83
|
base_path = File.expand_path('../../../../templates', __FILE__)
|
78
84
|
template_path = File.join(base_path, template)
|
79
85
|
hook = Mustache.render(File.read(template_path), options)
|
@@ -96,6 +102,19 @@ module CreateProj
|
|
96
102
|
def install_dependencies
|
97
103
|
end
|
98
104
|
|
105
|
+
# Add a list of files from @gitignore_files
|
106
|
+
#
|
107
|
+
# @example
|
108
|
+
def gitignore(ignore_files)
|
109
|
+
return if ignore_files.empty?
|
110
|
+
|
111
|
+
File.open('.gitignore', 'w+') do |f|
|
112
|
+
ignore_files.each do |gf|
|
113
|
+
f.write("#{gf}\n")
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
99
118
|
# intended to be overwritten per class
|
100
119
|
def extra_setup
|
101
120
|
end
|
@@ -6,6 +6,18 @@ module CreateProj
|
|
6
6
|
super(*args)
|
7
7
|
@precommit_template = 'lint-pre-commit'
|
8
8
|
@precommit_options = { linter: 'rubocop', file_ext: '.rb' }
|
9
|
+
@gitignore_files = %w(.ruby-gemset .ruby-version .bundle
|
10
|
+
Gemfile.lock doc .yardoc)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Creates a namespaced gemset name to avoid overwriting of gemsets
|
14
|
+
#
|
15
|
+
# @example Get gemset name if project name is test
|
16
|
+
# gemset_name #=> 'test-createproj'
|
17
|
+
#
|
18
|
+
# @return [String] that has unique integer name
|
19
|
+
def gemset_name
|
20
|
+
"#{@name}-createproj"
|
9
21
|
end
|
10
22
|
|
11
23
|
# Create an rvm gemset with the project name and
|
@@ -18,26 +30,39 @@ module CreateProj
|
|
18
30
|
#
|
19
31
|
# @return Nothing
|
20
32
|
def install_sandbox
|
21
|
-
RVM.gemset_create
|
22
|
-
RVM.gemset_use @name
|
33
|
+
RVM.gemset_create(gemset_name)
|
23
34
|
|
35
|
+
# must have both .ruby-gemset and .ruby-version file
|
24
36
|
File.open('.ruby-gemset', 'w+') do |f|
|
25
|
-
f.write(
|
37
|
+
f.write(gemset_name)
|
38
|
+
end
|
39
|
+
|
40
|
+
# @todo - make this an option
|
41
|
+
default_ruby_version = '2.0.0'
|
42
|
+
File.open('.ruby-version', 'w+') do |f|
|
43
|
+
f.write(default_ruby_version)
|
26
44
|
end
|
27
45
|
end
|
28
46
|
|
29
47
|
# Installs dependencies in the new sandbox
|
30
48
|
#
|
31
|
-
# @example
|
32
|
-
# install_dependencies #=> rubocop
|
49
|
+
# @example Write rubocop to a gemfile and prompt `bundle install`
|
50
|
+
# install_dependencies #=> rubocop written in Gemfile
|
33
51
|
#
|
34
52
|
# @return Nothing
|
35
53
|
def install_dependencies
|
36
|
-
gems_to_install =
|
54
|
+
gems_to_install = {
|
55
|
+
'rubocop' => '0.28', 'rspec' => '3.0', 'yard' => '0.8'
|
56
|
+
}
|
37
57
|
|
38
|
-
|
39
|
-
|
58
|
+
File.open('Gemfile', 'w+') do |f|
|
59
|
+
f.write("source 'https://rubygems.org'\n\n")
|
60
|
+
gems_to_install.each do |k, v|
|
61
|
+
f.write("gem '#{k}', '~> #{v}'\n")
|
62
|
+
end
|
40
63
|
end
|
64
|
+
|
65
|
+
puts 'Enter the directory and run bundle install.'
|
41
66
|
end
|
42
67
|
end
|
43
68
|
end
|
data/lib/createproj/version.rb
CHANGED
data/lib/createproj.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: createproj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt McNaughton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|