tanjun 0.0.1.alpha3 → 0.0.1.alpha4

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/.gitignore CHANGED
@@ -15,3 +15,7 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .*.sw[a-z]
19
+ *.un~
20
+ Session.vim
21
+
@@ -1,25 +1,33 @@
1
1
  #!/bin/bash
2
- # This file can be run directly from Github with:
3
- # curl -L http://bit.ly/tanjun-bootstrap | bash -s
2
+ # This script can be run directly from Github with:
3
+ # curl -L http://bit.ly/tanjun-bootstrap | bash -s
4
+ #
5
+ # This script installs all rvm/ruby/nginx/passenger dependencies and a few
6
+ # useful applications. It also installs rvm, the latest ruby-mri, the tanjun
7
+ # gem and runs the the tanjun installer.
4
8
 
5
- applications="vim google-chrome-stable git"
6
- dependencies="build-essential openssl libreadline6 libreadline6-dev "\
7
- "zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev "\
8
- "sqlite3 libxml2-dev libxslt1-dev autoconf libc6-dev "\
9
- "libncurses-dev automake libtool bison subversion"
10
- gems="bundler passenger hub rails"
9
+ apps="vim google-chrome-stable"
10
+ rvm_dep="build-essential openssl libreadline6 libreadline6-dev curl "\
11
+ "git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 "\
12
+ "libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool "\
13
+ "bison subversion"
14
+ nginx_dep="libcurl4-openssl-dev"
11
15
 
12
16
  # Install package repositories
13
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
14
- sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
17
+ curl -L https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
18
+ sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google.list'
15
19
  sudo apt-get update
16
20
 
17
21
  # Install applications and dependencies
18
- sudo apt-get install --force-yes --yes $dependencies $applications
22
+ sudo apt-get install --force-yes --yes $dependencies
19
23
 
20
24
  # Install RVM
21
25
  curl -L get.rvm.io | bash -s stable --ruby
22
- source "$HOME/.rvm/scripts/rvm"
23
- gem install $gems
24
- gem install tanjun --pre
26
+ source "$HOME/.bashrc"
27
+
28
+ # Install and run Tanjun
29
+ gem install tanjun --no-ri --no-rdoc
25
30
  tanjun install
31
+
32
+ echo "Now reload your shell or run:"
33
+ echo " source ~/.bashrc"
data/bin/tanjun CHANGED
@@ -1,88 +1,109 @@
1
1
  #!/usr/bin/env ruby
2
- require 'tanjun'
2
+ require 'kwalify'
3
+ require 'hashie'
3
4
 
4
5
  module Tanjun
5
- class Tanjun < Thor
6
- include Thor::Actions
6
+ class Tanjun < Thor
7
+ include Thor::Actions
7
8
 
8
- def self.source_root
9
- @source ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
10
- end
9
+ def self.source_root
10
+ @source ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
11
+ end
11
12
 
12
- desc "install", "installs Tanjun"
13
- def install
14
- self.destination_root = File.expand_path("~")
13
+ desc "install", "installs Tanjun"
14
+ def install
15
+ self.destination_root = File.expand_path("~")
15
16
 
16
- ['projects', 'bin'].each do |path|
17
- empty_directory path
18
- end
17
+ config = "tanjun.yml"
18
+ config_root = file_exists?(config) ? destination_root : source_root
19
+ config = File.join(config_root, config)
19
20
 
20
- bash_profile = '[[ -s "$HOME/.bashrc" ]] && source "$HOME/.bashrc"'
21
- bashrc = '[[ -s "$HOME/.tanjun_profile" ]] && source "$HOME/.tanjun_profile"'
22
- bashrc_flag = '[ -z "$PS1" ] && return'
21
+ @options = Kwalify::Yaml.load(ERB.new(File.read(config)).result)
23
22
 
24
- add_to_file ".bash_profile", bash_profile
25
- if add_to_file ".bashrc", bashrc
26
- if add_to_file ".bashrc", 'if [[ -n "$PS1" ]]; then', bashrc_flag, force: true, quiet: true
27
- add_to_file ".bashrc", 'fi', nil, force: true, quiet: true
28
- end
29
- end
23
+ schema_file = "#{source_root}/tanjun_schema.yml"
24
+ if File.exists? schema_file
25
+ schema = Kwalify::Yaml.load_file(schema_file)
26
+ validator = Kwalify::Validator.new(schema)
27
+
28
+ errors = validator.validate(@options)
30
29
 
31
- path = "#{destination_root}/bin/hub"
32
- command = "hub hub standalone > #{path} && chmod 755 #{path}"
33
- run_with_conflict_check(path, command)
34
-
35
- path = "/opt/nginx/tanjun"
36
- command = "rvmsudo passenger-install-nginx-module --auto --auto-download --prefix=#{path}"
37
- run_with_conflict_check(path, command)
38
-
39
- path = "/etc/init.d/nginx"
40
- command = "sudo curl -L -o /etc/init.d/nginx http://bit.ly/nginx-ubuntu-init-file && sudo chown root:root /etc/init.d/nginx && sudo chmod '/etc/init.d/nginx' 0755 && sudo update-rc.d nginx defaults"
41
- run_with_conflict_check(path, command)
42
-
43
- gitconfig = {
44
- name: { key: 'user.name', prompt: 'Full Name', value: nil },
45
- email: { key: 'user.email', prompt: 'Email Address', value: nil },
46
- user: { key: 'github.user', prompt: 'Github Username', value: nil },
47
- token: { key: 'github.token', prompt: 'Github Token', value: nil },
48
- ignore: { key: 'core.excludesfile', value: '~/.gitignore' },
49
- color: { key: 'color.gui', value: 'true' }
50
- }
51
-
52
- gitconfig.each do |name, setting|
53
- setting[:value] ||= run "git config --global #{setting[:key]}", verbose: false, capture: true
54
- if setting[:value].to_s.strip.length == 0
55
- while setting[:value].to_s.strip.length == 0
56
- setting[:value] = ask "#{setting[:prompt]}: "
57
- if setting[:value].to_s.strip.length == 0
58
- say "Nothing input. Try again"
30
+ if errors && !errors.empty?
31
+ say "There were errors in the configuration file. Please correct them."
32
+ errors.each do |e|
33
+ say "[#{e.path} #{e.message}]"
59
34
  end
35
+ exit
60
36
  end
61
- `git config --global #{setting[:key]} #{setting[:value]}`
62
37
  end
38
+
39
+ @options = @options.to_mash
40
+
41
+ @options.each do |method_name, settings|
42
+ self.send("configure_#{method_name}", settings)
43
+ end
44
+
45
+ bash_profile = '[[ -s "$HOME/.tanjun_profile" ]] && source "$HOME/.tanjun_profile"'
46
+ add_to_file ".bash_profile", bash_profile
47
+
48
+ if file_exists?(".ssh/id_rsa") && file_exists?(".ssh/id_rsa.pub")
49
+ public_key = File.read("#{destination_root}/.ssh/id_rsa.pub")
50
+ else unless @options["ssh"]["email"].nil?
51
+ ask "SSH Passphrase: ", password: true, required: true
52
+
53
+ public_key = run "ssh-keygen -t rsa -C '#{@options["ssh"]["email"]}' -f '#{destination_root}/.ssh/id_rsa' -N #{password}"
54
+ end
55
+
56
+ copy_file 'gitignore', '.gitignore'
57
+ copy_file 'tanjun_profile', '.tanjun_profile'
58
+
59
+ say "Now add your ssh public key to https://github.com/settings/ssh:"
60
+ say public_key
63
61
  end
64
62
 
65
- if file_exists?(".ssh/id_rsa") && file_exists?(".ssh/id_rsa.pub")
66
- public_key = File.read("#{destination_root}/.ssh/id_rsa.pub")
67
- else
68
- password, confirm = nil
69
- while password != confirm || password.to_s.strip.length <= 4
70
- while password.to_s.strip.length == 0
71
- password = ask "SSH Passphrase: "
72
- if password.to_s.strip.length <= 4
73
- say "Password must be longer than 4 characters"
74
- end
63
+ no_task do
64
+ def configure_rubies(rubies)
65
+ rubies.each { |ruby| `rvm install #{ruby}` }
66
+ end
67
+
68
+ def configure_paths(paths)
69
+ paths.each { |path| empty_directory path }
70
+ end
71
+
72
+ def configure_vundle(vundles)
73
+ `git clone https://github.com/gmarik/vundle.git ~/vim/bundle/vundle`
74
+ @vundles = vundles
75
+ template 'vimrc', '.vimrc'
76
+ end
77
+
78
+ def configure_git(settings)
79
+ settings.each { |key, value| `git config --global #{key} #{value}` }
80
+ end
81
+
82
+ def configure_gems(gems)
83
+ gems.each do |gem|
84
+ gem.version ||= "=> 0"
85
+ `rvm do gem install #{gem.name} --version #{gem.version} --no-ri --no-rdoc`
86
+ self.send("configure_#{gem.name}")
75
87
  end
76
- confirm = ask "Confirm Passphrase: "
77
88
  end
78
89
 
79
- public_key = run "ssh-keygen -t rsa -C '#{gitconfig[:email][:value]}' -f '#{destination_root}/.ssh/id_rsa' -N #{password}"
80
- end
90
+ def configure_hub
91
+ path = "#{destination_root}/bin/hub"
92
+ command = "hub hub standalone > #{path} && chmod 755 #{path}"
93
+ run_with_conflict_check(path, command)
94
+ end
95
+
96
+ def configure_passenger
97
+ path = "/opt/nginx/tanjun"
98
+ command = "rvmsudo passenger-install-nginx-module --auto --auto-download --prefix=#{path}"
99
+ run_with_conflict_check(path, command)
81
100
 
82
- copy_file 'gitignore', '.gitignore'
83
- copy_file 'tanjun_profile', '.tanjun_profile'
101
+ path = "/etc/init.d/nginx"
102
+ command = "sudo curl -L -o /etc/init.d/nginx http://bit.ly/nginx-ubuntu-init-file && sudo chown root:root /etc/init.d/nginx && sudo chmod 0755 '/etc/init.d/nginx' && sudo update-rc.d nginx defaults"
103
+ run_with_conflict_check(path, command)
104
+ end
105
+ end
84
106
  end
85
107
  end
86
- end
87
108
 
88
109
  Tanjun::Tanjun.start
