rscaffold 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1266e781645b607559f2b3eb06ba49edcb5c9ac6
4
+ data.tar.gz: fac620a68838f619b9f7d8402e37df0ffd22889e
5
+ SHA512:
6
+ metadata.gz: a6b34feb80d5ed6ed45b48eba7447d82fb6e43a2a8383cf5fba07b93723ab8afc62859a0235aac2ba5ba121c5edb49d3abaea7f5879ddbe8d24fb940bee2e9da
7
+ data.tar.gz: f861ac5d10f5d95aca71933374744772a669715810e6a3ed3ed4f83f8b0a4be4a828550dc13d5f73bf8bd91c163efcc0310e7bf7f3f8fa1437703a572818455d
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ rscaffold
2
+ ---------
3
+ make a new ruby project.
4
+ rscaffold is a similar concept to jeweler,
5
+ but is meant to be simpler and smaller.
6
+
7
+ Installation
8
+ ---------
9
+
10
+ git clone https://github.com/rscaffold
11
+ cd rscaffold
12
+ rake install
13
+
14
+ (use `sudo` as necessary)
15
+
16
+ Runtime Requirements
17
+ ---------
18
+ ruby >= 1.9.2
19
+
20
+ Build Requirements
21
+ ---------
22
+ rake
23
+
24
+ Inspiration and History
25
+ ---------
26
+ I like automated setup of project scaffolding.
27
+ I thought jeweler is a little too much.
28
+
29
+ License
30
+ ---------
31
+ © 2014 Noah Birnel
32
+ MIT license
33
+
34
+ [![Build Status](https://travis-ci.org/nbirnel/rscaffold.png?branch=master)](https://travis-ci.org/nbirnel/rscaffold)
35
+ [![Code Climate](https://codeclimate.com/github/nbirnel/rscaffold.png)](https://codeclimate.com/github/nbirnel/rscaffold)
data/bin/rscaffold ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rscaffold'
4
+
5
+ @project_name = ARGV.shift
6
+
7
+
8
+ @project = RScaffold::Project.new @project_name
9
+ @project.write_all
10
+
@@ -0,0 +1,23 @@
1
+ Copyright (c) <%= Time.now.year %> <%= @owner %>
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without
5
+ modification, are permitted provided that the following conditions are met:
6
+
7
+ 1. Redistributions of source code must retain the above copyright notice, this
8
+ list of conditions and the following disclaimer.
9
+
10
+ 2. Redistributions in binary form must reproduce the above copyright notice,
11
+ this list of conditions and the following disclaimer in the documentation
12
+ and/or other materials provided with the distribution.
13
+
14
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
18
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,19 @@
1
+ Copyright (c) <%= Time.now.year %> <%= @owner %>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ module RScaffold
2
+
3
+ class Version
4
+ MAJOR = 0
5
+ MINOR = 0
6
+ PATCH = 1
7
+
8
+ class << self
9
+ def to_s
10
+ [MAJOR, MINOR, PATCH].join('.')
11
+ end
12
+ end
13
+ end
14
+
15
+ VERSION = Version.to_s
16
+
17
+ end
data/lib/rscaffold.rb ADDED
@@ -0,0 +1,143 @@
1
+ require 'erb'
2
+ require 'rscaffold/version'
3
+ require 'fileutils'
4
+ include FileUtils
5
+
6
+ module RScaffold
7
+
8
+ def self.camel_case string
9
+ string.split(/_/).map{|w| w.capitalize}.join ''
10
+ end
11
+
12
+ class Project
13
+ ATTRS = %w(
14
+ bin
15
+ camel
16
+ codeclimate
17
+ description
18
+ email
19
+ fullname
20
+ gemversion
21
+ homepage
22
+ license
23
+ location
24
+ owner
25
+ remote
26
+ remote_path
27
+ rubyver
28
+ summary
29
+ travis
30
+ usage
31
+ whoami
32
+ )
33
+
34
+ ATTRS.each{|a| attr_accessor a.to_sym}
35
+
36
+ attr_reader :name
37
+
38
+ def initialize name
39
+ @name = name
40
+ @bin = @name
41
+ @camel = RScaffold.camel_case @name
42
+
43
+ @rubyver = '>=1.8.7'
44
+ @license = 'MIT'
45
+
46
+ @today = Time.now.strftime '%Y-%m-%d'
47
+ @yyyy = Time.now.year
48
+
49
+ # This disgusting thing is to work across *nix, Windows, and Cygwin.
50
+ @whoami = ( ENV["USER"] || ENV["USERNAME"] ).sub(/.*\\/, '')
51
+ @email = `git config --get user.email`
52
+ @fullname = `git config --get user.name`
53
+ @owner = @fullname
54
+
55
+ @remote_path = "#{@whoami}/#{@name}"
56
+ @remote = "http://github.com/#{@remote_path}"
57
+ @homepage = @remote
58
+ @travis = travis_of @remote_path
59
+ @codeclimate = codeclimate_of @remote_path
60
+ @gemversion = gemversion_of @name
61
+
62
+ @summary = "!!SUMMARY!!"
63
+ @description = "!!DESCRIPTION!!"
64
+ @usage = "!!USAGE!!"
65
+
66
+ @location = {
67
+ :bin => "bin/#{@bin}",
68
+ :gemfile => "Gemfile",
69
+ :gemspec => "#{@name}.gemspec",
70
+ :gitignore => ".gitignore",
71
+ :license => "LICENSE",
72
+ :man => "man/man1/#{@bin}.1",
73
+ :project => "lib/#{@name}.rb",
74
+ :rakefile => "Rakefile",
75
+ :readme => "doc-src/README.md",
76
+ :rspec => ".rspec",
77
+ :spec => "spec/#{@name}_spec.rb",
78
+ :travis => ".travis.yml",
79
+ :version => "lib/#{@name}/version.rb",
80
+ }
81
+
82
+ end
83
+
84
+ def rendered template
85
+ ERB.new(contents(template), nil, '<>').result binding
86
+ end
87
+
88
+ def write template
89
+ FileUtils.mkdir_p File.dirname @location[template.to_sym]
90
+ File.open(@location[template.to_sym], 'w') do |file|
91
+ file.write rendered template
92
+ end
93
+ end
94
+
95
+ def write_all
96
+ @location.keys.each{|template| self.write(template.to_s)}
97
+ end
98
+
99
+ def licenses_avail
100
+ l = Dir.entries(licenses).reject{|el| el =~ /^(\.|\.\.)$/}
101
+ l.map{|fn| fn.sub(/\.erb$/, '')}
102
+ end
103
+
104
+ private
105
+
106
+ def travis_of path
107
+ travis_dir = "https://travis-ci.org/#{path}"
108
+ "[![Build Status](#{travis_dir}.png?branch=master)](#{travis_dir})"
109
+ end
110
+
111
+ def codeclimate_of path
112
+ codeclimate_dir = "https://codeclimate.com/github/#{path}"
113
+ "[![Code Climate](#{codeclimate_dir}.png)](#{codeclimate_dir})"
114
+ end
115
+
116
+ def gemversion_of path
117
+ gemversion_dir = "https://badge.fury.io/rb/#{path}"
118
+ "[![Gem Version](#{gemversion_dir}.png)](#{gemversion_dir})"
119
+ end
120
+
121
+ def contents template
122
+ if template == 'license'
123
+ filename = @license
124
+ dir = licenses
125
+ else
126
+ filename = template
127
+ dir = templates
128
+ end
129
+ file = "#{filename}.erb"
130
+ File.read(File.join(dir, file))
131
+ end
132
+
133
+ def templates
134
+ File.join(File.dirname(__FILE__), 'templates')
135
+ end
136
+
137
+ def licenses
138
+ File.join(File.dirname(__FILE__), 'licenses')
139
+ end
140
+
141
+ end
142
+
143
+ end
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require '<%=@name%>'
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'rake'
4
+
5
+ group :test do
6
+ gem 'rspec'
7
+ end
@@ -0,0 +1,21 @@
1
+ require './lib/<%=@name%>'
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = '<%=@name%>'
5
+ s.version = <%=@camel%>::VERSION
6
+ s.date = '<%=@today%>'
7
+ s.required_ruby_version = '<%@rubyver%>'
8
+ s.summary = "<%=@summary%>"
9
+ s.description = "<%=@description%>"
10
+ s.authors = ['<%=@fullname%>']
11
+ s.email = '<%=@email%>'
12
+ s.homepage = '<%=@homepage%>'
13
+ s.files = Dir.glob("{bin,lib,man}/**/*") + [
14
+ 'README.md',
15
+ '<%=@name%>.gemspec',
16
+ 'spec/<%=@name%>_spec.rb',
17
+ ]
18
+ s.has_rdoc = true
19
+ s.executables = ['<%=@bin%>']
20
+ s.license = '<%=@license%>'
21
+ end
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ doc/
@@ -0,0 +1,27 @@
1
+ .TH <%=@bin%> 1 <%=@bin%>\-0.0.0
2
+ .SH NAME
3
+ <%=@bin%> \- <%=@summary%>
4
+ .SH SYNOPSIS
5
+ .B <%=@bin%> <%=@usage%>
6
+ .SH DESCRIPTION
7
+ .B <%=@bin%>
8
+ <%=@description%>
9
+ .SH OPTIONS
10
+ .LP
11
+ .B --help
12
+ Print a brief usage message.
13
+ .SH EXAMPLES
14
+ .LP
15
+ .B <%=@bin%>
16
+ .SH FILES
17
+ .SH SEE ALSO
18
+ .TP
19
+ .BR ruby(1)
20
+ .TP
21
+ .IR <%=@fixmewebsite%>
22
+ .SH BUGS
23
+ Probably.
24
+ .SH LICENSE
25
+ Copyright <%=@year%> <%=@owner%>
26
+ .sp
27
+ <%=@license%>
@@ -0,0 +1,17 @@
1
+ module <%=@camel%>
2
+
3
+ class Version
4
+ MAJOR = 0
5
+ MINOR = 0
6
+ PATCH = 0
7
+
8
+ class << self
9
+ def to_s
10
+ [MAJOR, MINOR, PATCH].join('.')
11
+ end
12
+ end
13
+ end
14
+
15
+ VERSION = Version.to_s
16
+
17
+ end
@@ -0,0 +1,71 @@
1
+ require 'rspec/core/rake_task'
2
+ require 'rake/clean'
3
+ load 'lib/<%=@name%>.rb'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ VER = <%=@camel%>::VERSION
8
+ PROG = '<%=@name%>'
9
+ NAME = '<%=@bin%>'
10
+
11
+ LIB = FileList['lib/*.rb']
12
+ BIN = FileList['bin/*.rb']
13
+ TEST = FileList['spec/*.rb']
14
+ MAN = FileList['man/man*/*.?']
15
+ MANFILE = "#{NAME}.1"
16
+ SPEC = "#{PROG}.gemspec"
17
+ GEM = "#{PROG}-#{VER}.gem"
18
+ CLEAN.include('doc', '*.gem', 'README.md')
19
+ MANDIR = '/usr/local/man/man1/'
20
+ MANDEST = [MANDIR, MANFILE].join '/'
21
+ README = 'README.md'
22
+ READMESRC = 'doc-src/README.md'
23
+
24
+ task :all => [:spec, :install]
25
+
26
+ task :default => :spec
27
+
28
+ task :test => :spec
29
+
30
+ task :spec
31
+
32
+ file 'doc' => LIB do
33
+ `rdoc` #FIXME shell out not cool
34
+ end
35
+
36
+ task :readme => README
37
+
38
+ file README =>[READMESRC, MAN].flatten do
39
+ `cp #{READMESRC} #{README}`
40
+ `groff -tman -Thtml #{MAN} | sed '/<html/,$!d; /<style/,/<\\/style>/d' >>#{README}`
41
+ end
42
+
43
+ task :gem => GEM
44
+
45
+ file GEM => [LIB, BIN, TEST, MAN, SPEC, README].flatten do
46
+ `gem build #{SPEC}` #FIXME shell out not cool
47
+ end
48
+
49
+ task :install => [:install_gem, :install_man]
50
+
51
+ task :install_gem => GEM do
52
+ `gem install #{GEM}` #FIXME shell out not cool
53
+ end
54
+
55
+ task :install_man => MAN do
56
+ mkdir_p MANDIR
57
+ cp MAN, MANDIR
58
+ end
59
+
60
+ task :push do
61
+ `git push origin master` #FIXME shell out not cool
62
+ end
63
+
64
+ task :publish => :gem do
65
+ `gem push #{GEM}` #FIXME shell out not cool
66
+ end
67
+
68
+ task :uninstall do
69
+ `gem uninstall #{PROG}` #FIXME shell out not cool
70
+ File.delete MANDEST
71
+ end
@@ -0,0 +1,44 @@
1
+ <%=@name%>
2
+ ---------
3
+ <%=@summary%>
4
+
5
+ Installation
6
+ ---------
7
+ `gem install <%=@name%>`
8
+
9
+ or, if you want the latest and the greatest,
10
+ or if you want the man page installed:
11
+
12
+ git clone <%=@remote%>
13
+ cd <%=@name%>
14
+ rake install
15
+
16
+ (use `sudo` as necessary)
17
+
18
+ Runtime Requirements
19
+ ---------
20
+ ruby >= <%@rubyver%>
21
+
22
+ Build Requirements
23
+ ---------
24
+ rake
25
+
26
+ Developer Requirements
27
+ ---------
28
+ groff
29
+
30
+ Inspiration and History
31
+ ---------
32
+ <%=@fixme%>
33
+
34
+ License
35
+ ---------
36
+ © <%=@yyyy%> <%=@owner%>
37
+ <%=@license%> license
38
+
39
+ <%=@travis%>
40
+ <%=@codeclimate%>
41
+ <%=@gemversion%>
42
+
43
+ Man page
44
+ ---------
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
@@ -0,0 +1,8 @@
1
+ # coding: utf-8
2
+ require "#{File.dirname(__FILE__)}/../lib/<%=@name%>"
3
+
4
+ describe <%=@camel%> do
5
+ before do
6
+ end
7
+
8
+ end
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.8.7"
4
+ - "1.9.2"
5
+ - "1.9.3"
6
+ - "2.0.0"
7
+ - "2.1.0"
8
+ - jruby-18mode # JRuby in 1.8 mode
9
+ - jruby-19mode # JRuby in 1.9 mode
10
+ - rbx
11
+ # uncomment this line if your project needs to run something other than `rake`:
12
+ # script: bundle exec rspec spec
@@ -0,0 +1,17 @@
1
+ module <%=@camel%>
2
+
3
+ class Version
4
+ MAJOR = 0
5
+ MINOR = 0
6
+ PATCH = 0
7
+
8
+ class << self
9
+ def to_s
10
+ [MAJOR, MINOR, PATCH].join('.')
11
+ end
12
+ end
13
+ end
14
+
15
+ VERSION = Version.to_s
16
+
17
+ end
data/rscaffold.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ require "#{File.dirname(__FILE__)}/lib/rscaffold/version"
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'rscaffold'
5
+ s.version = RScaffold::VERSION
6
+ s.date = '2014-03-28'
7
+ s.required_ruby_version = '>=1.8.7'
8
+ s.summary = "make a new ruby project"
9
+ s.description = "rscaffold is a similar concept to jeweler,
10
+ but is meant to be simpler and smaller."
11
+ s.authors = ['Noah Birnel']
12
+ s.email = 'nbirnel@gmail.com'
13
+ s.homepage = 'http://github.com/nbirnel/rscaffold'
14
+ s.files = Dir.glob("{bin,lib}/**/*") + [
15
+ 'README.md',
16
+ 'rscaffold.gemspec',
17
+ 'spec/rscaffold_spec.rb'
18
+ ]
19
+ s.has_rdoc = true
20
+ s.executables = ['rscaffold']
21
+ s.license = 'MIT'
22
+ end
@@ -0,0 +1,66 @@
1
+ require "#{File.dirname(__FILE__)}/../lib/rscaffold"
2
+ require 'find'
3
+ include FileUtils
4
+ include FileTest
5
+ include Find
6
+
7
+ def output_files
8
+ Find.find('.').select{|f| FileTest.file?(f) }
9
+ end
10
+
11
+
12
+ describe RScaffold do
13
+
14
+ before(:all) do
15
+ FileUtils.rm_rf 'test_output'
16
+ FileUtils.mkdir_p 'test_output'
17
+ Dir.chdir 'test_output'
18
+ end
19
+
20
+ it 'camelcases a snake_case string' do
21
+ RScaffold.camel_case('foo_bar_baz').should eq 'FooBarBaz'
22
+ end
23
+
24
+ describe RScaffold::Project do
25
+
26
+ before do
27
+ @output_bin = "#!/usr/bin/env ruby\n\nrequire 'my_project'\n"
28
+ @p = RScaffold::Project.new 'my_project'
29
+ end
30
+
31
+ it 'has a name' do
32
+ @p.name.should eq 'my_project'
33
+ end
34
+
35
+ it 'has a CamelName' do
36
+ @p.camel.should eq 'MyProject'
37
+ end
38
+
39
+ it 'can have the remote reset' do
40
+ new_remote = 'https://some/secure/server/my_project'
41
+ @p.remote = new_remote
42
+ @p.remote.should eq new_remote
43
+ end
44
+
45
+ it 'renders templates' do
46
+ @p.rendered('bin').should eq @output_bin
47
+ end
48
+
49
+ it 'makes destination files' do
50
+ @p.write('bin')
51
+ File.read('bin/my_project').should eq @output_bin
52
+ end
53
+
54
+ it 'makes all destination files' do
55
+ @p.write_all
56
+ @p.location.length.should eq output_files.length
57
+ end
58
+
59
+ it 'lists all existing licenses' do
60
+ @p.licenses_avail.length.should be > 1
61
+ end
62
+
63
+ end
64
+
65
+ end
66
+
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rscaffold
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Noah Birnel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: "rscaffold is a similar concept to jeweler, \n but is meant to be
14
+ simpler and smaller."
15
+ email: nbirnel@gmail.com
16
+ executables:
17
+ - rscaffold
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - README.md
22
+ - bin/rscaffold
23
+ - lib/licenses/BSD-2.erb
24
+ - lib/licenses/MIT.erb
25
+ - lib/rscaffold.rb
26
+ - lib/rscaffold/version.rb
27
+ - lib/templates/bin.erb
28
+ - lib/templates/gemfile.erb
29
+ - lib/templates/gemspec.erb
30
+ - lib/templates/gitignore.erb
31
+ - lib/templates/man.erb
32
+ - lib/templates/project.erb
33
+ - lib/templates/rakefile.erb
34
+ - lib/templates/readme.erb
35
+ - lib/templates/rspec.erb
36
+ - lib/templates/spec.erb
37
+ - lib/templates/travis.erb
38
+ - lib/templates/version.erb
39
+ - rscaffold.gemspec
40
+ - spec/rscaffold_spec.rb
41
+ homepage: http://github.com/nbirnel/rscaffold
42
+ licenses:
43
+ - MIT
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.7
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.2.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: make a new ruby project
65
+ test_files: []