laadur 1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 32e5a296dde73b92f69d328b943a5bcac468d4a9
4
+ data.tar.gz: 1ff473f2c9f046542e4ef48ea3eb05854506ab6c
5
+ SHA512:
6
+ metadata.gz: e40fec48cdd196a4285c1f7883413c91419ee50f28cfe6d9a01f387d653e805b038a02f41f0779ab6b2d34f0bc32bf5bb3c85a117507bd1c13f60ae6e337b642
7
+ data.tar.gz: f3a19845fe7e9821143651e2277d9f01ee1a091b39d85fa53ae7b2c9fd13b405621d9e79deea02c182b454002925fe6ec201e5b2242a0e316de83924b0a636c5
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ coverage
8
+ InstalledFiles
9
+ lib/bundler/man
10
+ pkg
11
+ rdoc
12
+ spec/reports
13
+ test/tmp
14
+ test/version_tmp
15
+ tmp
16
+
17
+ # YARD artifacts
18
+ .yardoc
19
+ _yardoc
20
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in laadur.gemspec
4
+ gemspec
5
+ gem "version"
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Rozzy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,3 @@
1
+ laadur
2
+ ===
3
+ helps to manage workflow
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'version'
3
+
4
+ task :deploy, :arg1 do |t, args|
5
+ `rake install`
6
+ `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
+ `git commit -m '#{args.arg1}'`
11
+ `git push`
12
+ end
data/bin/laadur ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'laadur'
4
+ ch = Laadur::CLI.new
data/laadur.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'laadur/version'
5
+ include Laadur
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "laadur"
9
+ spec.version = Laadur.VERSION
10
+ spec.authors = ["Nikita Nikitin"]
11
+ spec.email = ["berozzy@gmail.com"]
12
+ spec.description = "Helps to simplify workflow"
13
+ spec.summary = ""
14
+ spec.homepage = "http://github.com/rozzy/laadur"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = ["laadur"] #spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ end
data/laadur.txt ADDED
@@ -0,0 +1,5 @@
1
+ Laadur #{version}
2
+ ============
3
+ Documentation: github.com/rozzy/laadur
4
+ Written by Rozzy (github.com/rozzy) for you.
5
+ Thanks for using.
@@ -0,0 +1,5 @@
1
+ module Laadur
2
+ def VERSION
3
+ File.read "version"
4
+ end
5
+ end
data/lib/laadur.rb ADDED
@@ -0,0 +1,178 @@
1
+ require 'laadur/version'
2
+ require 'optparse'
3
+ require 'fileutils'
4
+ require 'shell'
5
+
6
+ module Laadur
7
+ class CLI
8
+ def initialize
9
+ @@home = "#{Dir.home}/.laadur"
10
+ Dir.mkdir(File.join(Dir.home, ".laadur"), 0700) if not File.directory? @@home
11
+
12
+ @@workpath = Dir.pwd
13
+ puts "Your laadur folder is empty.\n\n" if Dir[File.join(@@home, '**', '*')].count { |dir| File.directory?(dir) } == 0
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']
23
+ 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
34
+
35
+ opts.on("--docs", "open github documentation page") do
36
+ `open https://github.com/rozzy/laadur`
37
+ end
38
+
39
+ opts.separator ""
40
+
41
+ opts.on("-o", "--open", "open laadur folder with Finder.app") do
42
+ `open #{@@home}`
43
+ end
44
+
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
59
+
60
+ opts.on("--folder", "print folder path") do
61
+ puts @@home
62
+ end
63
+
64
+ opts.separator ""
65
+
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
93
+
94
+ opts.separator ""
95
+
96
+ opts.on("-s", "--search <expr>", "search templates with regex") do |expr|
97
+ puts "searching with #{expr}"
98
+ end
99
+
100
+ opts.on("--all", "load all templates") do
101
+ puts "loading all"
102
+ end
103
+
104
+ opts.separator ""
105
+
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
109
+
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
122
+
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
141
+
142
+ end.parse!
143
+ rescue => error
144
+ puts error.to_s.slice(0,1).capitalize + error.to_s.slice(1..-1)
145
+ end
146
+ rescue OptionParser::InvalidOption => error
147
+ puts error.to_s
148
+ error_flag = true
149
+ retry
150
+ end
151
+ end
152
+
153
+ def template? template
154
+ File.directory? "#{@@home}/#{template}"
155
+ end
156
+
157
+ def parse_template template
158
+ @parsed_tmpl = true
159
+ FileUtils.cp_r "#{@@home}/#{template}/.", @target
160
+ puts "#{b template} loaded!"
161
+ end
162
+
163
+ def version; File.read "version"; end
164
+
165
+ def b(text) "#{`tput bold`}#{text}#{`tput sgr0`}"; end
166
+
167
+ def remove_template template
168
+ if self.template? template
169
+ print "You asked to remove template #{b template} (#{@@home}/#{template}). Are you sure? [y/n] "
170
+ begin
171
+ FileUtils.rm_rf "#{@@home}/#{template}" rescue puts "Something went wrong."
172
+ end if gets.chomp! == "y"
173
+ else
174
+ puts "There is no template with such name."
175
+ end
176
+ end
177
+ end
178
+ end
data/version ADDED
@@ -0,0 +1 @@
1
+ 1.0.1
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: laadur
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nikita Nikitin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Helps to simplify workflow
42
+ email:
43
+ - berozzy@gmail.com
44
+ executables:
45
+ - laadur
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - .gitignore
50
+ - Gemfile
51
+ - LICENSE
52
+ - README
53
+ - Rakefile
54
+ - bin/laadur
55
+ - laadur.gemspec
56
+ - laadur.txt
57
+ - lib/laadur.rb
58
+ - lib/laadur/version.rb
59
+ - version
60
+ homepage: http://github.com/rozzy/laadur
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.1.10
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: ''
84
+ test_files: []