@@ -0,0 +1,21 @@
1
+ gems:
2
+ - rails
3
+ - hub
4
+ - passenger
5
+ paths:
6
+ - projects
7
+ - bin
8
+ vundles:
9
+ - tpope/vim-fugitive
10
+ - tpope/vim-rails
11
+ - LStinson/TagmaBufMgr
12
+ gitconfig:
13
+ user.name:
14
+ user.email:
15
+ github.user:
16
+ github.token:
17
+ core.excludesfile: ~/.gitignore
18
+ color.gui: true
19
+ ssh:
20
+ email:
21
+ passphrase:
@@ -11,8 +11,4 @@ function ps1_git() {
11
11
 
12
12
  PS1="\[\033[1;32m\]\u@\h/\j \[\033[1;33m\]\W\[\033[1;34m\]\$(ps1_git)\[\033[00m\]\$ "
13
13
 
14
- if command -v hub >/dev/null 2>&1; then
15
- eval "$(hub alias -s)"
16
- fi
17
-
18
- [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
14
+ eval "$(hub alias -s)"
@@ -0,0 +1,37 @@
1
+ type: map
2
+ mapping:
3
+ "rubies":
4
+ type: seq
5
+ "paths":
6
+ type: seq
7
+ "gems":
8
+ type: seq
9
+ sequence:
10
+ - type: map
11
+ mapping:
12
+ "name":
13
+ required: yes
14
+ "version":
15
+ "vundles":
16
+ type: seq
17
+ "personal":
18
+ type: map
19
+ mapping:
20
+ "full_name":
21
+ required: yes
22
+ "email":
23
+ required: yes
24
+ "github_user":
25
+
26
+ "gitconfig":
27
+ type: seq
28
+ sequence:
29
+ - type: map
30
+ mapping:
31
+ "key":
32
+ required: yes
33
+ "value":
34
+ required: yes
35
+ "ssh":
36
+ type: map
37
+ mapping:
@@ -0,0 +1,50 @@
1
+ set nocompatible
2
+ filetype off
3
+
4
+ set rtp+=~/.vim/bundle/vundle
5
+ call vundle#rc()
6
+
7
+ Bundle 'gmarik/vundle'
8
+ <%- @vundles.each do |vundle| %>
9
+ Bundle '<%= vundle %>'
10
+ <%- end %>
11
+
12
+ filetype plugin indent on
13
+
14
+ syntax on
15
+ set background=dark
16
+ set ruler
17
+ set more
18
+ set number
19
+ set autoindent
20
+ set expandtab
21
+ set softtabstop=2
22
+ set shiftwidth=2
23
+ set scrolloff=5
24
+ set history=200
25
+ set backspace=indent,eol,start
26
+ set wrap
27
+ set linebreak
28
+ set showbreak=>\ \ \
29
+ set undolevels=1000
30
+ set complete=.,w,b,u,U,t,i,d
31
+ set ttyfast
32
+ set showmatch
33
+ set ignorecase
34
+ set smartcase
35
+ nore ; :
36
+ nore , ;
37
+ inoremap <Down> <C-o>gj
38
+ inoremap <Up> <C-o>gk
39
+ set list
40
+ set listchars=tab:>·,trail:·
41
+ set textwidth=80
42
+ set colorcolumn=+1
43
+ inoremap jk <Esc>
44
+ inoremap kj <Esc>
45
+ inoremap jj <Esc>
46
+ inoremap kk <Esc>
47
+ autocmd BufWritePost .vimrc source %
48
+ autocmd BufWritePre * :%s/\s\+$//e
49
+ set hidden
50
+ set wildmenu
@@ -3,3 +3,4 @@ require "open-uri"
3
3
  require "tanjun/core_ext/open-uri"
4
4
  require "thor"
5
5
  require "tanjun/thor_ext/actions"
6
+ require "tanjun/thor_ext/shell/basic"
@@ -0,0 +1,37 @@
1
+ require 'tanjun/thor_ext/shell/password'
2
+
3
+ class Thor
4
+ module Shell
5
+ class Basic
6
+ include Password
7
+
8
+ # Asks something to the user and receives a response.
9
+ #
10
+ # If asked to limit the correct responses, you can pass in an
11
+ # array of acceptable answers. If one of those is not supplied,
12
+ # they will be shown a message stating that one of those answers
13
+ # must be given and re-asked the question.
14
+ #
15
+ # ==== Example
16
+ # ask("What is your name?")
17
+ #
18
+ # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
19
+ #
20
+ def ask(statement, *args)
21
+ options = args.last.is_a?(Hash) ? args.pop : {}
22
+ response = if options[:limited_to]
23
+ ask_filtered(statement, options[:limited_to], *args)
24
+ elsif options[:password]
25
+ ask_passwordly(statement, *args)
26
+ else
27
+ ask_simply(statement, *args)
28
+ end
29
+
30
+ if options[:required] && response.to_s.strip.length == 0
31
+ say "Your response can't be empty. Please try again."
32
+ ask(statement, *args.push(options)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,41 @@
1
+ re 'tempfile'
2
+
3
+ class Thor
4
+ module Shell
5
+ module Password
6
+ if RUBY_PLATFORM =~ /mswin32|mingw32/
7
+
8
+ def ask_passwordly(statement, color = nil)
9
+ say("#{statement} ", color)
10
+
11
+ require "Win32API"
12
+ char = nil
13
+ password = ''
14
+
15
+ while char = Win32API.new("crtdll", "_getch", [ ], "L").Call do
16
+ break if char == 10 || char == 13 # received carriage return or newline
17
+ if char == 127 || char == 8 # backspace and delete
18
+ password.slice!(-1, 1)
19
+ else
20
+ # windows might throw a -1 at us so make sure to handle RangeError
21
+ (password << char.chr) rescue RangeError
22
+ end
23
+ end
24
+ puts
25
+ return password
26
+ end
27
+
28
+ else
29
+
30
+ def ask_passwordly(statement, color = nil)
31
+ system "stty -echo"
32
+ password = ask(statement, color)
33
+ puts
34
+ return password
35
+ ensure
36
+ system "stty echo"
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module Tanjun
2
- VERSION = "0.0.1.alpha3"
2
+ VERSION = "0.0.1.alpha4"
3
3
  end
@@ -16,4 +16,6 @@ Gem::Specification.new do |gem|
16
16
  gem.version = Tanjun::VERSION
17
17
 
18
18
  gem.add_dependency 'thor', '~> 0.14.6'
19
+ gem.add_dependency 'hashie', '~> 1.2.0'
20
+ gem.add_dependency 'kwalify', '~> 0.7.2'
19
21
  end
metadata CHANGED
@@ -1,40 +1,78 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: tanjun
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha3
5
- prerelease: 6
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: true
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ - alpha4
10
+ version: 0.0.1.alpha4
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Rupert
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-04-14 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-04-16 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: thor
16
- requirement: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
26
+ requirements:
19
27
  - - ~>
20
- - !ruby/object:Gem::Version
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 0
31
+ - 14
32
+ - 6
21
33
  version: 0.14.6
22
34
  type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: hashie
23
38
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
39
+ requirement: &id002 !ruby/object:Gem::Requirement
25
40
  none: false
26
- requirements:
41
+ requirements:
27
42
  - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 0.14.6
43
+ - !ruby/object:Gem::Version
44
+ segments:
45
+ - 1
46
+ - 2
47
+ - 0
48
+ version: 1.2.0
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: kwalify
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ segments:
60
+ - 0
61
+ - 7
62
+ - 2
63
+ version: 0.7.2
64
+ type: :runtime
65
+ version_requirements: *id003
30
66
  description: A collection of tools for faster development
31
- email:
67
+ email:
32
68
  - rupert@madden-abbott.com
33
- executables:
69
+ executables:
34
70
  - tanjun
35
71
  extensions: []
72
+
36
73
  extra_rdoc_files: []
37
- files:
74
+
75
+ files:
38
76
  - .gitignore
39
77
  - Gemfile
40
78
  - LICENSE
@@ -45,7 +83,10 @@ files:
45
83
  - bin/project
46
84
  - bin/tanjun
47
85
  - bin/templates/gitignore
86
+ - bin/templates/tanjun.yml
48
87
  - bin/templates/tanjun_profile
88
+ - bin/templates/tanjun_schema.yml
89
+ - bin/templates/vimrc
49
90
  - lib/interact/templates/meta/script.rb
50
91
  - lib/interact/templates/project/app/views/layout/application.html.haml.tt
51
92
  - lib/tanjun.rb
@@ -54,30 +95,43 @@ files:
54
95
  - lib/tanjun/generators/bootstrap-sass/install/install_generator.rb
55
96
  - lib/tanjun/generators/guard/install/install_generator.rb
56
97
  - lib/tanjun/thor_ext/actions.rb
98
+ - lib/tanjun/thor_ext/shell/basic.rb
99
+ - lib/tanjun/thor_ext/shell/password.rb
57
100
  - lib/tanjun/version.rb
58
101
  - tanjun.gemspec
102
+ has_rdoc: true
59
103
  homepage: http://github.com/rupert654/tanjun
60
104
  licenses: []
105
+
61
106
  post_install_message:
62
107
  rdoc_options: []
63
- require_paths:
108
+
109
+ require_paths:
64
110
  - lib
65
- required_ruby_version: !ruby/object:Gem::Requirement
111
+ required_ruby_version: !ruby/object:Gem::Requirement
66
112
  none: false
67
- requirements:
68
- - - ! '>='
69
- - !ruby/object:Gem::Version
70
- version: '0'
71
- required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ segments:
117
+ - 0
118
+ version: "0"
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
120
  none: false
73
- requirements:
74
- - - ! '>'
75
- - !ruby/object:Gem::Version
121
+ requirements:
122
+ - - ">"
123
+ - !ruby/object:Gem::Version
124
+ segments:
125
+ - 1
126
+ - 3
127
+ - 1
76
128
  version: 1.3.1
77
129
  requirements: []
130
+
78
131
  rubyforge_project:
79
- rubygems_version: 1.8.21
132
+ rubygems_version: 1.3.7
80
133
  signing_key:
81
134
  specification_version: 3
82
135
  summary: Scripts and generators to speed up your development
83
136
  test_files: []
137
+