natstrap 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +22 -0
- data/Rakefile +1 -0
- data/bin/natstrap +5 -0
- data/lib/natstrap/cli.rb +35 -0
- data/lib/natstrap/templates/Gemfile.tt +20 -0
- data/lib/natstrap/templates/README.md.tt +3 -0
- data/lib/natstrap/templates/Rakefile.tt +9 -0
- data/lib/natstrap/templates/config/database.rb.tt +51 -0
- data/lib/natstrap/utils.rb +83 -0
- data/lib/natstrap/version.rb +3 -0
- data/lib/natstrap.rb +15 -0
- data/natstrap.gemspec +29 -0
- metadata +160 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Nathaniel Welch
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# Natstrap
|
2
|
+
|
3
|
+
AKA, icco/basic.
|
4
|
+
|
5
|
+
This is used to generate a project to work on.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install natstrap
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
* `natstrap new project_name` - creates a new project in a folder called project_name
|
14
|
+
* `natstrap launch` - launches a new GCE server
|
15
|
+
|
16
|
+
## Contributing
|
17
|
+
|
18
|
+
1. Fork it
|
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 new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/natstrap
ADDED
data/lib/natstrap/cli.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Natstrap
|
2
|
+
|
3
|
+
# http://whatisthor.com/
|
4
|
+
class CLI < Thor
|
5
|
+
desc "new name", "Create a project named NAME."
|
6
|
+
def new prj_name
|
7
|
+
# Init padrino
|
8
|
+
Natstrap::Utils.create_padrino prj_name
|
9
|
+
|
10
|
+
# enter into the dir
|
11
|
+
FileUtils.cd prj_name, :verbose => Natstrap::DEV
|
12
|
+
|
13
|
+
# Track all of our changes with git
|
14
|
+
Natstrap::Utils.git_init
|
15
|
+
Natstrap::Utils.git_commit "padrino init."
|
16
|
+
|
17
|
+
# Install templates, update gems
|
18
|
+
Natstrap::Utils.extend_padrino prj_name
|
19
|
+
Natstrap::Utils.git_commit "padrino configured."
|
20
|
+
|
21
|
+
# Move folders around the way I like them
|
22
|
+
Natstrap::Utils.reorganize_public
|
23
|
+
Natstrap::Utils.git_commit "public folder reorganized"
|
24
|
+
|
25
|
+
# Download and extract bootstrap framework.
|
26
|
+
Natstrap::Utils.add_bootstrap 'public'
|
27
|
+
Natstrap::Utils.git_commit "bootstrapped"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "launch", "Launch a new server."
|
31
|
+
def launch
|
32
|
+
puts "Launching!"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
source :rubygems
|
2
|
+
|
3
|
+
# Project requirements
|
4
|
+
gem 'activerecord', :require => "active_record"
|
5
|
+
gem 'erubis', "~> 2.7.0"
|
6
|
+
gem 'less'
|
7
|
+
gem 'pg'
|
8
|
+
gem 'rack-less'
|
9
|
+
gem 'rake'
|
10
|
+
gem 'sinatra-flash', :require => 'sinatra/flash'
|
11
|
+
gem 'therubyracer'
|
12
|
+
gem 'thin'
|
13
|
+
|
14
|
+
# Padrino Stable Gem
|
15
|
+
gem 'padrino', '0.10.6'
|
16
|
+
|
17
|
+
# For dev
|
18
|
+
group :development do
|
19
|
+
gem 'shotgun'
|
20
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
##
|
2
|
+
# Database config for relational db.
|
3
|
+
connections = {
|
4
|
+
:development => "postgres://localhost/<%= name %>",
|
5
|
+
:test => "postgres://postgres@localhost/<%= name %>_test",
|
6
|
+
:production => ENV['DATABASE_URL']
|
7
|
+
}
|
8
|
+
|
9
|
+
# Setup our logger
|
10
|
+
ActiveRecord::Base.logger = logger
|
11
|
+
|
12
|
+
# Include Active Record class name as root for JSON serialized output.
|
13
|
+
ActiveRecord::Base.include_root_in_json = true
|
14
|
+
|
15
|
+
# Store the full class name (including module namespace) in STI type column.
|
16
|
+
ActiveRecord::Base.store_full_sti_class = true
|
17
|
+
|
18
|
+
# Use ISO 8601 format for JSON serialized times and dates.
|
19
|
+
ActiveSupport.use_standard_json_time_format = true
|
20
|
+
|
21
|
+
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
22
|
+
# if you're including raw json in an HTML page.
|
23
|
+
ActiveSupport.escape_html_entities_in_json = false
|
24
|
+
|
25
|
+
# Now we can estabilish connection with our db
|
26
|
+
if connections[Padrino.env]
|
27
|
+
url = URI(connections[Padrino.env])
|
28
|
+
options = {
|
29
|
+
:adapter => url.scheme,
|
30
|
+
:host => url.host,
|
31
|
+
:port => url.port,
|
32
|
+
:database => url.path[1..-1],
|
33
|
+
:username => url.user,
|
34
|
+
:password => url.password
|
35
|
+
}
|
36
|
+
|
37
|
+
case url.scheme
|
38
|
+
when "sqlite"
|
39
|
+
options[:adapter] = "sqlite3"
|
40
|
+
options[:database] = url.host + url.path
|
41
|
+
when "postgres"
|
42
|
+
options[:adapter] = "postgresql"
|
43
|
+
end
|
44
|
+
|
45
|
+
# Log what we are connecting to.
|
46
|
+
logger.push " DB: #{options.inspect}", :devel
|
47
|
+
|
48
|
+
ActiveRecord::Base.establish_connection(options)
|
49
|
+
else
|
50
|
+
logger.push("No database configuration for #{Padrino.env.inspect}", :fatal)
|
51
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Natstrap
|
2
|
+
class Utils
|
3
|
+
|
4
|
+
# Based off of https://github.com/wycats/thor/blob/master/lib/thor/actions/file_manipulation.rb#L103
|
5
|
+
def self.write_template template, opts = {}
|
6
|
+
template_dir = File.join(File.dirname(__FILE__), "templates")
|
7
|
+
|
8
|
+
source = File.join(template_dir, "#{template}.tt")
|
9
|
+
|
10
|
+
namespace = OpenStruct.new(opts)
|
11
|
+
context = namespace.instance_eval { binding }
|
12
|
+
|
13
|
+
content = ERB.new(::File.binread(source), nil, '-', '@output_buffer').result(context)
|
14
|
+
open(template, 'wb') do |f|
|
15
|
+
f << content
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.create_padrino project_name
|
20
|
+
cmd = "padrino g project #{project_name} -i -e erb -d activerecord -s jquery -c less"
|
21
|
+
Kernel.system cmd
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.extend_padrino project_name
|
25
|
+
Natstrap::Utils.write_template "Gemfile"
|
26
|
+
|
27
|
+
Kernel.system "bundle update"
|
28
|
+
|
29
|
+
Natstrap::Utils.write_template "config/database.rb", :name => project_name
|
30
|
+
|
31
|
+
[
|
32
|
+
"padrino g model Entry text:text"
|
33
|
+
].each {|cmd| Kernel.system cmd }
|
34
|
+
|
35
|
+
Natstrap::Utils.write_template "Rakefile"
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.add_bootstrap dir
|
39
|
+
bootstrap = "http://twitter.github.com/bootstrap/assets/bootstrap.zip"
|
40
|
+
open bootstrap do |data|
|
41
|
+
Zip::Archive.open_buffer(data.read) do |ar|
|
42
|
+
ar.each do |zf|
|
43
|
+
if zf.directory?
|
44
|
+
dirname = zf.name.sub('bootstrap', dir)
|
45
|
+
FileUtils.mkdir_p dirname, :verbose => Natstrap::DEV
|
46
|
+
else
|
47
|
+
filename = zf.name.sub('bootstrap', dir)
|
48
|
+
dirname = File.dirname(filename)
|
49
|
+
FileUtils.mkdir_p dirname, :verbose => Natstrap::DEV
|
50
|
+
|
51
|
+
open(filename, 'wb') do |f|
|
52
|
+
f << zf.read
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.reorganize_public
|
61
|
+
[
|
62
|
+
['images', 'img'],
|
63
|
+
['javascripts', 'js'],
|
64
|
+
['stylesheets', 'css'],
|
65
|
+
].each do |from, to|
|
66
|
+
FileUtils.mv "public/#{from}", "public/#{to}", :verbose => Natstrap::DEV
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.git_init
|
71
|
+
g = Git.init
|
72
|
+
Natstrap::Utils.write_template "README.md"
|
73
|
+
g.add('README.md')
|
74
|
+
g.commit('init.')
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.git_commit msg
|
78
|
+
g = Git.open(FileUtils.pwd, :log => Logger.new(STDOUT))
|
79
|
+
g.add('.')
|
80
|
+
g.commit_all(msg)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/lib/natstrap.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'git'
|
3
|
+
require 'logger'
|
4
|
+
require 'open-uri'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'thor'
|
7
|
+
require 'zipruby'
|
8
|
+
|
9
|
+
require "natstrap/version"
|
10
|
+
require "natstrap/cli"
|
11
|
+
require "natstrap/utils"
|
12
|
+
|
13
|
+
module Natstrap
|
14
|
+
DEV = false
|
15
|
+
end
|
data/natstrap.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'natstrap/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "natstrap"
|
8
|
+
gem.version = Natstrap::VERSION
|
9
|
+
gem.authors = ["Nat Welch"]
|
10
|
+
gem.email = ["nat@natwelch.com"]
|
11
|
+
gem.description = %q{A gem to create a new project for Nat.}
|
12
|
+
gem.summary = %q{A gem to create a new project for Nat.}
|
13
|
+
gem.homepage = "http://github.com/icco/basic"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_runtime_dependency "bundler"
|
21
|
+
gem.add_runtime_dependency "git"
|
22
|
+
gem.add_runtime_dependency "fog"
|
23
|
+
gem.add_runtime_dependency "padrino"
|
24
|
+
gem.add_runtime_dependency "thor"
|
25
|
+
gem.add_runtime_dependency "zipruby"
|
26
|
+
|
27
|
+
gem.rdoc_options = ['--charset=UTF-8']
|
28
|
+
gem.licenses = ['MIT']
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: natstrap
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nat Welch
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: git
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fog
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: padrino
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: thor
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: zipruby
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :runtime
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: A gem to create a new project for Nat.
|
111
|
+
email:
|
112
|
+
- nat@natwelch.com
|
113
|
+
executables:
|
114
|
+
- natstrap
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- bin/natstrap
|
124
|
+
- lib/natstrap.rb
|
125
|
+
- lib/natstrap/cli.rb
|
126
|
+
- lib/natstrap/templates/Gemfile.tt
|
127
|
+
- lib/natstrap/templates/README.md.tt
|
128
|
+
- lib/natstrap/templates/Rakefile.tt
|
129
|
+
- lib/natstrap/templates/config/database.rb.tt
|
130
|
+
- lib/natstrap/utils.rb
|
131
|
+
- lib/natstrap/version.rb
|
132
|
+
- natstrap.gemspec
|
133
|
+
homepage: http://github.com/icco/basic
|
134
|
+
licenses:
|
135
|
+
- MIT
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options:
|
138
|
+
- --charset=UTF-8
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
143
|
+
requirements:
|
144
|
+
- - ! '>='
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 1.8.24
|
156
|
+
signing_key:
|
157
|
+
specification_version: 3
|
158
|
+
summary: A gem to create a new project for Nat.
|
159
|
+
test_files: []
|
160
|
+
has_rdoc:
|