ruby-generator 0.1.0

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/ruby-generator +4 -0
  3. data/lib/generator.rb +58 -0
  4. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 69cec6ff7ab9d342c6850227db58476f4c52fa4f055badeb8b6a7fe0e7ef622d
4
+ data.tar.gz: 9ccafe6b0565e59dcb0f0b6e3787869676dfcd4d6661a045cdb5ea91b31cf722
5
+ SHA512:
6
+ metadata.gz: 0ac46ebf34a676a5b771b3a8a406b5c44b96480b5c2553beb9927eef50c0c48f3f296bc4c21008bc7e41c360a2df91971987a3c83dc9ca1e46c494084ca49af5
7
+ data.tar.gz: 19b0b8ef5f37041cf5b1443444df3bbd6cfba63a0fdbcf1230a7cc1dbd5873134f176e267b514b7fdbade4fe344045ea96aa0434fc7102a7244ea15190122f0f
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/generator'
3
+
4
+ Generator.new.run(ARGV)
data/lib/generator.rb ADDED
@@ -0,0 +1,58 @@
1
+ class Generator
2
+
3
+ GREEN='\033[0;32m'
4
+ RED='\033[0;31m'
5
+ NC='\033[0m'
6
+ CREATED = "#{GREEN}created#{NC}"
7
+ ADDLINE = "#{GREEN}added#{NC}"
8
+
9
+ def run(array)
10
+ if array[0] == "new"
11
+ new(array[1])
12
+ else
13
+ puts "unknown command"
14
+ end
15
+ end
16
+
17
+ def new(project)
18
+ # print "What would you like to call your project? "
19
+ # project = gets.strip
20
+ pdir = "./#{project}"
21
+ add_folder(pdir)
22
+ add_folder("#{pdir}/bin")
23
+ add_file("#{pdir}/bin/#{project}")
24
+ add_line("#!usr/bin/env ruby", "#{pdir}/bin/#{project}")
25
+ add_folder("#{pdir}/lib")
26
+ initialize_gemfile(pdir)
27
+ end
28
+
29
+ def add_file(path)
30
+ system("touch #{path}")
31
+ system("printf '#{CREATED} #{path}\n'")
32
+ end
33
+
34
+ def add_folder(path)
35
+ system("mkdir #{path}")
36
+ system("printf '#{CREATED} #{path}\n'")
37
+ end
38
+
39
+ def add_line(text, path)
40
+ system("echo '#{text}' >> #{path}")
41
+ system("printf '#{ADDLINE} #{text} >> #{path}\n'")
42
+ end
43
+
44
+ def initialize_gemfile(path)
45
+ system("cd #{path} && bundle init")
46
+ system("printf '#{CREATED} #{path}/Gemfile\n'")
47
+ system("echo '\ngroup :test, :development do' >> #{path}/Gemfile")
48
+ add_line(' gem "pry"', "#{path}/Gemfile")
49
+ system("echo 'end' >> #{path}/Gemfile")
50
+ system("echo '\ngroup :test do' >> #{path}/Gemfile")
51
+ add_line(' gem "rspec"', "#{path}/Gemfile")
52
+ system("echo 'end' >> #{path}/Gemfile")
53
+ system("cd #{path} && bundle install && rspec --init")
54
+ add_line('--format d', "#{path}/.rspec")
55
+ add_line('--color', "#{path}/.rspec")
56
+ end
57
+
58
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Enoch Griffith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-04-19 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A gem that helps you quickly build a ruby project
14
+ email: enochgriffith1985@gmail.com
15
+ executables:
16
+ - ruby-generator
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/ruby-generator
21
+ - lib/generator.rb
22
+ homepage:
23
+ licenses: []
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.7.6
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: A Ruby Project Generator
45
+ test_files: []