popo 0.1.9 → 0.1.10

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.
@@ -0,0 +1,27 @@
1
+ -- 0.1.10
2
+
3
+ features
4
+ * popo bash is now popo shell. bash still works though. just changed
5
+ underlying code to be more generic
6
+
7
+ * popo will now check for $SHELL instead of which
8
+
9
+ * git and env are now called on boot before everything else. without it,
10
+ popo will not have the ability to work.
11
+ * added boring README and CHANGELOG.
12
+
13
+ * version bump 0.1.9 -> 0.1.10
14
+
15
+ * added sourcing of rvm ps1_functions for ps1_set option
16
+
17
+ * removed deprecated targets folder
18
+
19
+ * poporc is now read from popo source and not from a manifest
20
+
21
+ * a customrc is now loaded if it is found under .manifest/script
22
+
23
+ bug fixes
24
+ * fixed sync not being be able to update when path basename is equal
25
+ to app basename.
26
+
27
+ * changed parameters in order of importance
data/README CHANGED
@@ -1 +1,11 @@
1
- popo rails repo tool
1
+ Popo Repo Tool
2
+
3
+ Deploy your rails app
4
+
5
+ Features:
6
+ - Customizable manifest
7
+ - Separate shell, rvm. No conflict worries
8
+ - Easy on resources (RAM and CPU)
9
+ - Integrated with cableguy to ease Rails configuration file deployment
10
+ - Is best used when deploying and working with multiple Rails applications
11
+
@@ -12,7 +12,7 @@ module Popo
12
12
  autoload :Database, File.join(POPO_LIB_ROOT, 'database')
13
13
  autoload :Error, File.join(POPO_LIB_ROOT, 'error')
14
14
  autoload :GitUtils, File.join(POPO_LIB_ROOT, 'git_utils')
15
- autoload :Initializer, File.join(POPO_LIB_ROOT, 'initializer')
15
+ autoload :Init, File.join(POPO_LIB_ROOT, 'init')
16
16
  autoload :Runner, File.join(POPO_LIB_ROOT, 'runner')
17
17
  autoload :RVM, File.join(POPO_LIB_ROOT, 'rvm')
18
18
  autoload :Sync, File.join(POPO_LIB_ROOT, 'sync')
@@ -1,12 +1,12 @@
1
1
  module Popo
2
- class Initializer
2
+ class Init
3
3
  include Constants
4
4
 
5
- def self.boot(config, options, db)
6
- self.new(config, options, db)
5
+ def self.boot(db, config, options)
6
+ self.new(db, config, options)
7
7
  end
8
8
 
9
- def initialize(config, options, db)
9
+ def initialize(db, config, options)
10
10
  @options = options
11
11
  @db = db
12
12
  @manifest = config['manifests'][@options[:manifest]]
@@ -3,18 +3,39 @@ module Popo
3
3
  include Constants
4
4
 
5
5
  def self.boot(args)
6
- Popo::Constants.const_set("BASH_CMD", `which bash 2>/dev/null`.strip)
7
- Popo::Constants.const_set("ZSH_CMD", `which zsh 2>/dev/null`.strip)
8
- Popo::Constants.const_set("ENV_CMD", `which env 2>/dev/null`.strip)
9
- Popo::Constants.const_set("GIT_CMD", `which git 2>/dev/null`.strip)
6
+ check_requirements
7
+
8
+ Popo::Constants.const_set("SHELL", ENV['SHELL'])
9
+
10
+ if SHELL.empty?
11
+ Error.say("SHELL is empty.")
12
+ end
10
13
 
11
14
  self.new(args)
12
15
  end
13
16
 
17
+ def self.check_requirements
18
+ bins = ['env', 'git' ]
19
+
20
+ bins.each do |b|
21
+ const_fn = "#{b.upcase}_CMD"
22
+
23
+ Popo::Constants.const_set(const_fn, get_bin_path(b))
24
+
25
+ if Popo::Constants.const_get(const_fn).empty?
26
+ Error.say "#{b} is needed and is not found in PATH!"
27
+ end
28
+ end
29
+ end
30
+
31
+ def self.get_bin_path(bin)
32
+ `which #{bin}`.strip
33
+ end
34
+
14
35
  def initialize(args)
15
36
  @db_opts = {}
16
37
  @options = {}
17
- @app_root = ENV['popo_path'] || Dir.pwd
38
+ @app_root = ENV['popo_path'] || Dir.pwd
18
39
  @options[:verbose] = false
19
40
 
20
41
  if Utils.has_popo_config?(@app_root)
@@ -67,15 +88,14 @@ module Popo
67
88
  else
68
89
  @db_opts[:path] = File.join(@app_root, POPO_WORK_PATH)
69
90
  @db_opts[:target] = ENV['CABLING_TARGET'] || @options[:target] || DEFAULT_POPO_TARGET
70
- @db_opts[:location] = ENV['CABLING_LOCATION'] || @options[:location]
71
91
  @db_opts[:verbose] = @options[:verbose]
92
+ @db_opts[:location] = ENV['CABLING_LOCATION'] || @options[:location]
72
93
 
73
94
  # set manifest usable constants
74
95
  Object.const_set("POPO_PATH", @app_root)
96
+ Object.const_set("POPO_USER", @options[:user])
75
97
  Object.const_set("POPO_TARGET", @db_opts[:target])
76
98
  Object.const_set("POPO_LOCATION", @options[:location])
77
- Object.const_set("POPO_USER", @options[:user])
78
-
79
99
 
80
100
  mandatory = [:path, :manifest]
81
101
  mandatory = mandatory.select { |p| @options[p].nil? }
@@ -89,7 +109,7 @@ module Popo
89
109
  end
90
110
 
91
111
  def run(args)
92
- if POPO_COMMANDS.include?(args)
112
+ if POPO_COMMANDS.include?(args.first)
93
113
  Utils.in_popo?(@app_root)
94
114
  end
95
115
 
@@ -105,64 +125,71 @@ module Popo
105
125
 
106
126
  if !File.exist?(File.join(@app_root, @options[:path]))
107
127
  @db_opts[:path] = File.join(@app_root, @options[:path], POPO_WORK_PATH)
108
- db = Database.new(@app_root, @db_opts)
128
+ db = get_database
109
129
 
110
- Initializer.boot(config, @options, db).setup
130
+ Init.boot(db, config, @options).setup
111
131
  else
112
- Error.say "Path already exists!"
132
+ Error.say "Path \'#{@options[:path]}\' already exists!"
113
133
  end
114
134
  when 'sync'
115
- db = Database.new(@app_root, @db_opts)
116
- db.boot_database
135
+ db = get_database
117
136
 
118
- Sync.new(@app_root, args, db).sync
137
+ Sync.new(db, @app_root, args).sync
119
138
  when 'rvm'
120
- db = Database.new(@app_root, @db_opts)
121
- db.boot_database
139
+ db = get_database
122
140
 
123
- RVM.new(@app_root, args, db).setup
141
+ RVM.new(db, @app_root, args).setup
124
142
  when 'migrate'
125
- db = Database.new(@app_root, @db_opts)
126
- db.boot_database
127
- db.migrate_database
143
+ get_database.migrate_database
128
144
  when 'status'
129
145
  Utils.say `cat #{File.join(@app_root, POPO_WORK_PATH, POPO_YML_FILE)}`
130
- when 'bash'
131
- sh!(cmd)
132
- when 'zsh'
133
- sh!(cmd)
146
+ when 'shell', 'bash'
147
+ sh!
134
148
  when 'diff'
135
149
  GitUtils.branch_diff(Dir.pwd)
136
150
  else
137
- Error.say "#{args} not a valid command!"
151
+ Error.say "#{cmd} is not a valid command!"
138
152
  end
139
153
  end
140
154
 
141
- def sh!(shell)
155
+ protected
156
+
157
+ def sh!
142
158
  if Utils.has_popo_config?(@app_root)
143
159
  path = POPO_CONFIG['path']
144
160
  target = POPO_CONFIG['target']
145
161
  location = POPO_CONFIG['location']
162
+ shell = File.basename(SHELL)
146
163
 
147
- if shell == 'bash'
164
+ case shell
165
+ when 'bash'
148
166
  poporc = File.expand_path('../../../script/poporc', __FILE__)
149
167
 
150
168
  shcmd = "%s popo_target=%s popo_path=%s \
151
169
  popo_location=%s %s --rcfile %s" \
152
- % [ENV_CMD, target, path, location, BASH_CMD, poporc]
153
- else
170
+ % [ENV_CMD, target, path, location, shell, poporc]
171
+ when 'zsh'
154
172
  zdotdir = File.expand_path('../../../script', __FILE__)
155
173
 
156
174
  shcmd = "%s popo_target=%s popo_path=%s \
157
175
  popo_location=%s ZDOTDIR=%s\
158
176
  %s" \
159
- % [ENV_CMD, target, path, location, zdotdir, ZSH_CMD]
177
+ % [ENV_CMD, target, path, location, zdotdir, shell]
178
+ else
179
+ Error.say "Shell #{SHELL} is not supported!"
160
180
  end
161
181
 
162
182
  exec(shcmd)
163
183
  end
164
184
  end
165
185
 
186
+ def get_database
187
+ database = Database.new(@app_root, @db_opts)
188
+ database.boot_database
189
+
190
+ database
191
+ end
192
+
166
193
  def get_config!
167
194
  if File.exist?(File.join(ENV['HOME'], ".#{DEFAULT_CONFIG_FILE}"))
168
195
  config_file_path = File.join(ENV['HOME'], ".#{DEFAULT_CONFIG_FILE}")
@@ -1,6 +1,6 @@
1
1
  module Popo
2
2
  class RVM
3
- def initialize(app_root, args, db)
3
+ def initialize(db, app_root, args)
4
4
  @db = db
5
5
  @app_root = app_root
6
6
  @rvm_bin = File.join(@app_root, 'rvm/bin/rvm')
@@ -2,7 +2,7 @@ module Popo
2
2
  class Sync
3
3
  include Constants
4
4
 
5
- def initialize(popo_path, args, db)
5
+ def initialize(db, popo_path, args)
6
6
  @db = db
7
7
  @sync_list = @db.get(POPO_DIR_KEY).split(',')
8
8
  @popo_path = popo_path
@@ -29,9 +29,10 @@ module Popo
29
29
  if @cwd.eql? @popo_path
30
30
  @sync_list.each { |p| sync_all(p) }
31
31
  else
32
- project = @cwd.split('/') - @popo_path.split('/')
32
+ key = @cwd.split('/')
33
+ key.shift(@popo_path.split('/').count)
33
34
 
34
- sync_all(convert_to_key(project))
35
+ sync_all(convert_to_key(key))
35
36
  end
36
37
  end
37
38
  end
@@ -74,7 +75,6 @@ module Popo
74
75
  end
75
76
  end
76
77
 
77
-
78
78
  def get_values(key)
79
79
  POPO_KEY_VALUES.each do |v|
80
80
  @info[v] = @db.get("#{key}.#{v}")
@@ -21,6 +21,7 @@ module Popo
21
21
  if !ENV.include?('popo_path')
22
22
  Error.say "You must be inside popo!"
23
23
  end
24
+
24
25
  true
25
26
  end
26
27
 
@@ -1,3 +1,3 @@
1
1
  module Popo
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env bash
2
-
3
2
  if [[ -z "$popo_path" ]] ; then
4
3
  echo "FAIL Please set the popo_path environment var"
5
4
  exit -1
@@ -14,26 +13,15 @@ YELLOW="\[\033[33m\]"
14
13
  NORMAL="\[\033[0;0m\]"
15
14
  BASEPATH=`which basename`
16
15
  BASENAME=`$BASEPATH $popo_path`
16
+ CUSTOMRC=$popo_path/.manifest/script/customrc
17
17
 
18
-
19
- export rvm_reload_flag=1
20
18
  export rvm_prefix=$popo_path
21
-
22
- export CABLING_PATH=$popo_path/.manifest/cabling
23
- export CABLING_TARGET=$popo_target
24
-
25
- if [[ -n "$popo_location" ]] ; then
26
- export CABLING_LOCATION=$popo_location
27
- fi
28
-
29
- export DBGET_PATH=$popo_path/.manifest
30
-
31
19
  unset $(env | awk -F= '/^rvm_/{print $1" "}')
32
-
33
20
  export rvm_path=$popo_path/rvm
34
21
  source $rvm_path/scripts/rvm
35
-
22
+ source $rvm_path/contrib/ps1_functions
36
23
  rubies_path=$rvm_path/rubies
24
+
37
25
  # Load default rvm if rubies folder is not empty
38
26
  if [ -d $rubies_path ] && [ "$(ls -A $rubies_path)" ] ; then
39
27
  rvm default
@@ -42,30 +30,32 @@ fi
42
30
  unset PALMADE_GEMS_DIR
43
31
  export PATH="$rvm_path/bin:$popo_path/tools:$PATH"
44
32
 
45
-
46
33
  if [[ $PS1 != "" ]] ; then
