yop 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 +7 -0
- checksums.yaml.gz.sig +0 -0
- data/bin/yop +50 -0
- data/lib/yop/bootstrap.rb +16 -0
- data/lib/yop/config.rb +43 -0
- data/lib/yop/exceptions.rb +4 -0
- data/lib/yop/home.rb +23 -0
- data/lib/yop/templates.rb +96 -0
- data/lib/yop/version.rb +8 -0
- data/lib/yop.rb +9 -0
- data/tests/tests.rb +32 -0
- data.tar.gz.sig +0 -0
- metadata +175 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f999a4178d91f2c183491af37837a814129fbc96
|
4
|
+
data.tar.gz: b5e0ecf6508e6f5635401878aee77745e28bc236
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4b77f2388b91267826ad6bfe1fa3b6c5a3446be04ed41b417f49e470c224ea9322ccf654a0efda9896d9cc29d8716d4d2e20d8bb844ada5168a6e73ece27cb3a
|
7
|
+
data.tar.gz: afa79f8dd233a9b50177e999e3b54acb37f101cc91b22d3ab1a1ab55086deea802ee8130e8c5e3683f5f5315045631d755bce97ecb41e04bc5ec8d900d8cad53
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data/bin/yop
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
|
4
|
+
# clean interrupt
|
5
|
+
trap("INT") { abort }
|
6
|
+
|
7
|
+
require "trollop"
|
8
|
+
require "yop"
|
9
|
+
|
10
|
+
Yop.init
|
11
|
+
|
12
|
+
opts = Trollop.options do
|
13
|
+
version "yop #{Yop.version}"
|
14
|
+
banner <<-EOS
|
15
|
+
Yop bootstraps your projects with predefined templates.
|
16
|
+
|
17
|
+
Usage:
|
18
|
+
yop [options] <template> <directory>
|
19
|
+
|
20
|
+
* <template> is a template name. Use --templates to list all of them
|
21
|
+
* <directory> is any directory. It’ll be created if it doesn’t exist
|
22
|
+
|
23
|
+
Options:
|
24
|
+
EOS
|
25
|
+
|
26
|
+
opt :templates, "List all available templates", default: false
|
27
|
+
end
|
28
|
+
|
29
|
+
if opts[:templates]
|
30
|
+
require "pathname"
|
31
|
+
|
32
|
+
puts "Templates:"
|
33
|
+
Yop.templates.each do |t|
|
34
|
+
puts "* #{Pathname.new(t).basename}"
|
35
|
+
end
|
36
|
+
exit 0
|
37
|
+
end
|
38
|
+
|
39
|
+
Trollop.educate unless ARGV.length == 2
|
40
|
+
|
41
|
+
template, directory = ARGV
|
42
|
+
|
43
|
+
puts "Applying template '#{template}' on #{directory}..."
|
44
|
+
begin
|
45
|
+
Yop.bootstrap(template, directory)
|
46
|
+
rescue NonExistentTemplate => e
|
47
|
+
puts "ERROR: The template '#{e}' doesn’t exist."
|
48
|
+
exit 1
|
49
|
+
end
|
50
|
+
puts "Done!"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
require_relative "templates"
|
4
|
+
|
5
|
+
module Yop
|
6
|
+
class << self
|
7
|
+
# Bootstrap a project (which will be) located in `directory` with the
|
8
|
+
# template `template`
|
9
|
+
# @param template [String] the template name
|
10
|
+
# @param directory [String] the directory path
|
11
|
+
# @return nil
|
12
|
+
def bootstrap(template, directory)
|
13
|
+
get_template(template).apply directory
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/yop/config.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
require_relative "home"
|
6
|
+
|
7
|
+
module Yop
|
8
|
+
class << self
|
9
|
+
# Get the local Yop config. If no argument is given the whole config is
|
10
|
+
# returned. If one is given, the corresponding value is returned.
|
11
|
+
# @param key [Any] the key to lookup
|
12
|
+
# @return [Any] either the whole config or the value for `key`
|
13
|
+
def config(key = nil)
|
14
|
+
read_config unless @conf
|
15
|
+
|
16
|
+
if !key.nil?
|
17
|
+
@conf[key]
|
18
|
+
else
|
19
|
+
@conf
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# Set variables in the local Yop config.
|
24
|
+
# @param opts [Hash] an hash which will be merged into the local config
|
25
|
+
# @return nil
|
26
|
+
def config!(opts = {})
|
27
|
+
@conf.update(opts)
|
28
|
+
save_config
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def read_config
|
34
|
+
@conf = YAML.load_file(home("config.yml")) || {}
|
35
|
+
end
|
36
|
+
|
37
|
+
def save_config
|
38
|
+
File.open(home("config.yml"), "w") do |f|
|
39
|
+
f.write YAML.dump(@conf)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/yop/home.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
module Yop
|
6
|
+
class << self
|
7
|
+
# Return the local Yop directory location. If an argument is given, it
|
8
|
+
# assumes it's a Yop subcomponent and returns its location.
|
9
|
+
# @param subcomponent [String] the subcomponent to look for
|
10
|
+
# @return [String] the path to the local Yop directory or its subcomponent
|
11
|
+
def home(subcomponent = "")
|
12
|
+
File.expand_path("~/.yop/#{subcomponent}")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Initialize Yop's local directory
|
16
|
+
# @return nil
|
17
|
+
def init
|
18
|
+
FileUtils.mkdir_p home
|
19
|
+
FileUtils.mkdir_p home("templates")
|
20
|
+
FileUtils.touch home("config.yml")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
# -*- coding: UTF-8 -*-
|
2
|
+
|
3
|
+
require "fileutils"
|
4
|
+
|
5
|
+
require_relative "home"
|
6
|
+
require_relative "config"
|
7
|
+
require_relative "exceptions"
|
8
|
+
|
9
|
+
module Yop
|
10
|
+
class << self
|
11
|
+
# @return [Array] all the available templates
|
12
|
+
def templates
|
13
|
+
Dir["#{Yop.home("templates")}/*"]
|
14
|
+
end
|
15
|
+
|
16
|
+
# Retrieve a template from its name, or raise a `NonExistentTemplate`
|
17
|
+
# exception if it doesn't exist
|
18
|
+
# @param name [String] the template name
|
19
|
+
# @return [Yop::Template]
|
20
|
+
def get_template(name)
|
21
|
+
dirs = Dir["#{Yop.home("templates")}/#{name}"]
|
22
|
+
fail NonExistentTemplate, name if dirs.empty?
|
23
|
+
Template.new(dirs.first, config(:vars) || {})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# A Yop Template, which consists of a base directory and an hash of variables
|
28
|
+
class Template
|
29
|
+
include FileUtils
|
30
|
+
|
31
|
+
# Create a new template from a base directory
|
32
|
+
# @param base_directory [String] a path to an existing directory which will
|
33
|
+
# be used as a source when this template
|
34
|
+
# will be applied
|
35
|
+
# @param vars [Hash]
|
36
|
+
def initialize(base_directory, vars = {})
|
37
|
+
@base = base_directory
|
38
|
+
@vars = vars
|
39
|
+
end
|
40
|
+
|
41
|
+
# Apply the template on a directory. It creates it if it doesn't exist,
|
42
|
+
# then recursively copies itself in it
|
43
|
+
# @param directory [String] the directory in which to copy
|
44
|
+
# @return nil
|
45
|
+
def apply(directory)
|
46
|
+
mkdir_p directory
|
47
|
+
|
48
|
+
# get relative paths
|
49
|
+
sources = []
|
50
|
+
cd(@base) { sources = Dir["**/*", "**/.*"] }
|
51
|
+
|
52
|
+
cd directory do
|
53
|
+
sources.each do |path|
|
54
|
+
next if skip? path
|
55
|
+
|
56
|
+
source = "#{@base}/#{path}"
|
57
|
+
|
58
|
+
if File.directory? source
|
59
|
+
mkdir_p path
|
60
|
+
elsif File.file? source
|
61
|
+
File.open(path, "w") do |f|
|
62
|
+
content = replace_vars source
|
63
|
+
f.write(content)
|
64
|
+
end
|
65
|
+
else
|
66
|
+
puts "Warning: unsupported file: #{source}"
|
67
|
+
next
|
68
|
+
end
|
69
|
+
mirror_perms source, path
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def ignore_extension?(path)
|
77
|
+
%w[.swp .swo .pyc .class].any? { |e| path.end_with?(e) }
|
78
|
+
end
|
79
|
+
|
80
|
+
def skip?(path)
|
81
|
+
return true if ignore_extension? path
|
82
|
+
|
83
|
+
[/\.git/, /.~$/, /__pycache__/].any? { |reg| path =~ reg }
|
84
|
+
end
|
85
|
+
|
86
|
+
def replace_vars(source)
|
87
|
+
# TODO
|
88
|
+
File.read(source)
|
89
|
+
end
|
90
|
+
|
91
|
+
def mirror_perms(source, target)
|
92
|
+
mode = File.new(source).stat.mode
|
93
|
+
File.chmod(mode, target)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/yop/version.rb
ADDED
data/lib/yop.rb
ADDED
data/tests/tests.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# -*- coding: UTF-8 -*-
|
3
|
+
|
4
|
+
require "coveralls"
|
5
|
+
Coveralls.wear!
|
6
|
+
|
7
|
+
require "test/unit"
|
8
|
+
require "simplecov"
|
9
|
+
|
10
|
+
test_dir = File.expand_path(File.dirname(__FILE__))
|
11
|
+
|
12
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
13
|
+
SimpleCov.start { add_filter "/tests/" }
|
14
|
+
|
15
|
+
require "yop"
|
16
|
+
|
17
|
+
for t in Dir[File.join(test_dir, "*_tests.rb")]
|
18
|
+
require t
|
19
|
+
end
|
20
|
+
|
21
|
+
class YopTests < Test::Unit::TestCase
|
22
|
+
|
23
|
+
# == #version == #
|
24
|
+
|
25
|
+
def test_version
|
26
|
+
assert(Yop.version =~ /^\d+\.\d+\.\d+/)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
exit Test::Unit::AutoRunner.run
|
data.tar.gz.sig
ADDED
Binary file
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: yop
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Baptiste Fontaine
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDaDCCAlCgAwIBAgIBATANBgkqhkiG9w0BAQUFADA9MRAwDgYDVQQDDAdiYXRp
|
14
|
+
Zm9uMRUwEwYKCZImiZPyLGQBGRYFeWFob28xEjAQBgoJkiaJk/IsZAEZFgJmcjAe
|
15
|
+
Fw0xNDA4MjQxMTM5NTJaFw0xNTA4MjQxMTM5NTJaMD0xEDAOBgNVBAMMB2JhdGlm
|
16
|
+
b24xFTATBgoJkiaJk/IsZAEZFgV5YWhvbzESMBAGCgmSJomT8ixkARkWAmZyMIIB
|
17
|
+
IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn3uOgWl+FwXIjDdCay28i6cK
|
18
|
+
FxHWhHoS/mH9pkXzSGVctEKP2fulie6MkIvrLCP5M6TpByeaBjcJjZPadrou1FIc
|
19
|
+
Yc/O14jYjaKTqfMxpzgNfGzDdBgBo0QZ9rcHjORetdIZdUSDaZjPtI1aGS6eBMsh
|
20
|
+
W2X6GxL4UQ1kH0Lyg7iPYAH5RHnD3+G+S28iOPFfRLFzm4fwJp1k7URiiSyOHTDp
|
21
|
+
B0ZehKKrW/ibCaRMYp2VoCamcim4de1VA6CTOaYSShueqThE18n1HM6aprihziyM
|
22
|
+
04yIpo80/unO6JxlsUFdBjsb5d7oJSqPJ6/OfcFnyXa/VRm+Ed9d6PTwZvL7YwID
|
23
|
+
AQABo3MwcTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUWyH3xMx1
|
24
|
+
8I5NLncgNEC0ZlDRKegwGwYDVR0RBBQwEoEQYmF0aWZvbkB5YWhvby5mcjAbBgNV
|
25
|
+
HRIEFDASgRBiYXRpZm9uQHlhaG9vLmZyMA0GCSqGSIb3DQEBBQUAA4IBAQAaTVya
|
26
|
+
CGgojxBwUoadCCIsFheGsXvSFhikkXYNXy0VxEYr8BaTfGwzYh9c9T5N+Y5Mu5MW
|
27
|
+
WegqwIwRhIu6Rg7huqJ7TK50pVDF0yrZcsxvWjOfd3clblBHjKGQx5Mbu7LVNGKE
|
28
|
+
+QNdTAwYVTAA8wXHpxk200cHb9xz4e9ANpb4lonGuPz8jKmb/A7Z1M5QD6zStG8l
|
29
|
+
sTlVAhA/LZiC9gL9LtW8Iq7o7xRFhxNPKWHu6JVThH9i16eli+JignOJbGna7C40
|
30
|
+
QnOQb8zHyNL+gq2m/mnZGrSehx+6AujokjOfHbmivYMfDATOQQx0eIBI18IhacZm
|
31
|
+
42WxhhIV2bwDtd77
|
32
|
+
-----END CERTIFICATE-----
|
33
|
+
date: 2015-01-31 00:00:00.000000000 Z
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: trollop
|
37
|
+
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2.1'
|
42
|
+
type: :runtime
|
43
|
+
prerelease: false
|
44
|
+
version_requirements: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '2.1'
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: simplecov
|
51
|
+
requirement: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0.7'
|
56
|
+
type: :development
|
57
|
+
prerelease: false
|
58
|
+
version_requirements: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.7'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: rake
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '10.1'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '10.1'
|
77
|
+
- !ruby/object:Gem::Dependency
|
78
|
+
name: test-unit
|
79
|
+
requirement: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '2.5'
|
84
|
+
type: :development
|
85
|
+
prerelease: false
|
86
|
+
version_requirements: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '2.5'
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: fakeweb
|
93
|
+
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.3'
|
98
|
+
type: :development
|
99
|
+
prerelease: false
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.3'
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: coveralls
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.7'
|
112
|
+
type: :development
|
113
|
+
prerelease: false
|
114
|
+
version_requirements: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0.7'
|
119
|
+
- !ruby/object:Gem::Dependency
|
120
|
+
name: rubocop
|
121
|
+
requirement: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0.28'
|
126
|
+
type: :development
|
127
|
+
prerelease: false
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0.28'
|
133
|
+
description: Yop bootstraps your projects from pre-defined templates
|
134
|
+
email: b@ptistefontaine.fr
|
135
|
+
executables:
|
136
|
+
- yop
|
137
|
+
extensions: []
|
138
|
+
extra_rdoc_files: []
|
139
|
+
files:
|
140
|
+
- bin/yop
|
141
|
+
- lib/yop.rb
|
142
|
+
- lib/yop/bootstrap.rb
|
143
|
+
- lib/yop/config.rb
|
144
|
+
- lib/yop/exceptions.rb
|
145
|
+
- lib/yop/home.rb
|
146
|
+
- lib/yop/templates.rb
|
147
|
+
- lib/yop/version.rb
|
148
|
+
- tests/tests.rb
|
149
|
+
homepage: https://github.com/bfontaine/Yop
|
150
|
+
licenses:
|
151
|
+
- MIT
|
152
|
+
metadata: {}
|
153
|
+
post_install_message:
|
154
|
+
rdoc_options: []
|
155
|
+
require_paths:
|
156
|
+
- lib
|
157
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
requirements: []
|
168
|
+
rubyforge_project:
|
169
|
+
rubygems_version: 2.4.4
|
170
|
+
signing_key:
|
171
|
+
specification_version: 4
|
172
|
+
summary: Templates-based projects manager
|
173
|
+
test_files:
|
174
|
+
- tests/tests.rb
|
175
|
+
has_rdoc:
|
metadata.gz.sig
ADDED
Binary file
|