llama 0.2.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 +8 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +39 -0
- data/README.md +24 -0
- data/Rakefile +6 -0
- data/bin/console +7 -0
- data/bin/llama +5 -0
- data/lib/llama.rb +13 -0
- data/lib/llama/cli.rb +20 -0
- data/lib/llama/processors/abstract_processor.rb +13 -0
- data/lib/llama/processors/dir_processor.rb +19 -0
- data/lib/llama/processors/file_processor.rb +18 -0
- data/lib/llama/project.rb +18 -0
- data/lib/llama/template.rb +31 -0
- data/lib/llama/version.rb +3 -0
- data/llama.gemspec +25 -0
- metadata +131 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 31bc627fb30fd35fe20d1a6edfc40cdcd2cb822a
|
|
4
|
+
data.tar.gz: bef7cc48c344488d40468b65989f513c8b52ce84
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8e7b438c00092ea518aab43d769dd4a7c33d48f263e2c67654f25ec2ef9386a1ae8cd4a03a3403a594cfaccf9c35432a058b6196aa6de67fdb500c816306fa43
|
|
7
|
+
data.tar.gz: '099f6a5233aab80e42e5a7a34afbd65149b264fb95a048294fedcc2adf85a18c290ddef32c4d1a4ef55fe1ffb6e8a99acda4f9927a42067c6d9e1ef937b12c4a'
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
llama (0.3.0)
|
|
5
|
+
colorize
|
|
6
|
+
thor
|
|
7
|
+
|
|
8
|
+
GEM
|
|
9
|
+
remote: https://rubygems.org/
|
|
10
|
+
specs:
|
|
11
|
+
colorize (0.8.1)
|
|
12
|
+
diff-lcs (1.3)
|
|
13
|
+
rake (10.5.0)
|
|
14
|
+
rspec (3.6.0)
|
|
15
|
+
rspec-core (~> 3.6.0)
|
|
16
|
+
rspec-expectations (~> 3.6.0)
|
|
17
|
+
rspec-mocks (~> 3.6.0)
|
|
18
|
+
rspec-core (3.6.0)
|
|
19
|
+
rspec-support (~> 3.6.0)
|
|
20
|
+
rspec-expectations (3.6.0)
|
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
22
|
+
rspec-support (~> 3.6.0)
|
|
23
|
+
rspec-mocks (3.6.0)
|
|
24
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
25
|
+
rspec-support (~> 3.6.0)
|
|
26
|
+
rspec-support (3.6.0)
|
|
27
|
+
thor (0.20.0)
|
|
28
|
+
|
|
29
|
+
PLATFORMS
|
|
30
|
+
ruby
|
|
31
|
+
|
|
32
|
+
DEPENDENCIES
|
|
33
|
+
bundler (~> 1.13)
|
|
34
|
+
llama!
|
|
35
|
+
rake (~> 10.0)
|
|
36
|
+
rspec (~> 3.0)
|
|
37
|
+
|
|
38
|
+
BUNDLED WITH
|
|
39
|
+
1.13.7
|
data/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Llama
|
|
2
|
+
Project scaffold generator.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
Add this line to your application's Gemfile:
|
|
7
|
+
|
|
8
|
+
```ruby
|
|
9
|
+
gem 'llama'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
And then execute:
|
|
13
|
+
|
|
14
|
+
$ bundle
|
|
15
|
+
|
|
16
|
+
Or install it yourself as:
|
|
17
|
+
|
|
18
|
+
$ gem install llama
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```shell
|
|
23
|
+
$ llama -t twinfacer/template_test new_fancy_app
|
|
24
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/llama
ADDED
data/lib/llama.rb
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'colorize'
|
|
2
|
+
require 'erb'
|
|
3
|
+
|
|
4
|
+
require 'llama/version'
|
|
5
|
+
require 'llama/processors/abstract_processor'
|
|
6
|
+
require 'llama/processors/file_processor'
|
|
7
|
+
require 'llama/processors/dir_processor'
|
|
8
|
+
|
|
9
|
+
require 'llama/project'
|
|
10
|
+
require 'llama/template'
|
|
11
|
+
|
|
12
|
+
module Llama
|
|
13
|
+
end
|
data/lib/llama/cli.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require 'thor'
|
|
2
|
+
require 'llama'
|
|
3
|
+
|
|
4
|
+
module Llama
|
|
5
|
+
class CLI < Thor
|
|
6
|
+
desc 'new PROJECT_NAME', 'Creates new scaffold.'
|
|
7
|
+
method_option :template, aliases: '-t', required: true, desc: 'Template repo to use as base for scaffolding'
|
|
8
|
+
method_option :force, aliases: '-f', type: :boolean, default: false, desc: 'Force overwrite project directory if one exist.'
|
|
9
|
+
def new(name)
|
|
10
|
+
project = Llama::Project.new(name, options.template)
|
|
11
|
+
if Dir.exist?(project.path) && !options.force
|
|
12
|
+
puts "#{project.path} already exists! Use --force to overwrite".red
|
|
13
|
+
else
|
|
14
|
+
`rm -rf #{project.path}`
|
|
15
|
+
Dir.mkdir(project.path)
|
|
16
|
+
project.write_template!
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
class Llama::AbstractProcessor
|
|
2
|
+
attr_accessor :source, :target, :project_name
|
|
3
|
+
|
|
4
|
+
def initialize(source, target, project_name)
|
|
5
|
+
@source = source
|
|
6
|
+
@target = target
|
|
7
|
+
@project_name = project_name
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def process!
|
|
11
|
+
raise NonImplementedError, 'subclasses must implement #process !'
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class Llama::DirProcessor < Llama::AbstractProcessor
|
|
2
|
+
def process!
|
|
3
|
+
content.sort.each do |name|
|
|
4
|
+
entry_path = File.join(source, name)
|
|
5
|
+
target_path = File.join(target, name)
|
|
6
|
+
if File.directory?(entry_path)
|
|
7
|
+
Dir.mkdir(target_path)
|
|
8
|
+
Llama::DirProcessor.new(entry_path, target_path, project_name).process!
|
|
9
|
+
else
|
|
10
|
+
Llama::FileProcessor.new(entry_path, target_path, project_name).process!
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def content
|
|
16
|
+
Dir.entries(source) - ['.', '..', '.git']
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'erb'
|
|
2
|
+
|
|
3
|
+
class Llama::FileProcessor < Llama::AbstractProcessor
|
|
4
|
+
def process!
|
|
5
|
+
target_path = target.gsub('@PROJECT_NAME@', project_name)
|
|
6
|
+
local_path = target_path.gsub("#{Dir.pwd}/", '')
|
|
7
|
+
print " => [creating] #{local_path}\n".green
|
|
8
|
+
File.open(target_path, 'w+') do |file|
|
|
9
|
+
file.write(process_content(File.read(source)))
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def process_content(str)
|
|
15
|
+
app_name = project_name.split('_').map(&:capitalize).join('')
|
|
16
|
+
ERB.new(str).result(binding)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Llama
|
|
2
|
+
class Project
|
|
3
|
+
attr_accessor :name, :template
|
|
4
|
+
|
|
5
|
+
def initialize(name, template_name)
|
|
6
|
+
@name = name
|
|
7
|
+
@template = Llama::Template.new(template_name)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def write_template!
|
|
11
|
+
template.render!(path, name)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def path
|
|
15
|
+
File.join(Dir.pwd, name)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Llama
|
|
2
|
+
class Template
|
|
3
|
+
attr_accessor :template_name
|
|
4
|
+
|
|
5
|
+
def initialize(template_name)
|
|
6
|
+
@template_name = template_name
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def render!(output_path, project_name)
|
|
10
|
+
fetch_template
|
|
11
|
+
Llama::DirProcessor.new(template_path, output_path, project_name).process!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def fetch_template
|
|
17
|
+
`rm -rf #{template_path}`
|
|
18
|
+
print " => [fetching template] #{template_name}\n".green
|
|
19
|
+
`git clone #{repo_path} #{template_path} 2>&1 1>/dev/null`
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def repo_path
|
|
23
|
+
"git@github.com:#{template_name}.git"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def template_path
|
|
27
|
+
File.expand_path("~/.llama/templates/#{template_name.split('/').last}")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
data/llama.gemspec
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require 'llama/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'llama'
|
|
7
|
+
spec.version = Llama::VERSION
|
|
8
|
+
spec.authors = ['Sergey Ivannikov']
|
|
9
|
+
spec.email = ['twinfacer@gmail.com']
|
|
10
|
+
spec.summary = %q{Llama will help you create scaffold project from git repo}
|
|
11
|
+
spec.description = %q{Llama will help you create scaffold project from git repo}
|
|
12
|
+
spec.homepage = 'https://github.com/twinfacer/llama'
|
|
13
|
+
|
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
15
|
+
f.match(%r{^(test|spec|features)/})
|
|
16
|
+
end
|
|
17
|
+
spec.executables << 'llama'
|
|
18
|
+
|
|
19
|
+
spec.add_dependency 'thor'
|
|
20
|
+
spec.add_dependency 'colorize'
|
|
21
|
+
|
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.13'
|
|
23
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
|
24
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
25
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: llama
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sergey Ivannikov
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-10-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: thor
|
|
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: colorize
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
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: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.13'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.13'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '10.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '10.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rspec
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '3.0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '3.0'
|
|
83
|
+
description: Llama will help you create scaffold project from git repo
|
|
84
|
+
email:
|
|
85
|
+
- twinfacer@gmail.com
|
|
86
|
+
executables:
|
|
87
|
+
- llama
|
|
88
|
+
extensions: []
|
|
89
|
+
extra_rdoc_files: []
|
|
90
|
+
files:
|
|
91
|
+
- ".gitignore"
|
|
92
|
+
- ".rspec"
|
|
93
|
+
- Gemfile
|
|
94
|
+
- Gemfile.lock
|
|
95
|
+
- README.md
|
|
96
|
+
- Rakefile
|
|
97
|
+
- bin/console
|
|
98
|
+
- bin/llama
|
|
99
|
+
- lib/llama.rb
|
|
100
|
+
- lib/llama/cli.rb
|
|
101
|
+
- lib/llama/processors/abstract_processor.rb
|
|
102
|
+
- lib/llama/processors/dir_processor.rb
|
|
103
|
+
- lib/llama/processors/file_processor.rb
|
|
104
|
+
- lib/llama/project.rb
|
|
105
|
+
- lib/llama/template.rb
|
|
106
|
+
- lib/llama/version.rb
|
|
107
|
+
- llama.gemspec
|
|
108
|
+
homepage: https://github.com/twinfacer/llama
|
|
109
|
+
licenses: []
|
|
110
|
+
metadata: {}
|
|
111
|
+
post_install_message:
|
|
112
|
+
rdoc_options: []
|
|
113
|
+
require_paths:
|
|
114
|
+
- lib
|
|
115
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
116
|
+
requirements:
|
|
117
|
+
- - ">="
|
|
118
|
+
- !ruby/object:Gem::Version
|
|
119
|
+
version: '0'
|
|
120
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
requirements: []
|
|
126
|
+
rubyforge_project:
|
|
127
|
+
rubygems_version: 2.6.8
|
|
128
|
+
signing_key:
|
|
129
|
+
specification_version: 4
|
|
130
|
+
summary: Llama will help you create scaffold project from git repo
|
|
131
|
+
test_files: []
|