47
- if [[ -f /etc/bash.bashrc ]] ; then
48
- source /etc/bash.bashrc
49
- fi
50
-
51
- if [[ -f $HOME/.bashrc ]] ; then
52
- source $HOME/.bashrc
53
- fi
54
-
55
- if [[ $BASENAME != $popo_target ]] ; then
56
- export PS1="$YELLOW(popo $popo_target/$BASENAME) $NORMAL$PS1"
57
- else
58
- export PS1="$YELLOW(popo $popo_target) $NORMAL$PS1"
59
- fi
34
+ if [[ -f /etc/bash.bashrc ]] ; then
35
+ source /etc/bash.bashrc
36
+ fi
37
+
38
+ if [[ -f $HOME/.bashrc ]] ; then
39
+ source $HOME/.bashrc
40
+ fi
41
+
42
+ if [[ $BASENAME != $popo_target ]] ; then
43
+ export PS1="$YELLOW(popo $popo_target/$BASENAME) $NORMAL$PS1"
44
+ else
45
+ export PS1="$YELLOW(popo $popo_target) $NORMAL$PS1"
46
+ fi
60
47
  fi
61
48
 
49
+ rvm reload
50
+
62
51
  if [[ -z "$PS1" ]] ; then
63
52
  rvm $*
64
53
  else
65
- echo "Welcome to the popoed bash environment, where you can play with your very own popo."
54
+ echo "Welcome to the popoed environment, where you can play with your very own popo."
66
55
  echo ""
67
- echo " popo path: $popo_path"
68
- echo " popo target: $popo_target"
56
+ echo "Popo has set these variables for you lazy ass people".
57
+ echo " popo_path: $popo_path"
58
+ echo " popo_target: $popo_target"
69
59
  echo ""
70
60
  echo "Remember to keep things clean and civil around here."
71
61
  echo "To go back to your normal world, just hit exit."
@@ -73,3 +63,8 @@ else
73
63
  echo "But wait, you ask, who needs popo? Baahh, popo's for n00bs!"
74
64
  echo ""
75
65
  fi
66
+
67
+ # source a custom rc file
68
+ if [[ -s $CUSTOMRC ]] ; then
69
+ source $CUSTOMRC
70
+ fi
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: popo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-08 00:00:00.000000000Z
12
+ date: 2012-03-26 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sequel
16
- requirement: &20227340 !ruby/object:Gem::Requirement
16
+ requirement: &17259580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *20227340
24
+ version_requirements: *17259580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &20226280 !ruby/object:Gem::Requirement
27
+ requirement: &17259080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *20226280
35
+ version_requirements: *17259080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cableguy
38
- requirement: &20225240 !ruby/object:Gem::Requirement
38
+ requirement: &17258660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *20225240
46
+ version_requirements: *17258660
47
47
  description: Ruby and rails repo tool
48
48
  email:
49
49
  - poymode@gmail.com
@@ -54,6 +54,7 @@ extensions: []
54
54
  extra_rdoc_files: []
55
55
  files:
56
56
  - .gitignore
57
+ - CHANGELOG
57
58
  - Gemfile
58
59
  - README
59
60
  - Rakefile
@@ -67,7 +68,7 @@ files:
67
68
  - lib/popo/database.rb
68
69
  - lib/popo/error.rb
69
70
  - lib/popo/git_utils.rb
70
- - lib/popo/initializer.rb
71
+ - lib/popo/init.rb
71
72
  - lib/popo/runner.rb
72
73
  - lib/popo/rvm.rb
73
74
  - lib/popo/sync.rb
@@ -80,12 +81,6 @@ files:
80
81
  - script/envy.template
81
82
  - script/envyrc
82
83
  - script/poporc
83
- - targets/beta.rb
84
- - targets/common.rb
85
- - targets/development.rb
86
- - targets/production.rb
87
- - targets/staging.rb
88
- - targets/test.rb
89
84
  homepage: https://github.com/poymode/popo
90
85
  licenses: []
91
86
  post_install_message:
@@ -1 +0,0 @@
1
- # BETA target
@@ -1 +0,0 @@
1
- # COMMON TARGET
@@ -1 +0,0 @@
1
- # DEVELOPMENT TARGET
@@ -1 +0,0 @@
1
- # PRODUCTION TARGET
@@ -1 +0,0 @@
1
- # STAGING TARGET
@@ -1 +0,0 @@
1
- # TEST TARGET