up_and_running 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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +62 -0
- data/Rakefile +10 -0
- data/bin/unr +14 -0
- data/lib/up_and_running.rb +30 -0
- data/lib/up_and_running/compiler.rb +62 -0
- data/lib/up_and_running/version.rb +3 -0
- data/up_and_running.gemspec +25 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e5215284b759d1cb56976b9e2db49e9cfc1e9ec1
|
4
|
+
data.tar.gz: 22ecdfe28e0a516ea6c7ae8079ea3fd12c2b8ddc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 611bf88549548817892f3a80c509fcffc8cc4d982a3f02a1778489fe11cd525df6e1960bf4d17733dec508210814643e4cfb0fdfee255b4d0603ab44adb040fe
|
7
|
+
data.tar.gz: 3b14e9d15fb70c08be2b2e6b6cc055706017002bed1eb35a6a0a83275c509749888d42bc6cf517079c56df56d762b786a37f6c98d71e8e5fc1f947c095fc02ea
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# UpAndRunning
|
2
|
+
|
3
|
+
a simple, generic templating system with the goal of helping you rapidly bootstrap new projects
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```rb
|
8
|
+
gem install 'up_and_running'
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
The main interface for using `UpAndRunning` is the `unr` command.
|
14
|
+
It accepts a feature name, searches the `UP_AND_RUNNING_FEATURE_LOAD_PATH` for the correct compiler,
|
15
|
+
copies any template files, and compiles any ERB.
|
16
|
+
|
17
|
+
Compilers consist of two things:
|
18
|
+
* a compiler class (such as `gem.rb`)
|
19
|
+
* an optional template directory with the same name (such as `gem/`)
|
20
|
+
|
21
|
+
Everything in the template directory will be copied over into the output directory.
|
22
|
+
If there are any ERB templates, those will be compiled with the `@scope` variable from
|
23
|
+
the compiler instance
|
24
|
+
|
25
|
+
By default features are loaded from `~/.up_and_running/features`.
|
26
|
+
|
27
|
+
Here is a sample:
|
28
|
+
|
29
|
+
```rb
|
30
|
+
# ~/.up_and_running/sample.rb
|
31
|
+
class Sample < UpAndRunning::Compiler
|
32
|
+
def initialize
|
33
|
+
@scope = OpenStruct.new(username: 'jbodah')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# ~/.up_and_running/sample/hello.erb
|
38
|
+
Hello <%= username %>
|
39
|
+
```
|
40
|
+
|
41
|
+
Then you can just call the `unr` command with the name of your
|
42
|
+
|
43
|
+
```rb
|
44
|
+
unr sample
|
45
|
+
```
|
46
|
+
|
47
|
+
This will compile the templates and output them into your output directory:
|
48
|
+
|
49
|
+
```sh
|
50
|
+
$ tree
|
51
|
+
└── hello
|
52
|
+
```
|
53
|
+
|
54
|
+
Compilers also support `before_compile` and `after_compile` hooks. Just define those methods:
|
55
|
+
|
56
|
+
```rb
|
57
|
+
class MyCompiler < UpAndRunning::Compiler
|
58
|
+
def before_compile
|
59
|
+
puts 'hello world'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
```
|
data/Rakefile
ADDED
data/bin/unr
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
raise 'Usage: unr <FEATURE_NAME>' if ARGV.empty?
|
4
|
+
|
5
|
+
$: << File.expand_path('../../lib', __FILE__)
|
6
|
+
require 'up_and_running'
|
7
|
+
|
8
|
+
feature_name = ARGV[0]
|
9
|
+
|
10
|
+
feature_class = UpAndRunning::FeatureResolver.resolve(feature_name)
|
11
|
+
feature = feature_class.new
|
12
|
+
feature.before_compile
|
13
|
+
feature.compile
|
14
|
+
feature.after_compile
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'up_and_running/version'
|
2
|
+
require 'up_and_running/compiler'
|
3
|
+
|
4
|
+
module UpAndRunning
|
5
|
+
module FeatureResolver
|
6
|
+
extend self
|
7
|
+
|
8
|
+
# Returns the matching compiler
|
9
|
+
# TODO - abstract both compiler and templates into feature
|
10
|
+
def resolve(name)
|
11
|
+
load_path.reverse_each.find do |dir|
|
12
|
+
next unless Dir.exists?(dir)
|
13
|
+
filename = File.join(dir, "#{name}.rb")
|
14
|
+
if File.exists?(filename)
|
15
|
+
load filename
|
16
|
+
const_name = File.basename(filename).sub(/\.rb$/, '').split('_').map(&:capitalize).join
|
17
|
+
return const_get(const_name)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
raise "Couldn't find feature for #{name}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def load_path
|
24
|
+
@load_path ||= begin
|
25
|
+
lp = ENV['UP_AND_RUNNING_FEATURE_LOAD_PATH'] || []
|
26
|
+
lp << File.expand_path('~/.up_and_running/features')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'ostruct' # For common use
|
2
|
+
|
3
|
+
module UpAndRunning
|
4
|
+
class Compiler
|
5
|
+
class << self
|
6
|
+
def inherited(subclass)
|
7
|
+
@path_of ||= {}
|
8
|
+
@path_of[subclass] = caller.first.sub(/:.*/, '')
|
9
|
+
end
|
10
|
+
|
11
|
+
def path_of(klass)
|
12
|
+
@path_of[klass]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def before_compile; end
|
17
|
+
|
18
|
+
def compile
|
19
|
+
copy_dir if dir
|
20
|
+
compile_erb(@scope) if compile_erb?
|
21
|
+
end
|
22
|
+
|
23
|
+
def after_compile; end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def copy_dir
|
28
|
+
require 'fileutils'
|
29
|
+
FileUtils.cp_r dir.path + '/.', out
|
30
|
+
end
|
31
|
+
|
32
|
+
def compile_erb?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def compile_erb(scope)
|
37
|
+
require 'erb'
|
38
|
+
require 'tilt'
|
39
|
+
require 'fileutils'
|
40
|
+
Dir[File.join(out, '**/*.erb')].each do |erb_template|
|
41
|
+
out = Tilt.new(erb_template).render(scope)
|
42
|
+
File.open(erb_template.sub(/\.erb$/, ''), 'w') {|f| f.write out}
|
43
|
+
FileUtils.rm(erb_template)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def out
|
48
|
+
'.'
|
49
|
+
end
|
50
|
+
|
51
|
+
def dir
|
52
|
+
@dir ||= begin
|
53
|
+
dir = Compiler.path_of(self.class).sub(/\.rb/, '')
|
54
|
+
if Dir.exists?(dir)
|
55
|
+
Dir.new(dir)
|
56
|
+
else
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'up_and_running/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "up_and_running"
|
8
|
+
spec.version = UpAndRunning::VERSION
|
9
|
+
spec.authors = ["Josh Bodah"]
|
10
|
+
spec.email = ["jb3689@yahoo.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{a simple, generic templating system with the goal of helping you rapidly bootstrap new projects}
|
13
|
+
spec.homepage = "https://github.com/jbodah/up_and_running"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency 'tilt'
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: up_and_running
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Bodah
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tilt
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- jb3689@yahoo.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/unr
|
82
|
+
- lib/up_and_running.rb
|
83
|
+
- lib/up_and_running/compiler.rb
|
84
|
+
- lib/up_and_running/version.rb
|
85
|
+
- up_and_running.gemspec
|
86
|
+
homepage: https://github.com/jbodah/up_and_running
|
87
|
+
licenses: []
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.4.8
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: a simple, generic templating system with the goal of helping you rapidly
|
109
|
+
bootstrap new projects
|
110
|
+
test_files: []
|