zsh_dots 0.5.7 → 0.5.8
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.
- data/.bundle/config +3 -0
- data/.gitignore +0 -1
- data/Gemfile.lock +1 -1
- data/config/bundle/config +1 -1
- data/config/gitconfig +8 -6
- data/config/vimrc +35 -59
- data/config/zshenv +1 -1
- data/lib/dots/aliases.zsh +3 -1
- data/lib/dots/functions.zsh +41 -0
- data/lib/ruby/dots/bootstrap.rb +4 -13
- data/lib/ruby/dots/command.rb +6 -4
- data/lib/ruby/dots/sanity.rb +50 -0
- data/lib/ruby/dots/version.rb +1 -1
- data/lib/ruby/dots.rb +9 -0
- data/{bin → script}/stock +1 -1
- metadata +22 -36
- data/bin/elocal_nightly.sh +0 -18
- data/bin/gbrt +0 -42
- data/bin/git_cwd_info +0 -40
- data/bin/lein +0 -229
- data/bin/loggly +0 -166
- data/bin/reattach-to-user-namespace +0 -0
- data/bin/repl.sh +0 -6
- data/config/Gemfile +0 -19
data/.bundle/config
ADDED
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/config/bundle/config
CHANGED
data/config/gitconfig
CHANGED
@@ -18,12 +18,14 @@
|
|
18
18
|
unstaged = diff
|
19
19
|
current-branch = !git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||'
|
20
20
|
track = checkout -t
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
restore = stash pop
|
22
|
+
# Rewrite of 'git-process' in git. Basically the same thing without
|
23
|
+
# the _parking_ branch (it's the same as master)
|
24
|
+
sync = !git fetch origin && git rebase master
|
25
|
+
new-fb = !git checkout master && git pull --rebase origin master && git checkout -b $2
|
26
|
+
expose = !git sync && git push origin `git current-branch`
|
27
|
+
pull-upstream = !git pull --rebase origin master && git checkout master
|
28
|
+
to-master = !export GIT_BRANCH=`git current-branch` && git pull-upstream && git merge $GIT_BRANCH && git push origin master
|
27
29
|
[apply]
|
28
30
|
whitespace = warn
|
29
31
|
[color]
|
data/config/vimrc
CHANGED
@@ -34,7 +34,7 @@ Bundle 'Shougo/neocomplcache'
|
|
34
34
|
Bundle 'mattn/webapi-vim'
|
35
35
|
Bundle 'mattn/gist-vim'
|
36
36
|
Bundle 'vim-scripts/sudo.vim'
|
37
|
-
Bundle '
|
37
|
+
Bundle 'skalnik/vim-vroom'
|
38
38
|
|
39
39
|
|
40
40
|
""
|
@@ -59,8 +59,8 @@ let mapleader = "," " Set leader key to something easier to access
|
|
59
59
|
"" Whitespace
|
60
60
|
""
|
61
61
|
|
62
|
-
set wrap " turn word wrap on
|
63
|
-
set textwidth=72 " attempt to enforce 72 chars
|
62
|
+
"set wrap " turn word wrap on
|
63
|
+
"set textwidth=72 " attempt to enforce 72 chars
|
64
64
|
set tabstop=2 " a tab is two spaces
|
65
65
|
set shiftwidth=2 " an autoindent (with <<) is two spaces
|
66
66
|
set expandtab " use spaces, not tabs
|
@@ -141,20 +141,8 @@ let macvim_hig_shift_movement = 1 " MacVim shift+arrow-keys behavior (required i
|
|
141
141
|
" Skip bullshit directories
|
142
142
|
let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated .sass-cache .git'
|
143
143
|
set grepprg=/bin/grep\ -nH
|
144
|
-
" Enforce Ruby 1.9 syntax
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
""
|
149
|
-
"" Testing
|
150
|
-
""
|
151
|
-
|
152
|
-
let g:rubytest_cmd_test = "rtest %p"
|
153
|
-
let g:rubytest_cmd_testcase = "rtest %p -n \'/%c/\'"
|
154
|
-
let g:rubytest_cmd_spec = "rspec --format=documentation %p"
|
155
|
-
let g:rubytest_cmd_example = "rspec --format=documentation %p -l '%c'"
|
156
|
-
let g:rubytest_cmd_feature = "cucumber %p"
|
157
|
-
let g:rubytest_cmd_story = "cucumber %p -n '%c'"
|
144
|
+
" Enforce Ruby 1.9 syntax on this line
|
145
|
+
map <leader>h :s/:\([a-z0-9_]\+\)\s*=>/\1: /g<cr>
|
158
146
|
|
159
147
|
|
160
148
|
""
|
@@ -194,6 +182,10 @@ augroup vimrcEx
|
|
194
182
|
|
195
183
|
" Strip whitespace in Python
|
196
184
|
autocmd BufWritePre *.py :%s/\s\+$//e
|
185
|
+
|
186
|
+
" Highlight certain files as Ruby
|
187
|
+
au BufNewFile,BufRead *.gemfile set filetype=ruby
|
188
|
+
au BufNewFile,BufRead *.rake set filetype=ruby
|
197
189
|
augroup END
|
198
190
|
|
199
191
|
" When there's no text behind it, tab indents. When there is, tab
|
@@ -252,63 +244,47 @@ set background=light
|
|
252
244
|
map <C-t> :CommandT<cr>
|
253
245
|
" Pressing ,ss will toggle and untoggle spell checking
|
254
246
|
map <leader>ss :setlocal spell!<cr>
|
255
|
-
|
256
|
-
"
|
257
|
-
|
247
|
+
|
248
|
+
" Remap :W => :w to avoid errors
|
249
|
+
command! W w
|
250
|
+
|
251
|
+
""
|
252
|
+
"" Inline Testing
|
253
|
+
""
|
254
|
+
|
255
|
+
let g:vroom_use_binstubs = 1
|
256
|
+
let g:vroom_use_colors = 1
|
257
|
+
let g:vroom_map_keys = 0
|
258
|
+
let g:vroom_spec_command = 'rspec --format=documentation '
|
259
|
+
let g:vroom_test_unit_command = 'bundle exec ruby -Itest '
|
260
|
+
"let g:vroom_test_unit_command = 'rtest '
|
261
|
+
|
262
|
+
nnoremap <leader>t :VroomRunNearestTest<cr>
|
263
|
+
nnoremap <leader>T :VroomRunTestFile<cr>
|
264
|
+
|
258
265
|
function! OpenTestAlternate()
|
259
266
|
let new_file = AlternateForCurrentFile()
|
260
267
|
exec ':e ' . new_file
|
261
268
|
endfunction
|
262
|
-
" Find the test or implementation code that corresponds with this file.
|
263
269
|
function! AlternateForCurrentFile()
|
264
|
-
let using_rspec = filereadable('spec/spec_helper.rb')
|
265
270
|
let current_file = expand("%")
|
266
271
|
let new_file = current_file
|
267
|
-
let
|
268
|
-
let
|
269
|
-
let in_app = match(current_file, '\<controllers\>') != -1 || match(current_file, '\<models\>') != -1 || match(current_file, '\<views\>') != -1 || match(current_file, '\<
|
270
|
-
|
271
|
-
if going_to_test
|
272
|
+
let in_spec = match(current_file, '^spec/') != -1
|
273
|
+
let going_to_spec_or_test = !in_spec
|
274
|
+
let in_app = match(current_file, '\<controllers\>') != -1 || match(current_file, '\<models\>') != -1 || match(current_file, '\<views\>') != -1 || match(current_file, '\<helpers\>') != -1
|
275
|
+
if going_to_spec
|
272
276
|
if in_app
|
273
277
|
let new_file = substitute(new_file, '^app/', '', '')
|
274
278
|
end
|
275
|
-
|
276
|
-
|
277
|
-
if using_rspec
|
278
|
-
let new_file = substitute(new_file, '\.rb$', '_spec.rb', '')
|
279
|
-
let new_file = 'spec/' . new_file
|
280
|
-
else
|
281
|
-
let new_file = substitute(new_file, '\.rb$', '_test.rb', '')
|
282
|
-
let new_file = 'test/' . new_file
|
283
|
-
let new_file = substitute(new_file, 'models', 'unit', '')
|
284
|
-
let new_file = substitute(new_file, 'support', 'unit', '')
|
285
|
-
let new_file = substitute(new_file, 'controllers', 'functional', '')
|
286
|
-
endif
|
279
|
+
let new_file = substitute(new_file, '\.rb$', '_spec.rb', '')
|
280
|
+
let new_file = 'spec/' . new_file
|
287
281
|
else
|
282
|
+
let new_file = substitute(new_file, '_spec\.rb$', '.rb', '')
|
283
|
+
let new_file = substitute(new_file, '^spec/', '', '')
|
288
284
|
if in_app
|
289
285
|
let new_file = 'app/' . new_file
|
290
286
|
end
|
291
|
-
|
292
|
-
if using_rspec
|
293
|
-
let new_file = substitute(new_file, '_spec\.rb$', '.rb', '')
|
294
|
-
let new_file = substitute(new_file, 'spec/', '', '')
|
295
|
-
else
|
296
|
-
let new_file = substitute(new_file, '_test\.rb$', '.rb', '')
|
297
|
-
let new_file = substitute(new_file, '^test/', '', '')
|
298
|
-
|
299
|
-
if match(new_file, 'support/')
|
300
|
-
let new_file = substitute(new_file, 'unit', 'support', '')
|
301
|
-
else
|
302
|
-
let new_file = substitute(new_file, 'unit', 'models', '')
|
303
|
-
endif
|
304
|
-
|
305
|
-
let new_file = substitute(new_file, 'functional', 'controllers', '')
|
306
|
-
endif
|
307
287
|
endif
|
308
288
|
return new_file
|
309
289
|
endfunction
|
310
290
|
nnoremap <leader>. :call OpenTestAlternate()<cr>
|
311
|
-
map <C-j> <leader>.
|
312
|
-
|
313
|
-
" Remap :W => :w to avoid errors
|
314
|
-
command! W w
|
data/config/zshenv
CHANGED
@@ -10,7 +10,7 @@ DOTS=$ZSH
|
|
10
10
|
# Domain-specific PATHs.
|
11
11
|
RBPATH=/usr/local/lib/ruby/gems/1.9.1/bin:/usr/local/Cellar/ruby/1.9.3-p327/bin
|
12
12
|
JSPATH=node_modules/.bin:/usr/local/share/npm/bin
|
13
|
-
PYPATH=/usr/local/Cellar/python/2.7.
|
13
|
+
PYPATH=/usr/local/Cellar/python/2.7.3/bin
|
14
14
|
GOPATH=$HOME/Code/Go
|
15
15
|
PGPATH=/Applications/Postgres.app/Contents/MacOS/bin
|
16
16
|
MANPATH=/opt/local/share/man:$MANPATH
|
data/lib/dots/aliases.zsh
CHANGED
@@ -48,7 +48,7 @@ alias krp='kill_first_ruby_process'
|
|
48
48
|
alias fs='foreman start'
|
49
49
|
alias reload='dots update'
|
50
50
|
|
51
|
-
alias guard='nocorrect guard --no-bundler-warning'
|
51
|
+
#alias guard='nocorrect guard --no-bundler-warning'
|
52
52
|
alias rspec='nocorrect rspec'
|
53
53
|
alias rain='nocorrect rain'
|
54
54
|
|
@@ -63,3 +63,5 @@ alias cfg='source .env'
|
|
63
63
|
|
64
64
|
# Just in case..
|
65
65
|
alias dots='nocorrect dots'
|
66
|
+
|
67
|
+
alias replace='gg_replace'
|
data/lib/dots/functions.zsh
CHANGED
@@ -90,3 +90,44 @@ function rhombus() {
|
|
90
90
|
function hidden_config_for() {
|
91
91
|
source "$DOTS/config/$1.zsh"
|
92
92
|
}
|
93
|
+
|
94
|
+
# Find and replace in a directory.
|
95
|
+
gg_replace() {
|
96
|
+
if [[ "$#" == "0" ]]; then
|
97
|
+
echo 'Usage:'
|
98
|
+
echo ' gg_replace term replacement file_mask'
|
99
|
+
echo
|
100
|
+
echo 'Example:'
|
101
|
+
echo ' gg_replace cappuchino cappuccino *.html'
|
102
|
+
echo
|
103
|
+
else
|
104
|
+
find=$1; shift
|
105
|
+
replace=$1; shift
|
106
|
+
|
107
|
+
ORIG_GLOBIGNORE=$GLOBIGNORE
|
108
|
+
GLOBIGNORE=*.*
|
109
|
+
|
110
|
+
if [[ "$#" = "0" ]]; then
|
111
|
+
set -- ' ' $@
|
112
|
+
fi
|
113
|
+
|
114
|
+
while [[ "$#" -gt "0" ]]; do
|
115
|
+
for file in `git grep -l $find -- $1`; do
|
116
|
+
sed -i -e "s/$find/$replace/g" -i'' $file
|
117
|
+
done
|
118
|
+
shift
|
119
|
+
done
|
120
|
+
|
121
|
+
GLOBIGNORE=$ORIG_GLOBIGNORE
|
122
|
+
fi
|
123
|
+
}
|
124
|
+
|
125
|
+
# Turn underscores into dashes.
|
126
|
+
gg_dasherize() {
|
127
|
+
gg_replace $1 `echo $1 | sed -e 's/_/-/g'` $2
|
128
|
+
}
|
129
|
+
|
130
|
+
# Wrap a Ruby binary in the global GEM_HOME.
|
131
|
+
function globalize() {
|
132
|
+
GEM_HOME=$GLOBAL_GEM_HOME $@
|
133
|
+
}
|
data/lib/ruby/dots/bootstrap.rb
CHANGED
@@ -25,7 +25,7 @@ module Dots
|
|
25
25
|
# Install the latest version of all gems to the global gemset. These
|
26
26
|
# gems are configured in +~/.Gemfile+.
|
27
27
|
def install_bundle
|
28
|
-
system "cd #{
|
28
|
+
system "cd && #{install_bundler} && #{install_global_gemset}"
|
29
29
|
end
|
30
30
|
|
31
31
|
# Install Python packages from pip. Pip!
|
@@ -38,26 +38,17 @@ module Dots
|
|
38
38
|
`which #{command}` != ""
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
|
43
|
-
"#{install_bundler} #{install_global_gemset}"
|
41
|
+
def install_bundler
|
42
|
+
"gem install bundler"
|
44
43
|
end
|
45
44
|
|
46
45
|
def install_global_gemset
|
47
|
-
"
|
48
|
-
end
|
49
|
-
|
50
|
-
def install_bundler
|
51
|
-
"gem install bundler"
|
46
|
+
"gem install #{Dots.gems}"
|
52
47
|
end
|
53
48
|
|
54
49
|
# Install the latest version of the Homebrew package manager.
|
55
50
|
def install_homebrew
|
56
51
|
%x[ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"]
|
57
52
|
end
|
58
|
-
|
59
|
-
def global_gemset
|
60
|
-
"#{Dots.root}/config/Gemfile"
|
61
|
-
end
|
62
53
|
end
|
63
54
|
end
|
data/lib/ruby/dots/command.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'dots/persistence'
|
2
2
|
require 'dots/installation'
|
3
3
|
require 'dots/bootstrap'
|
4
|
+
require 'dots/sanity'
|
4
5
|
|
5
6
|
module Dots
|
6
7
|
class Command < Thor
|
7
|
-
include Thor::Actions, Dots::Persistence, Dots::Installation, Dots::Bootstrap
|
8
|
+
include Thor::Actions, Dots::Persistence, Dots::Installation, Dots::Bootstrap, Dots::Sanity
|
8
9
|
default_task :usage
|
9
10
|
|
10
11
|
desc :usage, "Show usage information"
|
@@ -47,9 +48,10 @@ module Dots
|
|
47
48
|
install_programs and install_bundle and install
|
48
49
|
end
|
49
50
|
|
50
|
-
desc :
|
51
|
-
|
52
|
-
|
51
|
+
desc :robify, "Restore the shell to sane, sensible defaults."
|
52
|
+
method_option :edit, default: true
|
53
|
+
def robify
|
54
|
+
stop_being_insane! and (open_textmate if options[:edit])
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# = Dots::Sanity
|
2
|
+
#
|
3
|
+
# This module helps me pair program with others who may not enjoy the
|
4
|
+
# quirky nature of my personal setup. It restores the shell,
|
5
|
+
# destructively, to some saner defaults.
|
6
|
+
module Dots
|
7
|
+
module Sanity
|
8
|
+
include Thor::Actions
|
9
|
+
|
10
|
+
# Restore the shell to some more sensible defaults, and familiar
|
11
|
+
# aliases.
|
12
|
+
def stop_being_insane!
|
13
|
+
restore_to_sensible_defaults and say_farewell
|
14
|
+
end
|
15
|
+
|
16
|
+
# Open the current folder in TextMate.
|
17
|
+
def open_textmate
|
18
|
+
if textmate_installed?
|
19
|
+
system 'mate .'
|
20
|
+
else
|
21
|
+
say "Please install TextMate to open this folder sensibly."
|
22
|
+
exit 1
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def say_farewell
|
28
|
+
if $? == 0
|
29
|
+
true
|
30
|
+
else
|
31
|
+
say "There were errors robifying the shell.."
|
32
|
+
false
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def restore_to_sensible_defaults
|
37
|
+
commands = [
|
38
|
+
"bindkey -e",
|
39
|
+
"alias rbtest='nocorrect rtest_rake'",
|
40
|
+
"alias rbtest_exec='rtest_bare'"
|
41
|
+
]
|
42
|
+
restore_sensible_defaults = "zsh -c '#{commands.join(" && ")}'"
|
43
|
+
system restore_sensible_defaults
|
44
|
+
end
|
45
|
+
|
46
|
+
def textmate_installed?
|
47
|
+
`which mate` != ""
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/ruby/dots/version.rb
CHANGED
data/lib/ruby/dots.rb
CHANGED
@@ -7,8 +7,12 @@ require 'dots/command'
|
|
7
7
|
require 'dots/version'
|
8
8
|
require 'dots/persistence'
|
9
9
|
require 'dots/installation'
|
10
|
+
require 'dots/sanity'
|
10
11
|
|
11
12
|
module Dots
|
13
|
+
# All gems installed by DOTS
|
14
|
+
GEMS = %w(dots pv git_tracker rails)
|
15
|
+
|
12
16
|
# The root path of the DOTS gem.
|
13
17
|
def self.root
|
14
18
|
@root_dir ||= begin
|
@@ -40,5 +44,10 @@ module Dots
|
|
40
44
|
|
41
45
|
# The home directory for the current user.
|
42
46
|
HOME = ENV['HOME']
|
47
|
+
|
48
|
+
# Accessor for all gems installed by DOTS, formatted for a `gem install`.
|
49
|
+
def self.gems
|
50
|
+
GEMS.join " "
|
51
|
+
end
|
43
52
|
end
|
44
53
|
|
data/{bin → script}/stock
RENAMED
metadata
CHANGED
@@ -1,81 +1,74 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zsh_dots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.8
|
4
5
|
prerelease:
|
5
|
-
version: 0.5.7
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tom Scott
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
|
-
none: false
|
21
|
-
name: thor
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
25
26
|
requirements:
|
26
27
|
- - ! '>='
|
27
28
|
- !ruby/object:Gem::Version
|
28
29
|
version: '0'
|
29
|
-
none: false
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
31
|
+
name: activemodel
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
32
34
|
requirements:
|
33
35
|
- - ! '>='
|
34
36
|
- !ruby/object:Gem::Version
|
35
37
|
version: '0'
|
36
|
-
none: false
|
37
|
-
name: activemodel
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
41
42
|
requirements:
|
42
43
|
- - ! '>='
|
43
44
|
- !ruby/object:Gem::Version
|
44
45
|
version: '0'
|
45
|
-
none: false
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
48
50
|
requirements:
|
49
51
|
- - ! '>='
|
50
52
|
- !ruby/object:Gem::Version
|
51
53
|
version: '0'
|
52
|
-
none: false
|
53
|
-
name: rake
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
57
58
|
requirements:
|
58
59
|
- - ! '>='
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: '0'
|
61
|
-
none: false
|
62
62
|
description: DOTS is an advanced ZSH framework.
|
63
63
|
email:
|
64
64
|
- tubbo@psychedeli.ca
|
65
65
|
executables:
|
66
66
|
- dots
|
67
|
-
- elocal_nightly.sh
|
68
|
-
- gbrt
|
69
|
-
- git_cwd_info
|
70
|
-
- lein
|
71
|
-
- loggly
|
72
|
-
- reattach-to-user-namespace
|
73
|
-
- repl.sh
|
74
67
|
- ssh-copy-id
|
75
|
-
- stock
|
76
68
|
extensions: []
|
77
69
|
extra_rdoc_files: []
|
78
70
|
files:
|
71
|
+
- .bundle/config
|
79
72
|
- .gitignore
|
80
73
|
- .gitmodules
|
81
74
|
- Gemfile
|
@@ -83,16 +76,7 @@ files:
|
|
83
76
|
- README.md
|
84
77
|
- Rakefile
|
85
78
|
- bin/dots
|
86
|
-
- bin/elocal_nightly.sh
|
87
|
-
- bin/gbrt
|
88
|
-
- bin/git_cwd_info
|
89
|
-
- bin/lein
|
90
|
-
- bin/loggly
|
91
|
-
- bin/reattach-to-user-namespace
|
92
|
-
- bin/repl.sh
|
93
79
|
- bin/ssh-copy-id
|
94
|
-
- bin/stock
|
95
|
-
- config/Gemfile
|
96
80
|
- config/bundle/config
|
97
81
|
- config/example.aws.zsh
|
98
82
|
- config/gemrc
|
@@ -141,9 +125,11 @@ files:
|
|
141
125
|
- lib/ruby/dots/installation.rb
|
142
126
|
- lib/ruby/dots/installer.rb
|
143
127
|
- lib/ruby/dots/persistence.rb
|
128
|
+
- lib/ruby/dots/sanity.rb
|
144
129
|
- lib/ruby/dots/version.rb
|
145
130
|
- lib/ruby/templates/usage.txt.erb
|
146
131
|
- lib/tasks/.gitkeep
|
132
|
+
- script/stock
|
147
133
|
- spec/integration/command_spec.rb
|
148
134
|
- spec/models/dot_file_spec.rb
|
149
135
|
- spec/spec_helper.rb
|
@@ -160,17 +146,17 @@ rdoc_options: []
|
|
160
146
|
require_paths:
|
161
147
|
- lib/ruby
|
162
148
|
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
163
150
|
requirements:
|
164
151
|
- - ! '>='
|
165
152
|
- !ruby/object:Gem::Version
|
166
153
|
version: '0'
|
167
|
-
none: false
|
168
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
169
156
|
requirements:
|
170
157
|
- - ! '>='
|
171
158
|
- !ruby/object:Gem::Version
|
172
159
|
version: '0'
|
173
|
-
none: false
|
174
160
|
requirements: []
|
175
161
|
rubyforge_project:
|
176
162
|
rubygems_version: 1.8.23
|
data/bin/elocal_nightly.sh
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
#!/bin/zsh
|
2
|
-
#
|
3
|
-
# Nightly database import script for eLocal.com.
|
4
|
-
|
5
|
-
# Download the latest database from our backup server
|
6
|
-
cd /Users/tom/Code/elocal/
|
7
|
-
bundle exec thor db:import:production
|
8
|
-
|
9
|
-
# Index the new data with Solr
|
10
|
-
bundle exec thor solr:index_accounts
|
11
|
-
bundle exec thor solr:index_profiles
|
12
|
-
bundle exec thor solr:index_categories
|
13
|
-
|
14
|
-
# Send a confirmation email when everything is done
|
15
|
-
EMAIL="tubbo@psychedeli.ca"
|
16
|
-
SUBJECT="Imported the production database to playa."
|
17
|
-
MESSAGE="db:import:production has been run, and the database has been delivered to your local development machine."
|
18
|
-
echo "To: $EMAIL\nSubject:$SUBJECT\nContent-Type:text/plain;charset="us-ascii"\n\n$MESSAGE" | sendmail -t
|
data/bin/gbrt
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
def format_commit_info timestamp, time_desc, commit_id, message, ref_name
|
4
|
-
[
|
5
|
-
"#{timestamp.strftime("%y %b %d")}, #{timestamp.strftime("%l:%M%p").downcase}",
|
6
|
-
"(#{time_desc})",
|
7
|
-
commit_id,
|
8
|
-
message,
|
9
|
-
ref_name
|
10
|
-
]
|
11
|
-
end
|
12
|
-
|
13
|
-
def render_commit_info timestamp, time_desc, commit_id, message, ref_name, merged
|
14
|
-
[
|
15
|
-
timestamp,
|
16
|
-
time_desc,
|
17
|
-
"\e[32m#{ref_name}\e[0m",
|
18
|
-
(merged ? " #{commit_id}" : "+ \e[33m#{commit_id}\e[0m"),
|
19
|
-
"\e[#{message[/^Temp/] ? 31 : 90}m#{message.strip}\e[0m"
|
20
|
-
].join(' ')
|
21
|
-
end
|
22
|
-
|
23
|
-
commit_info = `git branch #{ARGV.join(' ')} | cut -c 3-`.strip.split("\n").reject {|ref_name|
|
24
|
-
ref_name[' -> ']
|
25
|
-
}.map {|ref_name|
|
26
|
-
`git log --no-walk --pretty=format:"%ct\n%cr\n%h\n%s" '#{ref_name}' --`.strip.split("\n").push(ref_name)
|
27
|
-
}.map {|commit_info|
|
28
|
-
[Time.at(commit_info.shift.to_i)].concat(commit_info)
|
29
|
-
}.sort_by {|commit_info|
|
30
|
-
commit_info.first # unix timestamp
|
31
|
-
}.reverse.map {|commit_info|
|
32
|
-
format_commit_info(*commit_info)
|
33
|
-
}.transpose.map {|column|
|
34
|
-
max_col_length = column.sort_by {|i| i.length }.last.length
|
35
|
-
column.map {|i| i.ljust(max_col_length) }
|
36
|
-
}.transpose.map {|commit_info|
|
37
|
-
commit_info.push(
|
38
|
-
`git merge-base HEAD #{commit_info[2]}`.chomp[0...7] == commit_info[2]
|
39
|
-
)
|
40
|
-
}.each {|commit_info|
|
41
|
-
puts render_commit_info(*commit_info)
|
42
|
-
}
|
data/bin/git_cwd_info
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# -*- coding: utf-8 -*-
|
3
|
-
|
4
|
-
# The methods that get called more than once are memoized.
|
5
|
-
|
6
|
-
def git_repo_path
|
7
|
-
@git_repo_path ||= `git rev-parse --git-dir 2>/dev/null`.strip
|
8
|
-
end
|
9
|
-
|
10
|
-
def in_git_repo
|
11
|
-
!git_repo_path.empty? &&
|
12
|
-
git_repo_path != '~' &&
|
13
|
-
git_repo_path != "#{ENV['HOME']}/.git"
|
14
|
-
end
|
15
|
-
|
16
|
-
def git_parse_branch
|
17
|
-
@git_parse_branch ||= File.read("#{git_repo_path}/HEAD").strip.scan(/(?<=refs\/heads\/).*$/).first
|
18
|
-
end
|
19
|
-
|
20
|
-
def git_head_commit_id
|
21
|
-
`git rev-parse --short HEAD 2>/dev/null`.strip
|
22
|
-
end
|
23
|
-
|
24
|
-
def git_cwd_dirty
|
25
|
-
" %{\e[90m%}✗%{\e[0m%}" unless git_repo_path == '.' || `git ls-files -m`.strip.empty?
|
26
|
-
end
|
27
|
-
|
28
|
-
def rebasing_etc
|
29
|
-
if File.exists?(File.join(git_repo_path, 'BISECT_LOG'))
|
30
|
-
"+bisect"
|
31
|
-
elsif File.exists?(File.join(git_repo_path, 'MERGE_HEAD'))
|
32
|
-
"+merge"
|
33
|
-
elsif %w[rebase rebase-apply rebase-merge ../.dotest].any? {|d| File.exists?(File.join(git_repo_path, d)) }
|
34
|
-
"+rebase"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
if in_git_repo
|
39
|
-
print " %{$fg[cyan]%}#{git_parse_branch}%{$reset_color_with_bg%}@%{$fg[violet]%}#{git_head_commit_id}%{$reset_color_with_bg%}#{rebasing_etc}#{git_cwd_dirty}"
|
40
|
-
end
|
data/bin/lein
DELETED
@@ -1,229 +0,0 @@
|
|
1
|
-
#!/bin/bash
|
2
|
-
|
3
|
-
export LEIN_VERSION="2.0.0-preview6"
|
4
|
-
|
5
|
-
case $LEIN_VERSION in
|
6
|
-
*SNAPSHOT) SNAPSHOT="YES" ;;
|
7
|
-
*) SNAPSHOT="NO" ;;
|
8
|
-
esac
|
9
|
-
|
10
|
-
if [ `id -u` -eq 0 ] && [ "$LEIN_ROOT" = "" ]; then
|
11
|
-
echo "WARNING: You're currently running as root; probably by accident."
|
12
|
-
echo "Press control-C to abort or Enter to continue as root."
|
13
|
-
echo "Set LEIN_ROOT to disable this warning."
|
14
|
-
read _
|
15
|
-
fi
|
16
|
-
|
17
|
-
NOT_FOUND=1
|
18
|
-
ORIGINAL_PWD="$PWD"
|
19
|
-
while [ ! -r "$PWD/project.clj" ] && [ "$PWD" != "/" ] && [ $NOT_FOUND -ne 0 ]
|
20
|
-
do
|
21
|
-
cd ..
|
22
|
-
if [ "$(dirname "$PWD")" = "/" ]; then
|
23
|
-
NOT_FOUND=0
|
24
|
-
cd "$ORIGINAL_PWD"
|
25
|
-
fi
|
26
|
-
done
|
27
|
-
|
28
|
-
export LEIN_HOME=${LEIN_HOME:-"$HOME/.lein"}
|
29
|
-
|
30
|
-
if [ "$OSTYPE" = "cygwin" ]; then
|
31
|
-
export LEIN_HOME=`cygpath -w $LEIN_HOME`
|
32
|
-
fi
|
33
|
-
|
34
|
-
LEIN_JAR="$LEIN_HOME/self-installs/leiningen-$LEIN_VERSION-standalone.jar"
|
35
|
-
|
36
|
-
# normalize $0 on certain BSDs
|
37
|
-
if [ "$(dirname "$0")" = "." ]; then
|
38
|
-
SCRIPT="$(which $(basename "$0"))"
|
39
|
-
else
|
40
|
-
SCRIPT="$0"
|
41
|
-
fi
|
42
|
-
|
43
|
-
# resolve symlinks to the script itself portably
|
44
|
-
while [ -h "$SCRIPT" ] ; do
|
45
|
-
ls=`ls -ld "$SCRIPT"`
|
46
|
-
link=`expr "$ls" : '.*-> \(.*\)$'`
|
47
|
-
if expr "$link" : '/.*' > /dev/null; then
|
48
|
-
SCRIPT="$link"
|
49
|
-
else
|
50
|
-
SCRIPT="$(dirname "$SCRIPT"$)/$link"
|
51
|
-
fi
|
52
|
-
done
|
53
|
-
|
54
|
-
BIN_DIR="$(dirname "$SCRIPT")"
|
55
|
-
|
56
|
-
if [ -r "$BIN_DIR/../src/leiningen/version.clj" ]; then
|
57
|
-
# Running from source checkout
|
58
|
-
LEIN_DIR="$(dirname "$BIN_DIR")"
|
59
|
-
|
60
|
-
# Need to use lein 1.x to bootstrap the leiningen-core library (for aether)
|
61
|
-
if [ "$(ls $LEIN_DIR/leiningen-core/lib/*)" = "" ]; then
|
62
|
-
echo "Leiningen is missing its dependencies."
|
63
|
-
echo "Please see \"Building\" in the README."
|
64
|
-
exit 1
|
65
|
-
fi
|
66
|
-
|
67
|
-
# If project.clj for lein or leiningen-core changes, we must recalculate
|
68
|
-
LAST_PROJECT_CHECKSUM=$(cat "$LEIN_DIR/.lein-project-checksum" 2> /dev/null)
|
69
|
-
PROJECT_CHECKSUM=$(sum "$LEIN_DIR/project.clj" "$LEIN_DIR/leiningen-core/project.clj")
|
70
|
-
if [ "$PROJECT_CHECKSUM" != "$LAST_PROJECT_CHECKSUM" ]; then
|
71
|
-
if [ -r "$LEIN_DIR/.lein-classpath" ]; then
|
72
|
-
rm "$LEIN_DIR/.lein-classpath"
|
73
|
-
fi
|
74
|
-
fi
|
75
|
-
|
76
|
-
# Use bin/lein to calculate its own classpath since src/ and
|
77
|
-
# leiningen-core/lib/*jar suffices to run the classpath task.
|
78
|
-
if [ ! -r "$LEIN_DIR/.lein-classpath" ] && [ "$1" != "classpath" ]; then
|
79
|
-
echo "Recalculating Leiningen's classpath."
|
80
|
-
ORIG_PWD="$PWD"
|
81
|
-
cd "$LEIN_DIR"
|
82
|
-
|
83
|
-
$0 classpath .lein-classpath
|
84
|
-
sum $LEIN_DIR/project.clj $LEIN_DIR/leiningen-core/project.clj > \
|
85
|
-
.lein-project-checksum
|
86
|
-
cd "$ORIG_PWD"
|
87
|
-
fi
|
88
|
-
|
89
|
-
mkdir -p "$LEIN_DIR/target/classes"
|
90
|
-
export LEIN_JVM_OPTS=${LEIN_JVM_OPTS:-"-Dclojure.compile.path=$LEIN_DIR/target/classes"}
|
91
|
-
CLASSPATH="$LEIN_DIR/leiningen-core/src/"
|
92
|
-
CLASSPATH="$CLASSPATH:$LEIN_DIR/leiningen-core/resources/"
|
93
|
-
CLASSPATH="$CLASSPATH:$(cat $LEIN_DIR/.lein-classpath 2> /dev/null)"
|
94
|
-
CLASSPATH="$CLASSPATH:$LEIN_DIR/leiningen-core/lib/*"
|
95
|
-
CLASSPATH="$CLASSPATH:$LEIN_DIR/test:$LEIN_DIR/target/classes"
|
96
|
-
CLASSPATH="$CLASSPATH:$LEIN_DIR/src:$LEIN_DIR/resources:$LEIN_JAR"
|
97
|
-
if [ -f .lein-classpath ]; then
|
98
|
-
CLASSPATH="`cat .lein-classpath`:$CLASSPATH"
|
99
|
-
fi
|
100
|
-
else # Not running from a checkout
|
101
|
-
# apply context specific CLASSPATH entries
|
102
|
-
if [ -f .lein-classpath ]; then
|
103
|
-
CLASSPATH="`cat .lein-classpath`:$LEIN_JAR"
|
104
|
-
else
|
105
|
-
CLASSPATH="$LEIN_JAR"
|
106
|
-
fi
|
107
|
-
|
108
|
-
export LEIN_JVM_OPTS=${LEIN_JVM_OPTS:-"-Xbootclasspath/a:$LEIN_JAR"}
|
109
|
-
|
110
|
-
if [ ! -r "$LEIN_JAR" -a "$1" != "self-install" ]; then
|
111
|
-
"$0" self-install
|
112
|
-
fi
|
113
|
-
fi
|
114
|
-
|
115
|
-
HTTP_CLIENT=${HTTP_CLIENT:-"wget -O"}
|
116
|
-
if type -p curl >/dev/null 2>&1; then
|
117
|
-
if [ "$https_proxy" != "" ]; then
|
118
|
-
CURL_PROXY="-x $https_proxy"
|
119
|
-
fi
|
120
|
-
HTTP_CLIENT="curl $CURL_PROXY -f -L -o"
|
121
|
-
fi
|
122
|
-
|
123
|
-
export JAVA_CMD=${JAVA_CMD:-"java"}
|
124
|
-
export LEIN_JAVA_CMD=${LEIN_JAVA_CMD:-$JAVA_CMD}
|
125
|
-
|
126
|
-
# Support $JAVA_OPTS for backwards-compatibility.
|
127
|
-
export JVM_OPTS="${JVM_OPTS:-"$JAVA_OPTS"}"
|
128
|
-
|
129
|
-
# TODO: investigate http://skife.org/java/unix/2011/06/20/really_executable_jars.html
|
130
|
-
# If you're packaging this for a package manager (.deb, homebrew, etc)
|
131
|
-
# you need to remove the self-install and upgrade functionality or see lein-pkg.
|
132
|
-
if [ "$1" = "self-install" ]; then
|
133
|
-
if [ -r "$LEIN_JAR" ]; then
|
134
|
-
echo "The self-install jar already exists at $LEIN_JAR."
|
135
|
-
echo "If you wish to re-download, delete it and rerun \"$0 self-install\"."
|
136
|
-
exit 1
|
137
|
-
fi
|
138
|
-
echo "Downloading Leiningen now..."
|
139
|
-
LEIN_DIR=`dirname "$LEIN_JAR"`
|
140
|
-
mkdir -p "$LEIN_DIR"
|
141
|
-
LEIN_URL="https://github.com/downloads/technomancy/leiningen/leiningen-$LEIN_VERSION-standalone.jar"
|
142
|
-
$HTTP_CLIENT "$LEIN_JAR" "$LEIN_URL"
|
143
|
-
if [ $? != 0 ]; then
|
144
|
-
echo "Failed to download $LEIN_URL"
|
145
|
-
echo "If you have an old version of libssl you may not have the correct"
|
146
|
-
echo "certificate authority. Either upgrade or set HTTP_CLIENT to insecure:"
|
147
|
-
echo " export HTTP_CLIENT=\"wget --no-check-certificate -O\" # or"
|
148
|
-
echo " export HTTP_CLIENT=\"curl --insecure -f -L -o"
|
149
|
-
if [ $SNAPSHOT = "YES" ]; then
|
150
|
-
echo "If you have Maven installed, you can do"
|
151
|
-
echo "mvn dependency:copy-dependencies; mv target/dependency lib"
|
152
|
-
echo "See README.md for further SNAPSHOT build instructions."
|
153
|
-
fi
|
154
|
-
rm $LEIN_JAR 2> /dev/null
|
155
|
-
exit 1
|
156
|
-
fi
|
157
|
-
elif [ "$1" = "upgrade" ]; then
|
158
|
-
if [ "$LEIN_DIR" != "" ]; then
|
159
|
-
echo "The upgrade task is not meant to be run from a checkout."
|
160
|
-
exit 1
|
161
|
-
fi
|
162
|
-
if [ $SNAPSHOT = "YES" ]; then
|
163
|
-
echo "The upgrade task is only meant for stable releases."
|
164
|
-
echo "See the \"Hacking\" section of the README."
|
165
|
-
exit 1
|
166
|
-
fi
|
167
|
-
if [ ! -w "$SCRIPT" ]; then
|
168
|
-
echo "You do not have permission to upgrade the installation in $SCRIPT"
|
169
|
-
exit 1
|
170
|
-
else
|
171
|
-
TARGET_VERSION="${2:-"preview"}"
|
172
|
-
echo "The script at $SCRIPT will be upgraded to the latest $TARGET_VERSION version."
|
173
|
-
echo -n "Do you want to continue [Y/n]? "
|
174
|
-
read RESP
|
175
|
-
case "$RESP" in
|
176
|
-
y|Y|"")
|
177
|
-
echo
|
178
|
-
echo "Upgrading..."
|
179
|
-
TARGET="/tmp/lein-$$-upgrade"
|
180
|
-
if ["$OSTYPE" = "cygwin" ]; then
|
181
|
-
TARGET=`cygpath -w $TARGET`
|
182
|
-
fi
|
183
|
-
LEIN_SCRIPT_URL="https://github.com/technomancy/leiningen/raw/$TARGET_VERSION/bin/lein"
|
184
|
-
$HTTP_CLIENT "$TARGET" "$LEIN_SCRIPT_URL" \
|
185
|
-
&& mv "$TARGET" "$SCRIPT" \
|
186
|
-
&& chmod +x "$SCRIPT" \
|
187
|
-
&& echo && "$SCRIPT" self-install && echo && echo "Now running" `$SCRIPT version`
|
188
|
-
exit $?;;
|
189
|
-
*)
|
190
|
-
echo "Aborted."
|
191
|
-
exit 1;;
|
192
|
-
esac
|
193
|
-
fi
|
194
|
-
else
|
195
|
-
if [ "$OSTYPE" = "cygwin" ]; then
|
196
|
-
# When running on Cygwin, use Windows-style paths for java
|
197
|
-
ORIGINAL_PWD=`cygpath -w "$ORIGINAL_PWD"`
|
198
|
-
CLASSPATH=`cygpath -wp "$CLASSPATH"`
|
199
|
-
fi
|
200
|
-
|
201
|
-
if [ $DEBUG ]; then
|
202
|
-
echo "Classpath: $CLASSPATH"
|
203
|
-
fi
|
204
|
-
|
205
|
-
TRAMPOLINE_FILE="/tmp/lein-trampoline-$$"
|
206
|
-
if [ "$OSTYPE" = "cygwin" ]; then
|
207
|
-
TRAMPOLINE_FILE=`cygpath -w $TRAMPOLINE_FILE`
|
208
|
-
fi
|
209
|
-
|
210
|
-
$LEIN_JAVA_CMD \
|
211
|
-
-client -XX:+TieredCompilation \
|
212
|
-
$LEIN_JVM_OPTS \
|
213
|
-
-Dfile.encoding=UTF-8 \
|
214
|
-
-Dmaven.wagon.http.ssl.easy=false \
|
215
|
-
-Dleiningen.original.pwd="$ORIGINAL_PWD" \
|
216
|
-
-Dleiningen.trampoline-file=$TRAMPOLINE_FILE \
|
217
|
-
-cp "$CLASSPATH" \
|
218
|
-
clojure.main -m leiningen.core.main "$@"
|
219
|
-
|
220
|
-
EXIT_CODE=$?
|
221
|
-
|
222
|
-
if [ -r $TRAMPOLINE_FILE ]; then
|
223
|
-
TRAMPOLINE="$(cat $TRAMPOLINE_FILE)"
|
224
|
-
rm $TRAMPOLINE_FILE
|
225
|
-
exec sh -c "exec $TRAMPOLINE"
|
226
|
-
else
|
227
|
-
exit $EXIT_CODE
|
228
|
-
fi
|
229
|
-
fi
|
data/bin/loggly
DELETED
@@ -1,166 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python
|
2
|
-
|
3
|
-
"""
|
4
|
-
Loggly CLI interface - standalone (Just Python). Deals with paging results automatically so you can easily grab >2000 rows.
|
5
|
-
|
6
|
-
Run `loggly.py --help` to see usage information.
|
7
|
-
|
8
|
-
TODO:
|
9
|
-
* Support XML format results (ie. combining multiple pages of results together)
|
10
|
-
* Facet support
|
11
|
-
|
12
|
-
Rob Coup - @amatix - robert.coup@koordinates.com
|
13
|
-
|
14
|
-
-------
|
15
|
-
|
16
|
-
Copyright (c) 2012, Robert Coup
|
17
|
-
All rights reserved.
|
18
|
-
|
19
|
-
Redistribution and use in source and binary forms, with or without
|
20
|
-
modification, are permitted provided that the following conditions are met:
|
21
|
-
|
22
|
-
1. Redistributions of source code must retain the above copyright notice, this
|
23
|
-
list of conditions and the following disclaimer.
|
24
|
-
2. Redistributions in binary form must reproduce the above copyright notice,
|
25
|
-
this list of conditions and the following disclaimer in the documentation
|
26
|
-
and/or other materials provided with the distribution.
|
27
|
-
|
28
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
29
|
-
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
30
|
-
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
31
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
32
|
-
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
33
|
-
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
34
|
-
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
35
|
-
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
36
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
37
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
38
|
-
|
39
|
-
The views and conclusions contained in the software and documentation are those
|
40
|
-
of the authors and should not be interpreted as representing official policies,
|
41
|
-
either expressed or implied, of the FreeBSD Project.
|
42
|
-
"""
|
43
|
-
|
44
|
-
from optparse import OptionParser
|
45
|
-
import urllib
|
46
|
-
import urllib2
|
47
|
-
import os
|
48
|
-
import json
|
49
|
-
import sys
|
50
|
-
import time
|
51
|
-
|
52
|
-
|
53
|
-
def main():
|
54
|
-
parser = OptionParser("Usage: %prog [options] SEARCH_QUERY")
|
55
|
-
|
56
|
-
parser.add_option("--username", help="Loggly username. Or specify via LOGGLY_USERNAME environment variable")
|
57
|
-
parser.add_option("--password", help="Loggly password. Or specify via LOGGLY_PASSWORD")
|
58
|
-
parser.add_option("--subdomain", help="Loggly subdomain (eg. foo). Or specify via LOGGLY_SUBDOMAIN")
|
59
|
-
|
60
|
-
parser.add_option("--from", help="Start time for the search.", default="NOW-24HOURS", dest="start")
|
61
|
-
parser.add_option("--to", help="End time for the search.", default="NOW", dest="end")
|
62
|
-
parser.add_option("--format", help="Output format, either 'json', 'xml', 'csv', or 'text'.", choices=('text', 'json', 'csv', 'xml'), default="text")
|
63
|
-
parser.add_option("--order", help="Direction of results returned, either 'asc' or 'desc'.", choices=('asc', 'desc'), default="asc")
|
64
|
-
|
65
|
-
# search API
|
66
|
-
parser.add_option("--rows", help="Number of rows returned by search. 0 will get all matching rows via paging.", type="int", default=0)
|
67
|
-
|
68
|
-
options, args = parser.parse_args()
|
69
|
-
|
70
|
-
if len(args) != 1:
|
71
|
-
parser.error("Need to specify SEARCH_QUERY as one argument")
|
72
|
-
|
73
|
-
if not options.username and 'LOGGLY_USERNAME' in os.environ:
|
74
|
-
options.username = os.environ['LOGGLY_USERNAME']
|
75
|
-
if not options.password and 'LOGGLY_PASSWORD' in os.environ:
|
76
|
-
options.password = os.environ['LOGGLY_PASSWORD']
|
77
|
-
if not options.subdomain and 'LOGGLY_SUBDOMAIN' in os.environ:
|
78
|
-
options.subdomain = os.environ['LOGGLY_SUBDOMAIN']
|
79
|
-
|
80
|
-
if not options.username:
|
81
|
-
parser.error("Need to specify either LOGGLY_USERNAME or --username")
|
82
|
-
if not options.password:
|
83
|
-
parser.error("Need to specify either LOGGLY_PASSWORD or --password")
|
84
|
-
if not options.subdomain:
|
85
|
-
parser.error("Need to specify either LOGGLY_SUBDOMAIN or --subdomain")
|
86
|
-
|
87
|
-
url = "https://%s.loggly.com/api/search/" % options.subdomain
|
88
|
-
|
89
|
-
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
|
90
|
-
password_mgr.add_password(None, url, options.username, options.password)
|
91
|
-
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
|
92
|
-
opener = urllib2.build_opener(handler)
|
93
|
-
|
94
|
-
if options.rows > 2000 or options.rows <= 0:
|
95
|
-
target_rows = None if options.rows <= 0 else options.rows
|
96
|
-
rows = 2000
|
97
|
-
paging = True
|
98
|
-
else:
|
99
|
-
rows = options.rows
|
100
|
-
paging = False
|
101
|
-
|
102
|
-
params = {
|
103
|
-
'q': args[0],
|
104
|
-
'from': options.start,
|
105
|
-
'until': options.end,
|
106
|
-
'format': options.format,
|
107
|
-
'order': options.order,
|
108
|
-
'rows': rows,
|
109
|
-
'start': 0,
|
110
|
-
}
|
111
|
-
|
112
|
-
results = None
|
113
|
-
while True:
|
114
|
-
req_url = url + '?' + urllib.urlencode(params)
|
115
|
-
print >>sys.stderr, req_url
|
116
|
-
try:
|
117
|
-
resp = opener.open(req_url)
|
118
|
-
except Exception, e:
|
119
|
-
print >>sys.stderr, "\t%s -- retrying" % repr(e)
|
120
|
-
time.sleep(3)
|
121
|
-
resp = opener.open(req_url)
|
122
|
-
|
123
|
-
result_count = 0
|
124
|
-
if options.format in ('csv', 'text'):
|
125
|
-
# can stream the output
|
126
|
-
for line in resp:
|
127
|
-
if len(line) > 1:
|
128
|
-
result_count += 1
|
129
|
-
print line,
|
130
|
-
elif options.format == 'json':
|
131
|
-
# merge JSON result pages in.
|
132
|
-
r_this = json.load(resp)
|
133
|
-
result_count += len(r_this['data'])
|
134
|
-
if results is None:
|
135
|
-
results = r_this
|
136
|
-
else:
|
137
|
-
results['data'] += r_this['data']
|
138
|
-
elif options.format == 'xml':
|
139
|
-
# TODO: merge XML result pages together
|
140
|
-
print resp.read()
|
141
|
-
raise NotImplementedError("TODO: implement XML-format result paging")
|
142
|
-
|
143
|
-
if paging:
|
144
|
-
if target_rows:
|
145
|
-
got = params['start'] + result_count
|
146
|
-
if got >= target_rows:
|
147
|
-
# got the target number of rows
|
148
|
-
break
|
149
|
-
params['rows'] += min(2000, target_rows - got)
|
150
|
-
elif result_count == 0:
|
151
|
-
# no more results
|
152
|
-
break
|
153
|
-
params['start'] += 2000
|
154
|
-
else:
|
155
|
-
# no paging, just get required
|
156
|
-
break
|
157
|
-
|
158
|
-
if options.format == 'json':
|
159
|
-
json.dump(results, sys.stdout, indent=2)
|
160
|
-
sys.stdout.write("\n")
|
161
|
-
elif options.format == 'xml':
|
162
|
-
# TODO: output combined XML results
|
163
|
-
raise NotImplementedError("TODO: implement XML-format result paging")
|
164
|
-
|
165
|
-
if __name__ == "__main__":
|
166
|
-
main()
|
Binary file
|
data/bin/repl.sh
DELETED
data/config/Gemfile
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# A global collection of gems that are used in all dirs.
|
2
|
-
#
|
3
|
-
# Add gems here to be included on the whole system.
|
4
|
-
|
5
|
-
source :rubygems
|
6
|
-
|
7
|
-
group :version_control do
|
8
|
-
gem 'git_tracker'
|
9
|
-
gem 'git-process'
|
10
|
-
end
|
11
|
-
|
12
|
-
group :development_tools do
|
13
|
-
gem 'rails'
|
14
|
-
gem 'pv'
|
15
|
-
end
|
16
|
-
|
17
|
-
group :configuration_management do
|
18
|
-
gem 'zsh_dots' # keep up to date with the latest version
|
19
|
-
end
|