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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 843a43cbee86bb92e19bd92d3423b5b06ded456d
4
- data.tar.gz: 7fb99a78ab1f506f34dc0edcf151efd5e1eb90e4
3
+ metadata.gz: ce879aa2ccb1c26f3c594c5a1491469aa0d53efe
4
+ data.tar.gz: 066aa7e8ecbc2f812c9110e6588864d7de7c0c13
5
5
  SHA512:
6
- metadata.gz: 1edaef592474d5570dcfaed4d53870bdf2e8311e5acf57b5d9a142fda2c2765679f6289ccc65b4b9626e61f66306572e7de2cc2e1de4c430c68d28e6b13e3618
7
- data.tar.gz: fa4c9dd877892c7dcc43d7121d93d8278c61a954998ac467c9b044d3b075055b21c8c877d927344e3a88a40ef71526a49ba2a05d6b0bf8d12f9e2c2cecc819f3
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,7 @@ module CreateProj
6
6
  super(*args)
7
7
  @precommit_template = 'lint-pre-commit'
8
8
  @precommit_options = { linter: 'hlint', file_ext: '.hs' }
9
+ @gitignore_files = %w(cabal.sandbox.config .cabal-sandbox)
9
10
  end
10
11
 
11
12
  # Create an Haskell sandbox
@@ -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 @name
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(@name)
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 Installs rubocop in the gemset sandbox
32
- # install_dependencies #=> rubocop is no installed in the gemset
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 = %w(rubocop)
54
+ gems_to_install = {
55
+ 'rubocop' => '0.28', 'rspec' => '3.0', 'yard' => '0.8'
56
+ }
37
57
 
38
- gems_to_install.each do |g|
39
- system("gem install #{g}")
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
@@ -1,5 +1,5 @@
1
1
  # Namespace for CreateProj
2
2
  module CreateProj
3
3
  # Version number for the gem - make it only load once
4
- VERSION ||= '0.0.4'
4
+ VERSION ||= '0.0.5'
5
5
  end
data/lib/createproj.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # require all files needed for createproj
2
2
  require 'git'
3
3
  require 'mustache'
4
+ require 'open3'
4
5
  require 'rvm'
5
6
  require 'thor'
6
7
 
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
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-27 00:00:00.000000000 Z
11
+ date: 2014-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake