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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32e5a296dde73b92f69d328b943a5bcac468d4a9
4
- data.tar.gz: 1ff473f2c9f046542e4ef48ea3eb05854506ab6c
3
+ metadata.gz: 5d107aebb2b1247f7ff2874b4e5c2e52ca52e18d
4
+ data.tar.gz: aae0f83d091ec84bd389d13187f687d79db26023
5
5
  SHA512:
6
- metadata.gz: e40fec48cdd196a4285c1f7883413c91419ee50f28cfe6d9a01f387d653e805b038a02f41f0779ab6b2d34f0bc32bf5bb3c85a117507bd1c13f60ae6e337b642
7
- data.tar.gz: f3a19845fe7e9821143651e2277d9f01ee1a091b39d85fa53ae7b2c9fd13b405621d9e79deea02c182b454002925fe6ec201e5b2242a0e316de83924b0a636c5
6
+ metadata.gz: c98773fe172829fa16ee54b7c6da17d8412d7801eeec71dbaeb0a5b42770193a47cbb6920c766b8cac8562c7b445e513ea5cdea44e64f9f1b2861aec24c1dd20
7
+ data.tar.gz: 70ef15ad24e2d04ba9746a4e1d8065e0682e7ef3311664c74cf71b81dda0d2c97dc633f4917cbe1c00b0a94e05262571be12c924a2bc57617f982e3ae370f5d8
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in laadur.gemspec
4
- gemspec
5
- gem "version"
4
+ gemspec
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
+ ![Folder structure example](http://d1zjcuqflbd5k.cloudfront.net/files/acc_127427/Rqjt?response-content-disposition=inline;%20filename=Screen%20Shot%202013-10-29%20at%2012.24.34%20PM.png;%20filename*=UTF-8%27%27Screen%20Shot%202013-10-29%20at%2012.24.34%20PM.png&Expires=1383042517&Signature=Gun9Ejh5oAcvkZMFclne-84ATu4xa9Pu1Yh4tJOnCKBw8pOTYfD2pCHMfEr7uDMDFuIxaHBt15WlcDnMjHhZeA1MNHnlK2D1dDqSldgWf7YOpgYe3ImiM3q8XiDdukyLxjpcE-kaSxkBu5kuZxAU5fuk4pTOv4o8V8WEzavhjsI_&Key-Pair-Id=APKAJTEIOJM3LSMN33SA)
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
@@ -0,0 +1,4 @@
1
+ v2.0:
2
+ * collect options -> parse –> run (instead of parse->run in v1.0)
3
+ * --combine
4
+ * --force
data/bin/laadur CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'laadur'
4
- ch = Laadur::CLI.new
4
+ Laadur::CLI.new
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.VERSION
9
+ spec.version = Laadur::VERSION
10
10
  spec.authors = ["Nikita Nikitin"]
11
11
  spec.email = ["berozzy@gmail.com"]
12
- spec.description = "Helps to simplify workflow"
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
- error_flag ||= false
16
- @use_home = false
17
- @parsed_tmpl = false
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
- OptionParser.new do |opts|
25
- opts.banner = "Usage: laadur [options]"
26
-
27
- opts.on("-v", "--version", "show version") do
28
- puts version
29
- end
30
-
31
- opts.on("-h", "--help", "help window") do
32
- puts opts
33
- end
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
- opts.on("--docs", "open github documentation page") do
36
- `open https://github.com/rozzy/laadur`
37
- end
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
- `open #{@@home}`
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.on("-l", "--list", "list all templates") do
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("--folder", "print folder path") do
61
- puts @@home
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("-t", "--target <path>", "specify target folder for copying template files (also see --home)") do |target|
67
- raise "Next time use --target before specifying the template." if @parsed_tmpl
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("-s", "--search <expr>", "search templates with regex") do |expr|
97
- puts "searching with #{expr}"
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
- opts.on("--all", "load all templates") do
101
- puts "loading all"
102
- end
60
+ print_message if ARGV.size == 0
61
+
62
+ parse_multiple_args if ARGV.size > 1 and @@multiloading
103
63
 
104
- opts.separator ""
64
+ puts opts if @error_flag or ARGV.size == 0
65
+ end.parse!
66
+ end
105
67
 
106
- opts.on("load template from repository", "-l", "--load <template>", "you may not specify this flag") do |template|
107
- self.parse_template template
108
- end
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
- opts.on("-r", "--remove <template>", "remove a certain template") do |template|
111
- self.remove_template template
112
- end
113
-
114
- if ARGV.size == 0
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
- # if ARGV.size > 0
124
- # ARGV.each do |template|
125
- # if template.match /^--|-/ and reserved.include? template
126
- # if self.template? template
127
- # puts "There is option with name #{b template} and a path #{@@home}/#{b template}."
128
- # puts "I think this is option. If you want use it as path, load it like this: /../.laadur/#{b template}. Sorry :-("
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
- end.parse!
143
- rescue => error
144
- puts error.to_s.slice(0,1).capitalize + error.to_s.slice(1..-1)
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
- rescue OptionParser::InvalidOption => error
147
- puts error.to_s
148
- error_flag = true
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 version; File.read "version"; end
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
@@ -1,5 +1,3 @@
1
1
  module Laadur
2
- def VERSION
3
- File.read "version"
4
- end
2
+ VERSION = '1.3.1'
5
3
  end
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.0.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-27 00:00:00.000000000 Z
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: Helps to simplify workflow
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
@@ -1,3 +0,0 @@
1
- laadur
2
- ===
3
- helps to manage workflow
data/laadur.txt DELETED
@@ -1,5 +0,0 @@
1
- Laadur #{version}
2
- ============
3
- Documentation: github.com/rozzy/laadur
4
- Written by Rozzy (github.com/rozzy) for you.
5
- Thanks for using.
data/version DELETED
@@ -1 +0,0 @@
1
- 1.0.1