laadur 1.0.1 → 1.3.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 +4 -4
- data/Gemfile +1 -2
- data/README.md +113 -0
- data/Rakefile +0 -4
- data/TODO +4 -0
- data/bin/laadur +1 -1
- data/laadur.gemspec +2 -2
- data/lib/laadur.rb +101 -117
- data/lib/laadur/version.rb +1 -3
- data/lib/version +1 -0
- metadata +6 -6
- data/README +0 -3
- data/laadur.txt +0 -5
- data/version +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5d107aebb2b1247f7ff2874b4e5c2e52ca52e18d
|
|
4
|
+
data.tar.gz: aae0f83d091ec84bd389d13187f687d79db26023
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c98773fe172829fa16ee54b7c6da17d8412d7801eeec71dbaeb0a5b42770193a47cbb6920c766b8cac8562c7b445e513ea5cdea44e64f9f1b2861aec24c1dd20
|
|
7
|
+
data.tar.gz: 70ef15ad24e2d04ba9746a4e1d8065e0682e7ef3311664c74cf71b81dda0d2c97dc633f4917cbe1c00b0a94e05262571be12c924a2bc57617f982e3ae370f5d8
|
data/Gemfile
CHANGED
data/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# laadur (CLI)
|
|
2
|
+
|
|
3
|
+
## Intro
|
|
4
|
+
When you are doing routine work, you may need a tool which will simplify your workflow.
|
|
5
|
+
So became **laadur**.
|
|
6
|
+
|
|
7
|
+
Laadur creates a folder in your homepath (/Users/{user}/.laadur) and keeps there your templates.
|
|
8
|
+
**Now it works via CLI. So, it can't be required in your project or smth else. Yet.**
|
|
9
|
+
|
|
10
|
+
## Using
|
|
11
|
+
[Installation](#installation)
|
|
12
|
+
[Managing](#managing)
|
|
13
|
+
[Search](#search)
|
|
14
|
+
[Targetting](#targetting)
|
|
15
|
+
[Multiloading](#multiloading)
|
|
16
|
+
[Debugging](#debugging)
|
|
17
|
+
|
|
18
|
+
#### Installation
|
|
19
|
+
```sh
|
|
20
|
+
gem install laadur
|
|
21
|
+
```
|
|
22
|
+
So, now you are ready.
|
|
23
|
+
To create your first template, you can use
|
|
24
|
+
```sh
|
|
25
|
+
laadur -o
|
|
26
|
+
```
|
|
27
|
+
which will open your **laadur** folder with finder.
|
|
28
|
+
|
|
29
|
+
Simply create several folders there with some content.
|
|
30
|
+
For example, folders like:
|
|
31
|
+

|
|
32
|
+
Here you go.
|
|
33
|
+
Now you can get this templates from wherever you are.
|
|
34
|
+
|
|
35
|
+
Simply use:
|
|
36
|
+
```sh
|
|
37
|
+
[ ~ ]: cd blog
|
|
38
|
+
[ ~/blog ]: laadur -l bootstrap
|
|
39
|
+
```
|
|
40
|
+
It will load the content of `bootstrap` folder to your present working directory (pwd).
|
|
41
|
+
|
|
42
|
+
#### Managing
|
|
43
|
+
You can remotely get access to some laadur data.
|
|
44
|
+
Get laadur folder path: `laadur --folder`.
|
|
45
|
+
Get list of all templates: `laadur --list`.
|
|
46
|
+
And remove certain template: `laadur -r bootstrap`.
|
|
47
|
+
|
|
48
|
+
#### Search
|
|
49
|
+
Laadur can load several templates, using regular expression.
|
|
50
|
+
```sh
|
|
51
|
+
[ ~/blog ]: laadur --list
|
|
52
|
+
There are 4 templates:
|
|
53
|
+
├ jquery
|
|
54
|
+
├ jquery-mobile
|
|
55
|
+
├ sass-mixins
|
|
56
|
+
└ sass-mixins-mobile
|
|
57
|
+
[ ~/blog ]: laadur -s *-mobile
|
|
58
|
+
jquery-mobile loaded!
|
|
59
|
+
sass-mixins-mobile loaded!
|
|
60
|
+
```
|
|
61
|
+
You can also load all templates using `--all`.
|
|
62
|
+
|
|
63
|
+
#### Targetting
|
|
64
|
+
By default laadur loads files to your pwd.
|
|
65
|
+
If you wanna change destination folder, use `-t`/`--target`.
|
|
66
|
+
##### _In version 1.0 you should specify **target** before specifying template!_
|
|
67
|
+
Look:
|
|
68
|
+
```sh
|
|
69
|
+
[ ~ ]: cd blog
|
|
70
|
+
[ ~/blog ]: laadur -t assets -l bootstrap
|
|
71
|
+
```
|
|
72
|
+
Laadur will copy the content from `.laadur/bootstrap` and paste it to the `~/blog/assets` folder. If folder doesn't exist, it will create it for you.
|
|
73
|
+
If you need to choose destination folder not from pwd, you can set `--home` option, and laadur will search target folder from your home directory.
|
|
74
|
+
For example:
|
|
75
|
+
```sh
|
|
76
|
+
[ ~/blog/assets/img/png/16x16 ]: laadur --home -t blog/assets -l bootstrap
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Multiloading
|
|
80
|
+
Multiloading is disabled in the actual version, but you still can use it but in a little different way.
|
|
81
|
+
```sh
|
|
82
|
+
[ ~/blog ]: laadur -l bootstrap/css -l bootstrap/js
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### Debugging
|
|
86
|
+
If you are not sure, you can first check, where your files will be loaded to:
|
|
87
|
+
```sh
|
|
88
|
+
[ ~/blog ]: laadur --home -t another/path --prt
|
|
89
|
+
```
|
|
90
|
+
It will acts as you're going to copy.
|
|
91
|
+
But `--prt` option will simply print destination path instead of copying files.
|
|
92
|
+
### Options
|
|
93
|
+
```
|
|
94
|
+
-v, --version show version
|
|
95
|
+
-h, --help help window
|
|
96
|
+
--docs open github documentation page
|
|
97
|
+
|
|
98
|
+
-o, --open open laadur folder with Finder.app
|
|
99
|
+
--list list all templates
|
|
100
|
+
--folder print folder path
|
|
101
|
+
|
|
102
|
+
-t, --target <path> specify target folder for copying template files (also see --home)
|
|
103
|
+
--home use home folder as root for target option (pwd by default)
|
|
104
|
+
--pwd return back home as pwd (useful with multiloading)
|
|
105
|
+
--prt print target path (where files will be copied)
|
|
106
|
+
|
|
107
|
+
-s, --search <expr> search templates with regex
|
|
108
|
+
--all load all templates
|
|
109
|
+
|
|
110
|
+
-l, --load <template> load template from repository
|
|
111
|
+
you may not specify this flag
|
|
112
|
+
-r, --remove <template> remove a certain template
|
|
113
|
+
```
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
require 'bundler/gem_tasks'
|
|
2
|
-
require 'version'
|
|
3
2
|
|
|
4
3
|
task :deploy, :arg1 do |t, args|
|
|
5
4
|
`rake install`
|
|
6
5
|
`git add -A`
|
|
7
|
-
v = File.read("version").to_version
|
|
8
|
-
v.bump!
|
|
9
|
-
File.open('version', 'w') { |file| file.write(v.to_s) }
|
|
10
6
|
`git commit -m '#{args.arg1}'`
|
|
11
7
|
`git push`
|
|
12
8
|
end
|
data/TODO
ADDED
data/bin/laadur
CHANGED
data/laadur.gemspec
CHANGED
|
@@ -6,10 +6,10 @@ include Laadur
|
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = "laadur"
|
|
9
|
-
spec.version = Laadur
|
|
9
|
+
spec.version = Laadur::VERSION
|
|
10
10
|
spec.authors = ["Nikita Nikitin"]
|
|
11
11
|
spec.email = ["berozzy@gmail.com"]
|
|
12
|
-
spec.description = "
|
|
12
|
+
spec.description = "Template manager with CLI"
|
|
13
13
|
spec.summary = ""
|
|
14
14
|
spec.homepage = "http://github.com/rozzy/laadur"
|
|
15
15
|
spec.license = "MIT"
|
data/lib/laadur.rb
CHANGED
|
@@ -12,141 +12,95 @@ module Laadur
|
|
|
12
12
|
@@workpath = Dir.pwd
|
|
13
13
|
puts "Your laadur folder is empty.\n\n" if Dir[File.join(@@home, '**', '*')].count { |dir| File.directory?(dir) } == 0
|
|
14
14
|
begin
|
|
15
|
-
|
|
16
|
-
@use_home = false
|
|
17
|
-
@
|
|
18
|
-
@used_target = false
|
|
19
|
-
@target = @@workpath
|
|
20
|
-
options = {}
|
|
21
|
-
loaded = []
|
|
22
|
-
reserved = ['-s', '--search', '--all', '-v', '--version', '-h', '--help', '--docs', '-o', '--open', '-l', '--list', '--folder', '-t', '--target', '--home', '--pwd', '--prt', '-r', '--remove']
|
|
15
|
+
@@multiloading = false
|
|
16
|
+
@error_flag || @use_home = @parsed_tmpl = @used_target = false
|
|
17
|
+
@target, options, loaded = @@workpath, {}, []
|
|
23
18
|
begin
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
parse_options
|
|
20
|
+
rescue => error
|
|
21
|
+
puts error.to_s.slice(0,1).capitalize + error.to_s.slice(1..-1)
|
|
22
|
+
end
|
|
23
|
+
rescue OptionParser::InvalidOption => error
|
|
24
|
+
puts error.to_s
|
|
25
|
+
@error_flag = true
|
|
26
|
+
retry
|
|
27
|
+
end
|
|
28
|
+
end
|
|
34
29
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
def parse_options
|
|
31
|
+
OptionParser.new do |opts|
|
|
32
|
+
opts.banner = "Usage: laadur [options]"
|
|
33
|
+
opts.on("-v", "--version", "print gem version") do puts Laadur::VERSION end
|
|
34
|
+
opts.on("-h", "--help", "help window") do puts opts end
|
|
35
|
+
opts.on("--docs", "open github documentation page") do `open https://github.com/rozzy/laadur` end
|
|
38
36
|
|
|
39
37
|
opts.separator ""
|
|
40
38
|
|
|
41
|
-
opts.on("-o", "--open", "open laadur folder with Finder.app") do
|
|
42
|
-
|
|
43
|
-
end
|
|
39
|
+
opts.on("-o", "--open", "open laadur folder with Finder.app") do `open #{@@home}` end
|
|
40
|
+
opts.on("-l", "--list", "list all templates") do list end
|
|
41
|
+
opts.on("--folder", "print folder path") do puts @@home end
|
|
44
42
|
|
|
45
|
-
opts.
|
|
46
|
-
files = Dir.glob("#{@@home}/*").select {|f| File.directory? f}
|
|
47
|
-
if files.size > 0
|
|
48
|
-
puts "There #{files.size == 1 ? 'is' : 'are'} #{files.size} #{files.size == 1 ? 'template' : 'templates'}:"
|
|
49
|
-
last = Pathname.new(files.last).basename
|
|
50
|
-
files.pop
|
|
51
|
-
files.each do |file|
|
|
52
|
-
puts "├ #{b Pathname.new(file).basename}"
|
|
53
|
-
end
|
|
54
|
-
puts "└ #{b last}"
|
|
55
|
-
else
|
|
56
|
-
puts "Your laadur folder is empty!"
|
|
57
|
-
end
|
|
58
|
-
end
|
|
43
|
+
opts.separator ""
|
|
59
44
|
|
|
60
|
-
opts.on("--
|
|
61
|
-
|
|
62
|
-
end
|
|
45
|
+
opts.on("-t", "--target <path>", "specify target folder for copying template files (also see --home)") do |target| set_target target end
|
|
46
|
+
opts.on("--home", "use home folder as root for target option (pwd by default)") do use_home end
|
|
47
|
+
opts.on("--pwd", "return back home as pwd (useful with multiloading)") do return_pwd end
|
|
48
|
+
opts.on("--prt", "print target path (where files will be copied)") do puts "Files will be copied to: #{@target}" end
|
|
63
49
|
|
|
64
50
|
opts.separator ""
|
|
65
51
|
|
|
66
|
-
opts.on("-
|
|
67
|
-
|
|
68
|
-
@target = @use_home ? "#{Dir.home}/#{target}" : "#{@@workpath}/#{target}"
|
|
69
|
-
begin
|
|
70
|
-
puts "Trying to set target to #{@target}, but there is no such folder."
|
|
71
|
-
Dir.mkdir @target
|
|
72
|
-
puts "So #{@target} was created."
|
|
73
|
-
@used_target = true
|
|
74
|
-
end if not File.directory? @target
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
opts.on("--home", "use home folder as root for target option (pwd by default)") do
|
|
78
|
-
raise "Next time use --home before specifying the target." if @used_target
|
|
79
|
-
puts "Using #{Dir.home}/ as root."
|
|
80
|
-
@target = Dir.home
|
|
81
|
-
@use_home = true
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
opts.on("--pwd", "return back home as pwd (useful with multiloading)") do
|
|
85
|
-
puts "Using #{@@workpath}/ as root."
|
|
86
|
-
@target = @@workpath
|
|
87
|
-
@use_home = true
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
opts.on("--prt", "print target path (where files will be copied)") do
|
|
91
|
-
puts "Files will be copied to: #{@target}"
|
|
92
|
-
end
|
|
52
|
+
opts.on("-s", "--search <expr>", "search templates with regex") do |expr| load_regex expr end
|
|
53
|
+
opts.on("--all", "load all templates") do load_regex "*" end
|
|
93
54
|
|
|
94
55
|
opts.separator ""
|
|
95
56
|
|
|
96
|
-
opts.on("-
|
|
97
|
-
|
|
98
|
-
end
|
|
57
|
+
opts.on("load template from repository", "-l", "--load <template>", "you may not specify this flag") do |template| self.parse_template template end
|
|
58
|
+
opts.on("-r", "--remove <template>", "remove a certain template") do |template| self.remove_template template end
|
|
99
59
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
60
|
+
print_message if ARGV.size == 0
|
|
61
|
+
|
|
62
|
+
parse_multiple_args if ARGV.size > 1 and @@multiloading
|
|
103
63
|
|
|
104
|
-
opts.
|
|
64
|
+
puts opts if @error_flag or ARGV.size == 0
|
|
65
|
+
end.parse!
|
|
66
|
+
end
|
|
105
67
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
68
|
+
def set_target target
|
|
69
|
+
raise "Next time use --target before specifying the template." if @parsed_tmpl
|
|
70
|
+
@target = @use_home ? "#{Dir.home}/#{target}" : "#{@@workpath}/#{target}"
|
|
71
|
+
begin
|
|
72
|
+
puts "Trying to set target to #{@target}, but there is no such folder."
|
|
73
|
+
Dir.mkdir @target
|
|
74
|
+
puts "So #{@target} was created."
|
|
75
|
+
@used_target = true
|
|
76
|
+
end if not File.directory? @target
|
|
77
|
+
end
|
|
109
78
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
File.foreach('laadur.txt') do |line|
|
|
116
|
-
match = line.match /\#\{(.*)\}/
|
|
117
|
-
line = line.gsub /\#\{(.*)\}/, instance_eval("#{match[1]}") if match
|
|
118
|
-
puts line
|
|
119
|
-
end
|
|
120
|
-
puts ""
|
|
121
|
-
end
|
|
79
|
+
def return_pwd
|
|
80
|
+
puts "Using #{@@workpath}/ as root."
|
|
81
|
+
@target = @@workpath
|
|
82
|
+
@use_home = true
|
|
83
|
+
end
|
|
122
84
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
# puts ""
|
|
130
|
-
# puts opts
|
|
131
|
-
# puts ""
|
|
132
|
-
# end
|
|
133
|
-
# next
|
|
134
|
-
# end
|
|
135
|
-
|
|
136
|
-
# self.parse_template template if self.template? template
|
|
137
|
-
# end
|
|
138
|
-
# end
|
|
139
|
-
|
|
140
|
-
puts opts if error_flag or ARGV.size == 0
|
|
85
|
+
def use_home
|
|
86
|
+
raise "Next time use --home before specifying the target." if @used_target
|
|
87
|
+
puts "Using #{Dir.home}/ as root."
|
|
88
|
+
@target = Dir.home
|
|
89
|
+
@use_home = true
|
|
90
|
+
end
|
|
141
91
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
92
|
+
def list
|
|
93
|
+
files = Dir.glob("#{@@home}/*").select {|f| File.directory? f}
|
|
94
|
+
if files.size > 0
|
|
95
|
+
puts "There #{files.size == 1 ? 'is' : 'are'} #{files.size} #{files.size == 1 ? 'template' : 'templates'}:"
|
|
96
|
+
last = Pathname.new(files.last).basename
|
|
97
|
+
files.pop
|
|
98
|
+
files.each do |file|
|
|
99
|
+
puts "├ #{b Pathname.new(file).basename}"
|
|
145
100
|
end
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
retry
|
|
101
|
+
puts "└ #{b last}"
|
|
102
|
+
else
|
|
103
|
+
puts "Your laadur folder is empty!"
|
|
150
104
|
end
|
|
151
105
|
end
|
|
152
106
|
|
|
@@ -159,8 +113,13 @@ module Laadur
|
|
|
159
113
|
FileUtils.cp_r "#{@@home}/#{template}/.", @target
|
|
160
114
|
puts "#{b template} loaded!"
|
|
161
115
|
end
|
|
162
|
-
|
|
163
|
-
def
|
|
116
|
+
|
|
117
|
+
def load_regex expr
|
|
118
|
+
l = Dir.glob("#{@@home}/#{expr}").select { |f| self.template? Pathname.new(f).basename }
|
|
119
|
+
l.each do |template|
|
|
120
|
+
parse_template Pathname.new(template).basename
|
|
121
|
+
end
|
|
122
|
+
end
|
|
164
123
|
|
|
165
124
|
def b(text) "#{`tput bold`}#{text}#{`tput sgr0`}"; end
|
|
166
125
|
|
|
@@ -174,5 +133,30 @@ module Laadur
|
|
|
174
133
|
puts "There is no template with such name."
|
|
175
134
|
end
|
|
176
135
|
end
|
|
136
|
+
|
|
137
|
+
def print_message
|
|
138
|
+
puts "Laadur #{Laadur::VERSION}\n"+
|
|
139
|
+
"============\n" +
|
|
140
|
+
"Documentation: github.com/rozzy/laadur\n" +
|
|
141
|
+
"Written by Rozzy (github.com/rozzy) for you.\n" +
|
|
142
|
+
"Thanks for using.\n"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def parse_multiple_args
|
|
146
|
+
ARGV.each do |template|
|
|
147
|
+
if template.match /^--|-/
|
|
148
|
+
if self.template? template
|
|
149
|
+
puts "There is option with name #{b template} and a path #{@@home}/#{b template}."
|
|
150
|
+
puts "I think this is option. If you want use it as path, load it like this: /../.laadur/#{b template}. Sorry :-("
|
|
151
|
+
puts ""
|
|
152
|
+
puts opts
|
|
153
|
+
puts ""
|
|
154
|
+
end
|
|
155
|
+
next
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
self.parse_template template if self.template? template
|
|
159
|
+
end
|
|
160
|
+
end
|
|
177
161
|
end
|
|
178
162
|
end
|
data/lib/laadur/version.rb
CHANGED
data/lib/version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.0.2
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: laadur
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nikita Nikitin
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2013-10-
|
|
11
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -38,7 +38,7 @@ dependencies:
|
|
|
38
38
|
- - '>='
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
|
-
description:
|
|
41
|
+
description: Template manager with CLI
|
|
42
42
|
email:
|
|
43
43
|
- berozzy@gmail.com
|
|
44
44
|
executables:
|
|
@@ -49,14 +49,14 @@ files:
|
|
|
49
49
|
- .gitignore
|
|
50
50
|
- Gemfile
|
|
51
51
|
- LICENSE
|
|
52
|
-
- README
|
|
52
|
+
- README.md
|
|
53
53
|
- Rakefile
|
|
54
|
+
- TODO
|
|
54
55
|
- bin/laadur
|
|
55
56
|
- laadur.gemspec
|
|
56
|
-
- laadur.txt
|
|
57
57
|
- lib/laadur.rb
|
|
58
58
|
- lib/laadur/version.rb
|
|
59
|
-
- version
|
|
59
|
+
- lib/version
|
|
60
60
|
homepage: http://github.com/rozzy/laadur
|
|
61
61
|
licenses:
|
|
62
62
|
- MIT
|
data/README
DELETED
data/laadur.txt
DELETED
data/version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1.0.1
|