new_project 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d151ffab400eb5206bad97268961c09e65b4efc5
4
+ data.tar.gz: 6d92db62ed84d9007ce5837e7aca8391a51818c0
5
+ SHA512:
6
+ metadata.gz: 9393455b1ae2358d21cb3fc9b9e8f40ce4de17496e38d1386c07c9352cd8047611d1e8b3bc4becbc00b250990da443e52ea44478c233975cc5d51c91e476c070
7
+ data.tar.gz: e58074dd42d56b30d9318b77231a99caa0bb497b52fb39ad587c7f2e1477ee2356917e5b5d0000573c1279391b4d1bdeb1f122283b133b6a8d65979fc9cb0163
data/.gitignore ADDED
@@ -0,0 +1,30 @@
1
+ *.db
2
+ .DS_Store
3
+ *.gem
4
+ *.rbc
5
+ /.config
6
+ /coverage/
7
+ /InstalledFiles
8
+ /pkg/
9
+ /spec/reports/
10
+ /test/tmp/
11
+ /test/version_tmp/
12
+ /tmp/
13
+
14
+ /.yardoc/
15
+ /_yardoc/
16
+ /doc/
17
+ /rdoc/
18
+
19
+ /.bundle/
20
+ /lib/bundler/man/
21
+
22
+ Gemfile.lock
23
+ .ruby-version
24
+ .ruby-gemset
25
+
26
+ .rvmrc
27
+
28
+ *~
29
+ \#*\#
30
+ .\#*
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Keith Thibodeaux
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # new_project
2
+
3
+ Makes a directory and skeleton project
4
+
5
+ ## Installation
6
+
7
+ $ git clone git@github.com:kthibodeaux/new_project.git
8
+ $ cd new_project
9
+ $ gem build new_project.gemspec
10
+ $ gem install new_project-x.x.x.gem
11
+
12
+ ## Usage
13
+
14
+ $ new_project <project_name_in_snake_case>
15
+
16
+ ## Contributing
17
+
18
+ 1. Fork it ( https://github.com/kthibodeaux/new_project/fork )
19
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
20
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
21
+ 4. Push to the branch (`git push origin my-new-feature`)
22
+ 5. Create a new Pull Request
data/bin/new_project ADDED
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH << File.join(File.expand_path('.'), 'lib')
2
+ require 'new_project'
3
+
4
+ if ARGV.size != 1
5
+ puts "Usage: new_project <project_name_in_snake_case>"
6
+ fail "Invalid arguments" unless ARGV.size == 1
7
+ end
8
+
9
+ fail "Directory #{ARGV.first} already exists" if Dir.exists?(ARGV.first)
10
+
11
+ project = NewProject::Project.new(ARGV.first)
12
+
13
+ FileUtils.mkpath("#{project.snake_name}/bin")
14
+ FileUtils.mkpath("#{project.snake_name}/lib/#{project.snake_name}")
15
+ FileUtils.mkpath("#{project.snake_name}/spec/#{project.snake_name}")
16
+
17
+ [
18
+ NewProject::Template.new(project, 'bin-run', 'bin/run.rb'),
19
+ NewProject::Template.new(project, 'gemfile', 'Gemfile'),
20
+ NewProject::Template.new(project, 'gitignore', '.gitignore'),
21
+ NewProject::Template.new(project, 'lib-project', "lib/#{project.snake_name}.rb"),
22
+ NewProject::Template.new(project, 'spec-helper', 'spec/spec_helper.rb')
23
+ ].each do |template|
24
+ template.save
25
+ end
@@ -0,0 +1,24 @@
1
+ require 'new_project/project'
2
+ require 'new_project/template'
3
+
4
+ require 'erb'
5
+ require 'fileutils'
6
+
7
+ module NewProject
8
+
9
+ VERSION = '0.0.1'
10
+
11
+ def self.root
12
+ File.expand_path('../..', __FILE__)
13
+ end
14
+
15
+ end
16
+
17
+ class String
18
+
19
+ def camelcase
20
+ downcase.gsub('_', ' ').split(/(\W)/).
21
+ map(&:capitalize).join.delete(' ')
22
+ end
23
+
24
+ end
@@ -0,0 +1,18 @@
1
+ module NewProject
2
+ class Project
3
+ attr_reader :snake_name, :camel_name
4
+
5
+ def initialize(snake_name)
6
+ @snake_name = snake_name.downcase
7
+ @camel_name = snake_name.camelcase
8
+ end
9
+
10
+ def to_h()
11
+ {
12
+ snake_name: snake_name,
13
+ camel_name: camel_name
14
+ }
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ module NewProject
2
+ class Template
3
+ attr_reader :name, :path, :project, :contents
4
+
5
+ def initialize(project, name, path)
6
+ @project = project.to_h
7
+ @name = name
8
+ @path = path
9
+ @contents = raw
10
+ end
11
+
12
+ def render
13
+ ERB.new(contents).result(binding)
14
+ end
15
+
16
+ def save
17
+ File.open("./#{project[:snake_name]}/#{path}", 'w') do |f|
18
+ f.puts render
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def raw
25
+ raw_file = File.open("#{NewProject.root}/templates/#{name}.erb", 'r')
26
+ contents = raw_file.read
27
+ raw_file.close
28
+ contents
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'new_project'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'new_project'
8
+ spec.version = NewProject::VERSION
9
+ spec.authors = ["Keith Thibodeaux"]
10
+ spec.email = ["keith@railscoder.net"]
11
+ spec.summary = 'A quick and easy way to start a Ruby app'
12
+ spec.description = 'Creates bin/run.rb lib/project/ lib/project.rb spec/spec_helper.rb spec/project/ .gitignore Gemfile'
13
+ spec.homepage = 'https://github.com/kthibodeaux/new_project'
14
+ spec.licenses = ['MIT']
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(spec)/})
19
+ spec.require_paths = ["lib", "templates"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec", "~> 2.6"
24
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe NewProject::Project do
4
+
5
+ let(:project) { new_project }
6
+
7
+ it "responds to #snake_name" do
8
+ expect(project.snake_name).to eq('test_project')
9
+ end
10
+
11
+ it "responds to #camel_name" do
12
+ expect(project.camel_name).to eq('TestProject')
13
+ end
14
+
15
+ it "responds to #to_h" do
16
+ expect(project.to_h).to eq({
17
+ :snake_name => 'test_project',
18
+ :camel_name => 'TestProject'
19
+ })
20
+ end
21
+
22
+ end
23
+
24
+ def new_project
25
+ NewProject::Project.new('test_project')
26
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe NewProject::Template do
4
+
5
+ before(:all) { prepare }
6
+ after(:all) { cleanup }
7
+
8
+ let(:project) { new_project }
9
+ let(:template) { NewProject::Template.new(project, 'temp', 'bin/greet.rb') }
10
+
11
+ it "responds to #render" do
12
+ expect(template.render).to eq("puts 'hello, TestProject'\n")
13
+ end
14
+
15
+ it "responds to #save" do
16
+ template.save
17
+ output = File.open("#{project.snake_name}/bin/greet.rb")
18
+ contents = output.read
19
+ output.close
20
+ expect(contents).to eq("puts 'hello, TestProject'\n")
21
+ end
22
+
23
+ end
24
+
25
+ def prepare
26
+ FileUtils.mkpath("test_project/bin")
27
+ File.open('templates/temp.erb', 'w') do |f|
28
+ f.puts "puts 'hello, <%= project[:camel_name] %>'"
29
+ end
30
+ end
31
+
32
+ def cleanup
33
+ File.delete('templates/temp.erb')
34
+ File.delete("#{project.snake_name}/bin/greet.rb")
35
+ Dir.delete("#{project.snake_name}/bin")
36
+ Dir.delete(project.snake_name)
37
+ end
@@ -0,0 +1 @@
1
+ require 'new_project'
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH << File.join(File.expand_path('.'), 'lib')
2
+ require '<%= project[:snake_name] %>'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :development do
4
+ gem 'rspec'
5
+ end
@@ -0,0 +1,30 @@
1
+ *.db
2
+ .DS_Store
3
+ *.gem
4
+ *.rbc
5
+ /.config
6
+ /coverage/
7
+ /InstalledFiles
8
+ /pkg/
9
+ /spec/reports/
10
+ /test/tmp/
11
+ /test/version_tmp/
12
+ /tmp/
13
+
14
+ /.yardoc/
15
+ /_yardoc/
16
+ /doc/
17
+ /rdoc/
18
+
19
+ /.bundle/
20
+ /lib/bundler/man/
21
+
22
+ Gemfile.lock
23
+ .ruby-version
24
+ .ruby-gemset
25
+
26
+ .rvmrc
27
+
28
+ *~
29
+ \#*\#
30
+ .\#*
@@ -0,0 +1,9 @@
1
+ module <%= project[:camel_name] %>
2
+
3
+ VERSION = '0.0.1'
4
+
5
+ def self.root
6
+ File.expand_path('../..', __FILE__)
7
+ end
8
+
9
+ end
@@ -0,0 +1 @@
1
+ require '<%= project[:snake_name] %>'
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: new_project
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Keith Thibodeaux
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.6'
55
+ description: Creates bin/run.rb lib/project/ lib/project.rb spec/spec_helper.rb spec/project/
56
+ .gitignore Gemfile
57
+ email:
58
+ - keith@railscoder.net
59
+ executables:
60
+ - new_project
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - LICENSE
67
+ - README.md
68
+ - bin/new_project
69
+ - lib/new_project.rb
70
+ - lib/new_project/project.rb
71
+ - lib/new_project/template.rb
72
+ - new_project.gemspec
73
+ - spec/new_project/project_spec.rb
74
+ - spec/new_project/template_spec.rb
75
+ - spec/spec_helper.rb
76
+ - templates/bin-run.erb
77
+ - templates/gemfile.erb
78
+ - templates/gitignore.erb
79
+ - templates/lib-project.erb
80
+ - templates/spec-helper.erb
81
+ homepage: https://github.com/kthibodeaux/new_project
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ - templates
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.2.2
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: A quick and easy way to start a Ruby app
106
+ test_files:
107
+ - spec/new_project/project_spec.rb
108
+ - spec/new_project/template_spec.rb
109
+ - spec/spec_helper.rb