createproj 0.1.0 → 0.1.1

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: 109bef4359c5185cba4e3dd9fee61ba6c50b3cc8
4
- data.tar.gz: 4493e7837fa58c48745dbf197b2d796561d5dd82
3
+ metadata.gz: 945ead0d57ea958c1bf510d11ebe76ac277b4a4d
4
+ data.tar.gz: c51491e2687ce04a00183466822c4cfc49a494d9
5
5
  SHA512:
6
- metadata.gz: 8d100bb9ea1fdd577bb8d73fd56cb47b910d3b04329f5636976b62b096fc47dfcd48c3e915b6bda1a59b752e1fcccb666feab744845287df88d41017ddf73d3e
7
- data.tar.gz: 9050d835d6c6686c56f7a3e94b3b16059a1b0a5e1fa19fb2b8f809da4d6cc8e24aad5b37093fdafc2132edb28ff2cff5d0ac837ce91778b7d1eec73710f90728
6
+ metadata.gz: 1784da067adbd2c9b48aa601d7cae5d5a7d6b267d6328126a4bc5064e2000008cf71b222daf653a985b167b9a0435cc4007f84750ef6c5ceb0f0c3cf735b9959
7
+ data.tar.gz: ef94d407e6900715ee8ec636883292bc5156ffe4d7d19af8dfc3bb97ae63e3e5e454da3169e1f0d62ca453f8d7add44a9639b56746ae814c2489e84aa81690fa
data/README.md CHANGED
@@ -22,9 +22,13 @@ Once run, createproj will:
22
22
  - Create the project directory
23
23
  - Initialize a git repository with a language specified .gitignore and language specified git pre-commit hook (right now both are linters)
24
24
  - Create a sandbox
25
- - rvm gemset for ruby, cabal sandbox for haskell
25
+ - Ruby: rvm gemset
26
+ - Haskell: cabal sandbox
27
+ - Python: virtualenv environment
26
28
  - Install default dependencies in the sandbox
27
- - rubocop, yard, rspec for ruby and happy, hlint for haskell
29
+ - Ruby: rubocop, yard, rspec
30
+ - Haskell: happy, hlint
31
+ - Python: pylint,
28
32
 
29
33
  ## Steps for building/publish gem
30
34
  - From `createproj` directory, run:
@@ -35,8 +39,17 @@ Once run, createproj will:
35
39
  - Code is linted using rubocop
36
40
  - Code is documented using Yardoc
37
41
 
