geohash36 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/AUTHORS.md +29 -0
- data/CHANGELOG.md +0 -0
- data/COPYING.md +12 -0
- data/Gemfile +107 -0
- data/LICENSE.md +14 -0
- data/MAINTAINERS.md +40 -0
- data/README.md +78 -0
- data/Rakefile +52 -0
- data/bin/geohash36 +45 -0
- data/geohash36.gemspec +136 -0
- data/lib/demo.rb +25 -0
- data/lib/geohash36/interface/rake/cucumber.rb +36 -0
- data/lib/geohash36/interface/rake/default.rb +28 -0
- data/lib/geohash36/interface/rake/documentation.rb +46 -0
- data/lib/geohash36/interface/rake/guard.rb +13 -0
- data/lib/geohash36/interface/rake/helpers.rb +27 -0
- data/lib/geohash36/interface/rake/library.rb +126 -0
- data/lib/geohash36/interface/rake/metric.rb +13 -0
- data/lib/geohash36/interface/rake/rspec.rb +8 -0
- data/lib/geohash36/interface/thor/info.thor +292 -0
- data/lib/geohash36/interface/thor/mixin/config_choice.rb +27 -0
- data/lib/geohash36/interface/thor/mixin/configuration.rb +28 -0
- data/lib/geohash36/interface/thor/mixin/default.rb +30 -0
- data/lib/geohash36/interface/thor/mixin/default_config.rb +31 -0
- data/lib/geohash36/interface/thor/mixin/guess.rb +57 -0
- data/lib/geohash36/interface/thor/mixin/logger.rb +43 -0
- data/lib/geohash36/interface/thor/mixin/shell.rb +225 -0
- data/lib/geohash36/interface/thor/version.thor +33 -0
- data/lib/geohash36/library/interval.rb +130 -0
- data/lib/geohash36/version.rb +13 -0
- data/lib/geohash36.rb +164 -0
- data/spec/geohash36_spec.rb +52 -0
- data/spec/library/interval_spec.rb +55 -0
- data/spec/spec_helper.rb +55 -0
- metadata +281 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# System
|
5
|
+
require 'shellwords'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
require 'date'
|
9
|
+
require 'ostruct'
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
### Actions
|
14
|
+
|
15
|
+
desc "Look for TODO and FIXME tags in the code" # {{{
|
16
|
+
task :todo do
|
17
|
+
egrep /(FIXME|TODO|TBD|FIXME1|FIXME2|FIXME3)/
|
18
|
+
end # }}}
|
19
|
+
|
20
|
+
desc "Git Tag number of this repo" # {{{
|
21
|
+
task :version do |t|
|
22
|
+
# sh 'git describe --abbrev=0 --tags'
|
23
|
+
sh 'git describe --tags'
|
24
|
+
end # }}}
|
25
|
+
|
26
|
+
|
27
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,126 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# System
|
5
|
+
require 'shellwords'
|
6
|
+
require 'fileutils'
|
7
|
+
|
8
|
+
require 'date'
|
9
|
+
require 'ostruct'
|
10
|
+
|
11
|
+
|
12
|
+
### Helper Functions
|
13
|
+
|
14
|
+
# @fn def egrep(pattern) # {{{
|
15
|
+
# @brief Searches for a given regular expression among all ruby files
|
16
|
+
#
|
17
|
+
# @param [Regexp] pattern Regular Expression pattern class
|
18
|
+
def egrep( pattern )
|
19
|
+
|
20
|
+
Dir[ "**/*.{rb,thor,rake}" ].each do |fn|
|
21
|
+
count = 0
|
22
|
+
open(fn) do |f|
|
23
|
+
|
24
|
+
while line = f.gets
|
25
|
+
count += 1
|
26
|
+
STDOUT.puts "#{fn}:#{count}:#{line}" if line =~ pattern
|
27
|
+
end
|
28
|
+
|
29
|
+
end # end of open
|
30
|
+
end # end of Dir.each
|
31
|
+
|
32
|
+
end # }}}
|
33
|
+
|
34
|
+
# @fn def clean target # {{{
|
35
|
+
# @brief Clean thrift output from folder
|
36
|
+
#
|
37
|
+
# @param [String] target Target folder to clean
|
38
|
+
def clean target
|
39
|
+
|
40
|
+
files = Dir.glob( File.join( target, "*" ) )
|
41
|
+
|
42
|
+
files.each do |file|
|
43
|
+
print "(--) "
|
44
|
+
sh "rm -vrf #{file.to_s}" if( File.exists?( "#{file.to_s}" ) )
|
45
|
+
end
|
46
|
+
|
47
|
+
end # }}}
|
48
|
+
|
49
|
+
# @fn def colorize color, message {{{
|
50
|
+
# @brief The function colorize takes a message and wraps it into standard color commands such as for bash.
|
51
|
+
#
|
52
|
+
# @param [String] color The colorname in plain english. e.g. "LightGray", "Gray", "Red", "BrightRed"
|
53
|
+
# @param [String] message The message which should be wrapped
|
54
|
+
#
|
55
|
+
# @return [String] Colorized message string
|
56
|
+
#
|
57
|
+
# @warning Might not work for your terminal
|
58
|
+
#
|
59
|
+
# FIXME: Implement bold behavior
|
60
|
+
# FIXME: This method is currently b0rked
|
61
|
+
def colorize color, message
|
62
|
+
|
63
|
+
# Black 0;30 Dark Gray 1;30
|
64
|
+
# Blue 0;34 Light Blue 1;34
|
65
|
+
# Green 0;32 Light Green 1;32
|
66
|
+
# Cyan 0;36 Light Cyan 1;36
|
67
|
+
# Red 0;31 Light Red 1;31
|
68
|
+
# Purple 0;35 Light Purple 1;35
|
69
|
+
# Brown 0;33 Yellow 1;33
|
70
|
+
# Light Gray 0;37 White 1;37
|
71
|
+
|
72
|
+
colors = {
|
73
|
+
"Gray" => "\e[1;30m",
|
74
|
+
"LightGray" => "\e[0;37m",
|
75
|
+
"Cyan" => "\e[0;36m",
|
76
|
+
"LightCyan" => "\e[1;36m",
|
77
|
+
"Blue" => "\e[0;34m",
|
78
|
+
"LightBlue" => "\e[1;34m",
|
79
|
+
"Green" => "\e[0;32m",
|
80
|
+
"LightGreen" => "\e[1;32m",
|
81
|
+
"Red" => "\e[0;31m",
|
82
|
+
"LightRed" => "\e[1;31m",
|
83
|
+
"LightRedBlink" => "\e[5;31m",
|
84
|
+
"Purple" => "\e[0;35m",
|
85
|
+
"LightPurple" => "\e[1;35m",
|
86
|
+
"Brown" => "\e[0;33m",
|
87
|
+
"Yellow" => "\e[1;33m",
|
88
|
+
"White" => "\e[1;37m"
|
89
|
+
}
|
90
|
+
nocolor = "\e[0m"
|
91
|
+
|
92
|
+
colors[ color ] + message + nocolor
|
93
|
+
end # of def colorize }}}
|
94
|
+
|
95
|
+
# @fn def message level, msg {{{
|
96
|
+
# @brief The function message will take a message as argument as well as a level (e.g. "info", "ok", "error", "question", "debug") which then would print
|
97
|
+
# ( "(--) msg..", "(II) msg..", "(EE) msg..", "(??) msg..")
|
98
|
+
#
|
99
|
+
# @param [Symbol] level Can either be :info, :success, :error or :question
|
100
|
+
# @param [String] msg Represents the message you want to send to stdout (info, ok, question) stderr (error)
|
101
|
+
#
|
102
|
+
# Helpers: colorize
|
103
|
+
def message level, msg
|
104
|
+
|
105
|
+
symbols = {
|
106
|
+
:info => [ "(--)", "Brown" ],
|
107
|
+
:success => [ "(II)", "LightGreen" ],
|
108
|
+
:error => [ "(EE)", "LightRed" ],
|
109
|
+
:question => [ "(??)", "LightCyan" ],
|
110
|
+
:debug => [ "(++)", "LightBlue" ],
|
111
|
+
:warning => [ "(WW)", "Yellow" ]
|
112
|
+
}
|
113
|
+
|
114
|
+
raise ArugmentError, "Can't find the corresponding symbol for this message level (#{level.to_s}) - is the spelling wrong?" unless( symbols.key?( level ) )
|
115
|
+
|
116
|
+
if( level == :error )
|
117
|
+
STDERR.puts colorize( symbols[ level.to_sym ].last, "#{symbols[ level.to_sym ].first.to_s} #{msg.to_s}" )
|
118
|
+
else
|
119
|
+
STDOUT.puts colorize( symbols[ level.to_sym ].last, "#{symbols[ level.to_sym ].first.to_s} #{msg.to_s}" )
|
120
|
+
end
|
121
|
+
|
122
|
+
end # of def message }}}
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,292 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# System includes
|
5
|
+
require 'ostruct'
|
6
|
+
require 'awesome_print'
|
7
|
+
require 'andand'
|
8
|
+
require 'tempfile'
|
9
|
+
require 'os'
|
10
|
+
|
11
|
+
# Custom includes
|
12
|
+
require File.expand_path( File.dirname( __FILE__ ) + '/mixin/shell' )
|
13
|
+
|
14
|
+
|
15
|
+
# @class Info command class
|
16
|
+
# @brief Implements the info command
|
17
|
+
class Info < Thor
|
18
|
+
|
19
|
+
include ::Mixin::Shell
|
20
|
+
# include ::Mixin::Command
|
21
|
+
|
22
|
+
default_task :info
|
23
|
+
|
24
|
+
class_option :'without-general', :type => :boolean, :desc => "Print general system environment information"
|
25
|
+
class_option :'without-project', :type => :boolean, :desc => "Print project environment information"
|
26
|
+
class_option :'without-ruby', :type => :boolean, :desc => "Print ruby environment information"
|
27
|
+
|
28
|
+
class_option :pretty, :type => :boolean, :desc => "Pretty print"
|
29
|
+
|
30
|
+
|
31
|
+
## API
|
32
|
+
|
33
|
+
# @fn def info {{{
|
34
|
+
# @brief Main info task entry point
|
35
|
+
desc "overview", "Shows system overview"
|
36
|
+
def overview
|
37
|
+
|
38
|
+
# Default symbol action list to find info for
|
39
|
+
default = %i(
|
40
|
+
general
|
41
|
+
project
|
42
|
+
ruby
|
43
|
+
)
|
44
|
+
|
45
|
+
# Make sure if we have a --without-* opts to skip work
|
46
|
+
options.each_pair do |option, skip|
|
47
|
+
next unless( skip )
|
48
|
+
default.delete_if { |item| option =~ %r{#{item.to_s}}i }
|
49
|
+
end
|
50
|
+
|
51
|
+
# Execute scan & print
|
52
|
+
default.each do |item|
|
53
|
+
data = scan_for item
|
54
|
+
next if data.andand.broken.nil?
|
55
|
+
|
56
|
+
self.send :pretty_print, data
|
57
|
+
end # of default.each
|
58
|
+
|
59
|
+
end # }}}
|
60
|
+
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
no_tasks do
|
65
|
+
|
66
|
+
## Actions
|
67
|
+
|
68
|
+
# @fn def scan_for what # {{{
|
69
|
+
# @brief When executed will run "what" method scanner and print relevant information
|
70
|
+
#
|
71
|
+
# @param [Symbol] what Symbol of scanner method to run, e.g. :general, :java, :ruby etc.
|
72
|
+
def scan_for what
|
73
|
+
result = nil
|
74
|
+
|
75
|
+
begin
|
76
|
+
result = self.send what
|
77
|
+
rescue Exception => e
|
78
|
+
say "(EE) " + e.message, :red
|
79
|
+
result = OpenStruct.new
|
80
|
+
result.broken = true
|
81
|
+
end
|
82
|
+
|
83
|
+
return result
|
84
|
+
end # }}}
|
85
|
+
|
86
|
+
# @fn def pretty_print information, playful = options[:pretty] # {{{
|
87
|
+
# @brief Pretty prints given data to stdout
|
88
|
+
#
|
89
|
+
# @param [OpenStruct] information Information gathered from other scanning methods, e.g. :ruby
|
90
|
+
# @param [Boolean] playful Prints some curses like lines if true
|
91
|
+
def pretty_print information, playful = options[:pretty]
|
92
|
+
begin
|
93
|
+
puts ""
|
94
|
+
say information.title, :yellow
|
95
|
+
|
96
|
+
if( playful )
|
97
|
+
puts "-"*26
|
98
|
+
puts " "*26 + "\\"
|
99
|
+
else
|
100
|
+
puts ""
|
101
|
+
end
|
102
|
+
|
103
|
+
values = information.send :table
|
104
|
+
raise ArgumentError, "Information openstruct is malformed" if( values[ :broken ] )
|
105
|
+
|
106
|
+
values.each do |key, value|
|
107
|
+
|
108
|
+
# Skip :broken, :title
|
109
|
+
next if( %i(title broken).include?( key.to_sym ) )
|
110
|
+
|
111
|
+
# Make sure value is a string
|
112
|
+
value = value.to_s
|
113
|
+
|
114
|
+
# Remove pre- and post-padding
|
115
|
+
value.strip!
|
116
|
+
|
117
|
+
# Turn key into a nice printable value
|
118
|
+
# e.g. :current_directory => Current directory
|
119
|
+
description = key.to_s
|
120
|
+
description.gsub!( "_", " " )
|
121
|
+
description.capitalize!
|
122
|
+
|
123
|
+
|
124
|
+
# Check if value is multi-line, if so, format accordingly
|
125
|
+
output = []
|
126
|
+
|
127
|
+
if( value =~ %r{\n} )
|
128
|
+
lines = value.split( "\n" )
|
129
|
+
output << sprintf( "%-25s | %s", description, lines.shift )
|
130
|
+
lines.each { |line| output << sprintf( "%-25s | %s", "", line ) }
|
131
|
+
else
|
132
|
+
output << sprintf( "%-25s | %s", description, value )
|
133
|
+
end
|
134
|
+
|
135
|
+
output.each { |something| say something }
|
136
|
+
end
|
137
|
+
|
138
|
+
if( playful )
|
139
|
+
puts " "*26 + "\\"
|
140
|
+
puts " "*27 + "-"*80
|
141
|
+
end
|
142
|
+
|
143
|
+
puts ""
|
144
|
+
|
145
|
+
rescue Exception => e
|
146
|
+
say "(EE) " + e.message, :red
|
147
|
+
end
|
148
|
+
end # }}}
|
149
|
+
|
150
|
+
|
151
|
+
## Specific Scanners
|
152
|
+
|
153
|
+
# @fn def general {{{
|
154
|
+
# @brief Returns information collected from the general system
|
155
|
+
#
|
156
|
+
# @return [OpenStruct] Returns openstruct with gathered information
|
157
|
+
def general
|
158
|
+
result = nil
|
159
|
+
|
160
|
+
begin
|
161
|
+
result = OpenStruct.new
|
162
|
+
result.broken = false
|
163
|
+
|
164
|
+
os = os_report
|
165
|
+
|
166
|
+
result.title = "System Information"
|
167
|
+
result.system = os.host
|
168
|
+
result.cpus = OS.cpu_count
|
169
|
+
result.architecture = OS.bits
|
170
|
+
result.current_user = `whoami`.chomp
|
171
|
+
|
172
|
+
rescue Exception => e
|
173
|
+
result = OpenStruct.new
|
174
|
+
result.broken = true
|
175
|
+
|
176
|
+
say "(EE) " + e.message, :red
|
177
|
+
end
|
178
|
+
|
179
|
+
return result
|
180
|
+
end # }}}
|
181
|
+
|
182
|
+
# @fn def project {{{
|
183
|
+
# @brief Print project related information to stdout
|
184
|
+
#
|
185
|
+
# @return [OpenStruct] Returns openstruct with gathered information
|
186
|
+
def project
|
187
|
+
result = nil
|
188
|
+
|
189
|
+
begin
|
190
|
+
result = OpenStruct.new
|
191
|
+
result.broken = false
|
192
|
+
|
193
|
+
result.title = "Project information"
|
194
|
+
|
195
|
+
result.current_directory = Dir.pwd
|
196
|
+
result.version = `git describe --tags` || "unknown"
|
197
|
+
|
198
|
+
rescue Exception => e
|
199
|
+
result = OpenStruct.new
|
200
|
+
result.broken = true
|
201
|
+
|
202
|
+
say "(EE) " + e.message, :red
|
203
|
+
end
|
204
|
+
|
205
|
+
return result
|
206
|
+
end # }}}
|
207
|
+
|
208
|
+
# @fn def ruby {{{
|
209
|
+
# @brief Prints ruby environment information to stdout
|
210
|
+
#
|
211
|
+
# @return [OpenStruct] Returns openstruct with gathered information
|
212
|
+
def ruby
|
213
|
+
|
214
|
+
result = nil
|
215
|
+
|
216
|
+
begin
|
217
|
+
result = OpenStruct.new
|
218
|
+
result.broken = false
|
219
|
+
|
220
|
+
result.title = 'Ruby Information'
|
221
|
+
|
222
|
+
commands = %w(ruby rvm rbenv rake gem)
|
223
|
+
|
224
|
+
commands.each do |command|
|
225
|
+
next unless( self.which( command ) )
|
226
|
+
|
227
|
+
result.send "#{command}=", self.version( command )
|
228
|
+
end
|
229
|
+
|
230
|
+
rescue Exception => e
|
231
|
+
result = OpenStruct.new
|
232
|
+
result.broken = true
|
233
|
+
|
234
|
+
say "(EE) " + e.message, :red
|
235
|
+
end
|
236
|
+
|
237
|
+
return result
|
238
|
+
end # }}}
|
239
|
+
|
240
|
+
|
241
|
+
## Helpers
|
242
|
+
|
243
|
+
# @fn def os_report {{{
|
244
|
+
# @brief Get overview of the Operating System
|
245
|
+
#
|
246
|
+
# @return [OpenStruct] Returns a openstruct with various information, e.g.
|
247
|
+
# arch, target_os, target_vendor, target_cpu, target, host_os, host_vendor, host_cpu, host, RUBY_PLATFORM
|
248
|
+
def os_report
|
249
|
+
result = nil
|
250
|
+
|
251
|
+
begin
|
252
|
+
yaml = OS.report
|
253
|
+
hash = YAML.load( yaml )
|
254
|
+
result = hashes_to_ostruct( hash )
|
255
|
+
rescue Exception => e
|
256
|
+
$stderr.puts set_color "(EE) #{e.message}", :red
|
257
|
+
end
|
258
|
+
|
259
|
+
result
|
260
|
+
end # }}}
|
261
|
+
|
262
|
+
# @fn def hashes_to_ostruct object # {{{
|
263
|
+
# @brief This function turns a nested hash into a nested open struct
|
264
|
+
#
|
265
|
+
# @author Dave Dribin
|
266
|
+
# Reference: http://www.dribin.org/dave/blog/archives/2006/11/17/hashes_to_ostruct/
|
267
|
+
#
|
268
|
+
# @param [Object] object Value can either be of type Hash or Array, if other then it is returned and not changed
|
269
|
+
#
|
270
|
+
# @return [OStruct] Returns nested open structs
|
271
|
+
def hashes_to_ostruct object
|
272
|
+
|
273
|
+
return case object
|
274
|
+
when Hash
|
275
|
+
object = object.clone
|
276
|
+
object.each { |key, value| object[key] = hashes_to_ostruct(value) }
|
277
|
+
OpenStruct.new( object )
|
278
|
+
when Array
|
279
|
+
object = object.clone
|
280
|
+
object.map! { |i| hashes_to_ostruct(i) }
|
281
|
+
else
|
282
|
+
object
|
283
|
+
end
|
284
|
+
|
285
|
+
end # of def hashes_to_ostruct }}}
|
286
|
+
|
287
|
+
end # of no_tasks do
|
288
|
+
|
289
|
+
end # of Class Info
|
290
|
+
|
291
|
+
|
292
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# @module module Mixin
|
4
|
+
# @brief Mixin module contains various functions to be used in other components
|
5
|
+
module Mixin
|
6
|
+
|
7
|
+
# @module ConfigChoice Module
|
8
|
+
# @brief Module wrapper around ConfigChoice tasks
|
9
|
+
module ConfigChoice
|
10
|
+
|
11
|
+
def config_choice
|
12
|
+
defaults = YAML.load_file(File.expand_path( File.dirname( __FILE__ ) + '/../../../template/default_values.yml'))
|
13
|
+
defaults['jason'].each_key { |key| choice_option(defaults['jason'], key) }
|
14
|
+
defaults
|
15
|
+
end
|
16
|
+
|
17
|
+
private def choice_option(defaults, option)
|
18
|
+
print ("%s (%s): " % [option, defaults[option]])
|
19
|
+
value = STDIN.gets.chomp
|
20
|
+
defaults[option] = value unless value.empty?
|
21
|
+
end
|
22
|
+
end # of module ConfigChoice
|
23
|
+
|
24
|
+
end # of module Mixin
|
25
|
+
|
26
|
+
|
27
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# @module module Mixin
|
5
|
+
# @brief Mixin module contains various functions to be used in other components
|
6
|
+
module Mixin
|
7
|
+
|
8
|
+
# @module Configuration Module
|
9
|
+
# @brief Module wrapper around tasks which demands config file
|
10
|
+
module Configuration
|
11
|
+
|
12
|
+
# @fn def initialize *args {{{
|
13
|
+
# @brief Default constructor
|
14
|
+
#
|
15
|
+
# @param [Array] args Argument array
|
16
|
+
def initialize *args
|
17
|
+
super
|
18
|
+
unless File.exist?("~/.geohash36/config.yaml")
|
19
|
+
abort("Could not find configuration file in ~/geohash36/config.yaml. Please run 'geohash36 config:generate' to generate it.")
|
20
|
+
end
|
21
|
+
end # }}}
|
22
|
+
|
23
|
+
end # of module Configuration
|
24
|
+
|
25
|
+
end # of module Mixin
|
26
|
+
|
27
|
+
|
28
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# System includes
|
5
|
+
require 'thor'
|
6
|
+
require 'andand'
|
7
|
+
|
8
|
+
|
9
|
+
# @module module Mixin
|
10
|
+
# @brief Mixin module contains various functions to be used in other components
|
11
|
+
module Mixin
|
12
|
+
|
13
|
+
# @module Default Module
|
14
|
+
# @brief Module wrapper around default tasks
|
15
|
+
module Default
|
16
|
+
|
17
|
+
# @fn def initialize *args {{{
|
18
|
+
# @brief Default constructor
|
19
|
+
#
|
20
|
+
# @param [Array] args Argument array
|
21
|
+
def initialize *args
|
22
|
+
super
|
23
|
+
end # }}}
|
24
|
+
|
25
|
+
end # of module Default
|
26
|
+
|
27
|
+
end # of module Mixin
|
28
|
+
|
29
|
+
|
30
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Custom includes
|
4
|
+
require File.expand_path( File.dirname( __FILE__ ) + '/config_choice' )
|
5
|
+
|
6
|
+
# @module module Mixin
|
7
|
+
# @brief Mixin module contains various functions to be used in other components
|
8
|
+
module Mixin
|
9
|
+
|
10
|
+
# @module DefaultConfig Module
|
11
|
+
# @brief Module wrapper around default tasks
|
12
|
+
module DefaultConfig
|
13
|
+
|
14
|
+
# Include various partials
|
15
|
+
include ::Mixin::ConfigChoice
|
16
|
+
|
17
|
+
def defaults
|
18
|
+
config_path = File.expand_path( '~/.geohash36/config.yml' )
|
19
|
+
if File.exists?(config_path)
|
20
|
+
YAML.load_file(config_path)
|
21
|
+
else
|
22
|
+
FileUtils.mkdir_p( File.expand_path( '~/.geohash36' ) )
|
23
|
+
config_choice
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end # of module DefaultConfig
|
27
|
+
|
28
|
+
end # of module Mixin
|
29
|
+
|
30
|
+
|
31
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# System includes
|
5
|
+
require 'andand'
|
6
|
+
|
7
|
+
|
8
|
+
# @module module Mixin
|
9
|
+
# @brief Mixin module contains various functions to be used in other components
|
10
|
+
module Mixin
|
11
|
+
|
12
|
+
# @module Guess Module
|
13
|
+
# @brief Module wrapper around guess tasks to extract version numbers etc
|
14
|
+
module Guess
|
15
|
+
|
16
|
+
# @fn def initialize *args {{{
|
17
|
+
# @brief Default constructor
|
18
|
+
#
|
19
|
+
# @param [Array] args Argument array
|
20
|
+
def initialize *args
|
21
|
+
super
|
22
|
+
end # }}}
|
23
|
+
|
24
|
+
# @fn def guess_version string {{{
|
25
|
+
# @brief Guess version from full version string
|
26
|
+
#
|
27
|
+
# @example e.g. "ruby 2.1.1p76 (2014-02-24 revision 45161) [i686-linux]"
|
28
|
+
# -> 2.1.1
|
29
|
+
#
|
30
|
+
# "rake, version 10.1.1"
|
31
|
+
# -> 10.1.1
|
32
|
+
def guess_version string
|
33
|
+
|
34
|
+
result = ""
|
35
|
+
|
36
|
+
begin
|
37
|
+
|
38
|
+
# Sanity
|
39
|
+
raise ArgumentError, "Version has to be of type string" unless( string.is_a?( String ) )
|
40
|
+
raise ArgumentError, "Version can't be empty" if( string.empty? )
|
41
|
+
|
42
|
+
result = string.match( /\d+\.\d+\.\d+/ ).to_s # matches first only
|
43
|
+
|
44
|
+
rescue Exception => e
|
45
|
+
say "(EE) " + e.message, :red
|
46
|
+
result = ""
|
47
|
+
end
|
48
|
+
|
49
|
+
return result
|
50
|
+
end # }}}
|
51
|
+
|
52
|
+
end # of Module Guess
|
53
|
+
|
54
|
+
end # of module Mixin
|
55
|
+
|
56
|
+
|
57
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
|
4
|
+
# System includes
|
5
|
+
require 'thor'
|
6
|
+
require 'andand'
|
7
|
+
|
8
|
+
# Custom includes
|
9
|
+
require File.expand_path( File.dirname( __FILE__ ) + '/../../../library/logger' )
|
10
|
+
|
11
|
+
|
12
|
+
# @module module Mixin
|
13
|
+
# @brief Mixin module contains various functions to be used in other components
|
14
|
+
module Mixin
|
15
|
+
|
16
|
+
# @module Logger Module
|
17
|
+
# @brief Module wrapper around logger tasks
|
18
|
+
module Logger
|
19
|
+
|
20
|
+
# @fn def initialize *args {{{
|
21
|
+
# @brief Default constructor
|
22
|
+
#
|
23
|
+
# @param [Array] args Argument array
|
24
|
+
def initialize *args
|
25
|
+
super
|
26
|
+
|
27
|
+
@logger = ::ClothesNetwork::Logger.instance
|
28
|
+
|
29
|
+
@logger.color = options[ :colorize ]
|
30
|
+
@logger.silent = options[ :silent ]
|
31
|
+
|
32
|
+
end # }}}
|
33
|
+
|
34
|
+
Thor::class_option :colorize, :type => :boolean, :required => false, :default => true, :desc => 'Colorize the output for easier reading'
|
35
|
+
Thor::class_option :logger, :type => :boolean, :required => false, :default => true, :desc => 'Use default project logger'
|
36
|
+
Thor::class_option :silent, :type => :boolean, :required => false, :default => false, :desc => 'Turn off all logging'
|
37
|
+
|
38
|
+
end # of module Logger
|
39
|
+
|
40
|
+
end # of module Mixin
|
41
|
+
|
42
|
+
|
43
|
+
# vim:ts=2:tw=100:wm=100:syntax=ruby
|