38
- ## Assumptions
39
- I built this largely for my personal use so there are a couple of assumptions made.
40
- The first is that RVM and Cabal are installed.
42
+ ## Dependencies
43
+ For each language, I assume certain dependencies:
44
+ - Ruby
45
+ - [Rvm](https://rvm.io/)
46
+ - Haskell
47
+ - [Cabal](https://www.haskell.org/cabal/)
48
+ - Python
49
+ - [virtualenv](https://virtualenv.pypa.io/en/latest/), [virtualenvwrapper](http://virtualenvwrapper.readthedocs.org/en/latest/index.html)
50
+ - I also assume that [this](https://gist.github.com/mattjmcnaughton/4d599b62b60b59f9229f) virtualenv script is sourced. If not, instructions will be given to install.
51
+
52
+ ## Contributing
53
+ Please do! Let me know if I can be of any help!
41
54
 
42
55
 
@@ -18,6 +18,19 @@ module CreateProj
18
18
  CreateProj::Creator::HaskellCreator.new(name, options).run
19
19
  end
20
20
 
21
+ desc 'python NAME', 'create a python project called NAME'
22
+ # Command line input option for creating python project.
23
+ #
24
+ # @param [String] name the project
25
+ #
26
+ # @example Call from command line
27
+ # $ ./createproj python newproj #=> creates python proj called newproj
28
+ #
29
+ # @return Nothing
30
+ def python(name)
31
+ CreateProj::Creator::PythonCreator.new(name, options).run
32
+ end
33
+
21
34
  desc 'rails NAME', 'create a rails project called NAME'
22
35
  method_option :database, aliases: '-d', desc: 'database to use'
23
36
  method_option :javascript, aliases: '-j', desc: 'javascript library'
@@ -0,0 +1,92 @@
1
+ module CreateProj
2
+ module Creator
3
+ # Class for creating Ruby project
4
+ class PythonCreator < Creator
5
+ def initialize(*args)
6
+ super(*args)
7
+ @precommit_template = 'lint-pre-commit'
8
+ @precommit_options = { linter: 'pylint', file_ext: '.py' }
9
+ @gitignore_files = %w(*.pyc)
10
+ @packages_to_install = {
11
+ 'pylint' => '1.4.0'
12
+ }
13
+ end
14
+
15
+ # Creates a namespaced virtualenv name
16
+ #
17
+ # @example Get virtualenv name if project name is test
18
+ # virtualenv_name #=> 'test-createproj'
19
+ #
20
+ # @return [String] that has unique integer name
21
+ def virtualenv_name
22
+ "#{@name}-createproj"
23
+ end
24
+
25
+ # Write a .venv file with the name of the virtualenv
26
+ #
27
+ # @example
28
+ # write_venv_file #=> `cat .venv` #=> NAME
29
+ #
30
+ # @return Nothing
31
+ def write_venv_file
32
+ # must have both .ruby-gemset and .ruby-version file
33
+ File.open('.venv', 'w+') do |f|
34
+ f.write(virtualenv_name)
35
+ end
36
+ end
37
+
38
+ # Check that a bash script
39
+ def check_bash_script
40
+ command = <<-eos
41
+ If you want the virtual env to be automatically activated
42
+ upon entering the directory, follow the instructions in
43
+ this gist (https://gist.github.com/mattjmcnaughton/4d599b62b60b59f9229f).
44
+ eos
45
+
46
+ puts command unless File.exist?(File.join("#{Dir.home}",
47
+ '.virtualenv_sourcer'))
48
+ end
49
+
50
+ # Create an virtualenv with the project name and
51
+ # creates file dictating virtualenv
52
+ #
53
+ # @todo Automate creating the virtualenv
54
+ #
55
+ # Check that the user has installed a bash script
56
+ # that will automatically `workon ENV` when entering
57
+ # directory with a .venv file
58
+ #
59
+ # @example Create rvm sandbox for project named test
60
+ # install_sandbox #=> Executes `mkvirtualenv NAME`, write .env file,
61
+ # and check for bash script
62
+ #
63
+ # @return Nothing
64
+ def install_sandbox
65
+ # make system call to virtualenvwrapper to create the virtualenv
66
+ command = "Run mkvirtualenv #{virtualenv_name}"
67
+
68
+ puts command
69
+ write_venv_file
70
+ check_bash_script
71
+ end
72
+
73
+ # Installs dependencies in the new sandbox
74
+ #
75
+ # @example Write pylint to a requirements.txt and
76
+ # prompt `pip install -r requirements.txt`
77
+ # install_dependencies #=> pylint written in Gemfile
78
+ #
79
+ # @return Nothing
80
+ def install_dependencies
81
+ File.open('requirements.txt', 'w+') do |f|
82
+ @packages_to_install.each do |k, v|
83
+ f.write("#{k}==#{v}\n")
84
+ end
85
+ end
86
+
87
+ command = 'Enter the directory and run pip install requirements.txt'
88
+ puts command
89
+ end
90
+ end
91
+ end
92
+ end
@@ -8,6 +8,11 @@ module CreateProj
8
8
  @precommit_options = { linter: 'rubocop', file_ext: '.rb' }
9
9
  @gitignore_files = %w(.ruby-gemset .ruby-version .bundle
10
10
  Gemfile.lock doc .yardoc)
11
+
12
+ @gems_to_install = {
13
+ 'rubocop' => '0.28', 'rspec' => '3.0', 'yard' => '0.8'
14
+ }
15
+ @default_ruby_version = '2.0.0'
11
16
  end
12
17
 
13
18
  # Creates a namespaced gemset name to avoid overwriting of gemsets
@@ -20,30 +25,41 @@ module CreateProj
20
25
  "#{@name}-createproj"
21
26
  end
22
27
 
23
- # Create an rvm gemset with the project name and
24
- # creates file dictating gemset
28
+ # Write the .ruby-gemset and .ruby-version rvm files
25
29
  #
26
30
  # @todo - make it so can specify ruby version
27
31
  #
28
- # @example Create rvm sandbox for project named test
29
- # install_sandbox #=> Executes `rvm gemset create test`
32
+ # @example
33
+ # write_rvm_files #=> # writes the two files
30
34
  #
31
35
  # @return Nothing
32
- def install_sandbox
33
- RVM.gemset_create(gemset_name)
34
-
36
+ def write_rvm_files
35
37
  # must have both .ruby-gemset and .ruby-version file
36
38
  File.open('.ruby-gemset', 'w+') do |f|
37
39
  f.write(gemset_name)
38
40
  end
39
41
 
40
42
  # @todo - make this an option
41
- default_ruby_version = '2.0.0'
43
+
42
44
  File.open('.ruby-version', 'w+') do |f|
43
- f.write(default_ruby_version)
45
+ f.write(@default_ruby_version)
44
46
  end
45
47
  end
46
48
 
49
+ # Create an rvm gemset with the project name and
50
+ # creates file dictating gemset
51
+
52
+ #
53
+ # @example Create rvm sandbox for project named test
54
+ # install_sandbox #=> Executes `rvm gemset create test`
55
+ #
56
+ # @return Nothing
57
+ def install_sandbox
58
+ RVM.gemset_create(gemset_name)
59
+
60
+ write_rvm_files
61
+ end
62
+
47
63
  # Installs dependencies in the new sandbox
48
64
  #
49
65
  # @example Write rubocop to a gemfile and prompt `bundle install`
@@ -51,18 +67,15 @@ module CreateProj
51
67
  #
52
68
  # @return Nothing
53
69
  def install_dependencies
54
- gems_to_install = {
55
- 'rubocop' => '0.28', 'rspec' => '3.0', 'yard' => '0.8'
56
- }
57
-
58
70
  File.open('Gemfile', 'w+') do |f|
59
71
  f.write("source 'https://rubygems.org'\n\n")
60
- gems_to_install.each do |k, v|
72
+ @gems_to_install.each do |k, v|
61
73
  f.write("gem '#{k}', '~> #{v}'\n")
62
74
  end
63
75
  end
64
76
 
65
- puts 'Enter the directory and run bundle install.'
77
+ command = 'Enter the directory and run bundle install.'
78
+ puts command
66
79
  end
67
80
  end
68
81
  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.1.0'
4
+ VERSION ||= '0.1.1'
5
5
  end
data/lib/createproj.rb CHANGED
@@ -12,3 +12,4 @@ require 'createproj/creator/creator'
12
12
  require 'createproj/creator/haskell'
13
13
  require 'createproj/creator/ruby'
14
14
  require 'createproj/creator/rails'
15
+ require 'createproj/creator/python'
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.1.0
4
+ version: 0.1.1
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-28 00:00:00.000000000 Z
11
+ date: 2015-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -164,6 +164,7 @@ files:
164
164
  - lib/createproj/cli.rb
165
165
  - lib/createproj/creator/creator.rb
166
166
  - lib/createproj/creator/haskell.rb
167
+ - lib/createproj/creator/python.rb
167
168
  - lib/createproj/creator/rails.rb
168
169
  - lib/createproj/creator/ruby.rb
169
170
  - lib/createproj/version.rb