popo 0.1.1 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/envy CHANGED
@@ -7,7 +7,7 @@ ENV_PATH = `which env`.strip
7
7
  POPO_PATH = ENV['popo_path'] if ENV.include?('popo_path')
8
8
  POPO_TARGET = ENV['popo_target'] if ENV.include?('popo_target')
9
9
  POPO_WORK_PATH = '.manifest'
10
- ENVYRC = File.join(POPO_PATH, POPO_WORK_PATH, 'script/envyrc')
10
+ ENVYRC = File.expand_path(File.join(File.dirname(__FILE__), '../script/envyrc'))
11
11
 
12
12
  cmd = ARGV.join(' ')
13
13
 
data/lib/popo.rb CHANGED
@@ -3,6 +3,7 @@ require 'palmade/cableguy'
3
3
  require 'optparse'
4
4
  require 'yaml'
5
5
  require 'fileutils'
6
+ require File.join(File.dirname(__FILE__), 'popo/version')
6
7
 
7
8
  module Popo
8
9
  POPO_LIB_ROOT = File.join(File.dirname(__FILE__), 'popo')
data/lib/popo/database.rb CHANGED
@@ -19,5 +19,9 @@ module Popo
19
19
  def get_children(key, group = 'manifest')
20
20
  @cabler.db.get_children(key, group)
21
21
  end
22
+
23
+ def has_key?(key, group = 'manifest')
24
+ @cabler.db.has_key?(key, group)
25
+ end
22
26
  end
23
27
  end
@@ -27,7 +27,6 @@ module Popo
27
27
  end
28
28
  end
29
29
 
30
- git_stash(repo)
31
30
  git_checkout(repo, branch)
32
31
  git_reset(repo, branch)
33
32
  end
@@ -2,18 +2,14 @@ module Popo
2
2
  class Initializer
3
3
  include Constants
4
4
 
5
- def self.boot(config, options)
6
- self.new(config, options)
5
+ def self.boot(config, options, db)
6
+ self.new(config, options, db)
7
7
  end
8
8
 
9
- def initialize(config, options)
10
- @repos = {}
11
-
12
- config['repos'].each do |k, v|
13
- @repos[k] = v
14
- end
15
-
9
+ def initialize(config, options, db)
16
10
  @options = options
11
+ @db = db
12
+ @manifest = config['manifests'][@options[:manifest]]
17
13
  @default_target = @options[:target] || 'development'
18
14
  @deploy_path = File.absolute_path(@options[:path])
19
15
  @location = @options[:location] || nil
@@ -28,16 +24,18 @@ module Popo
28
24
  def setup
29
25
  print_variables if @options[:verbose]
30
26
 
31
- @repos.each do |k, v|
32
- basename = File.basename(v['git'])
27
+ clone_path = File.join(@deploy_path, POPO_WORK_PATH)
28
+ GitUtils.git_clone(@manifest['git'], clone_path, @manifest['branch'])
33
29
 
34
- if k == POPO_WORK_PATH.delete('.')
35
- clone_path = File.join(@deploy_path, POPO_WORK_PATH)
36
- else
37
- clone_path = File.join(@deploy_path, basename)
38
- end
30
+ @db.boot_database
31
+ @db.migrate_database
32
+ repos = @db.get_children("repos")
39
33
 
40
- GitUtils.git_clone(v['git'], clone_path, v['branch'])
34
+ repos.each do |r|
35
+ git = @db.get("repos.#{r}.git")
36
+ branch = @db.get("repos.#{r}.branch")
37
+ clone_path = File.join(@deploy_path, r)
38
+ GitUtils.git_clone(git, clone_path, branch)
41
39
  end
42
40
 
43
41
  write_config
data/lib/popo/runner.rb CHANGED
@@ -12,9 +12,16 @@ module Popo
12
12
 
13
13
  def initialize(args)
14
14
  @popo_path = ENV['popo_path'] || Dir.pwd
15
+ Object.const_set("POPO_PATH", @popo_path)
16
+
15
17
  @options = {}
16
18
  @cabler_options = {}
17
19
  @options[:verbose] = false
20
+ @options[:target] = 'development'
21
+
22
+ if Utils.has_popo_config?(@popo_path)
23
+ @options[:target] = POPO_CONFIG['target']
24
+ end
18
25
 
19
26
  optparse = OptionParser.new do |opts|
20
27
  opts.banner = "Popo tool."
@@ -32,6 +39,10 @@ module Popo
32
39
  @options[:user] = user
33
40
  end
34
41
 
42
+ opts.on('-m', '--manifest MANIFEST', 'Manifest') do |manifest|
43
+ @options[:manifest] = manifest
44
+ end
45
+
35
46
  opts.on('-l', '--location LOCATION', 'Location') do |location|
36
47
  @options[:location] = location
37
48
  end
@@ -40,6 +51,11 @@ module Popo
40
51
  @options[:verbose] = true
41
52
  end
42
53
 
54
+ opts.on('-V', '--version', 'Version') do
55
+ puts Popo::VERSION
56
+ exit
57
+ end
58
+
43
59
  opts.on('-h', '--help', 'Display this screen') do
44
60
  puts opts
45
61
  exit
@@ -51,26 +67,42 @@ module Popo
51
67
  if args.length == 0
52
68
  Utils.say optparse.help
53
69
  else
54
- @cabler_options = { :path => File.join(@popo_path, POPO_WORK_PATH),
55
- :target => ENV['CABLING_TARGET'],
56
- :location => ENV['CABLING_LOCATION'],
57
- :verbose => @options[:verbose] }
70
+ Object.const_set("POPO_TARGET", @options[:target])
71
+ Object.const_set("POPO_LOCATION", @options[:location])
72
+ Object.const_set("POPO_USER", @options[:user])
58
73
 
59
- run(args)
74
+ @cabler_options = { :path => File.join(@popo_path, POPO_WORK_PATH),
75
+ :target => ENV['CABLING_TARGET'] || @options[:target] || 'development',
76
+ :location => ENV['CABLING_LOCATION'] || @options[:location],
77
+ :verbose => @options[:verbose]
78
+ }
79
+ self.run(args)
60
80
  end
61
81
  end
62
82
 
63
83
  def run(args)
64
84
  case args.shift
65
85
  when 'init'
86
+ config = get_config!
87
+
88
+ if !@options[:manifest].nil?
89
+ if config['manifests'][@options[:manifest]].nil?
90
+ raise "manifest #{@options[:manifest]} does not exist in #{DEFAULT_CONFIG_FILE}!"
91
+ end
92
+ else
93
+ raise "manifest (-m) option needed!"
94
+ end
95
+
66
96
  if !@options[:path].nil?
67
97
  if !File.exist?(File.join(@popo_path, @options[:path]))
68
- Initializer.boot(get_config!, @options).setup
98
+ @cabler_options[:path] = File.join(@popo_path, @options[:path], POPO_WORK_PATH)
99
+ db = Database.new(@popo_path, @cabler_options)
100
+ Initializer.boot(config, @options, db).setup
69
101
  else
70
102
  raise "Path already exists!"
71
103
  end
72
104
  else
73
- raise "Supply a path with the -p option!"
105
+ raise "path (-p) option needed!"
74
106
  end
75
107
  when 'sync'
76
108
  if Utils.in_popo?(@popo_path)
@@ -81,16 +113,9 @@ module Popo
81
113
  end
82
114
  when 'rvminstall'
83
115
  if Utils.in_popo?(@popo_path)
84
- print "Install all rubies?(y/N): "
85
-
86
- ok = $stdin.gets.chomp!
87
- if ok == 'y'
88
- db = Database.new(@popo_path, @cabler_options)
89
- db.boot_database
90
- RVM.new(@popo_path, args, db).setup
91
- else
92
- Utils.say "y/N only!"
93
- end
116
+ db = Database.new(@popo_path, @cabler_options)
117
+ db.boot_database
118
+ RVM.new(@popo_path, args, db).setup
94
119
  end
95
120
  when 'migrate'
96
121
  if Utils.in_popo?(@popo_path)
@@ -110,18 +135,21 @@ module Popo
110
135
  end
111
136
 
112
137
  def bash!
113
- Utils.require_relative_work_popo(Dir.pwd)
138
+ if Utils.has_popo_config?(Dir.pwd)
114
139
 
115
- poporc_path = File.join(Dir.pwd, POPO_WORK_PATH, POPORC)
116
- target = POPO_CONFIG['target']
117
- path = POPO_CONFIG['path']
118
- location = POPO_CONFIG['location']
140
+ poporc_path = File.join(Dir.pwd, POPO_WORK_PATH, POPORC)
141
+ target = POPO_CONFIG['target']
142
+ path = POPO_CONFIG['path']
143
+ location = POPO_CONFIG['location']
119
144
 
120
- bashcmd = "%s popo_target=%s popo_path=%s \
121
- popo_location=%s %s --rcfile %s" \
122
- % [ENV_CMD, target, path, location, BASH_CMD, poporc_path]
145
+ bashcmd = "%s popo_target=%s popo_path=%s \
146
+ popo_location=%s %s --rcfile %s" \
147
+ % [ENV_CMD, target, path, location, BASH_CMD, poporc_path]
123
148
 
124
- exec(bashcmd)
149
+ exec(bashcmd)
150
+ else
151
+ raise "#{POPO_YML_FILE} not found or it may be wrong!"
152
+ end
125
153
  end
126
154
 
127
155
  def get_config!
data/lib/popo/rvm.rb CHANGED
@@ -8,12 +8,15 @@ module Popo
8
8
 
9
9
  @rubies = @db.get("rvm.rubies").split(",")
10
10
  @default_ruby = @db.get("rvm.ruby.default")
11
- @default_gems = @db.get("rvm.gems.default").split(",")
12
- @gem_source = @db.get("rvm.gems.source")
11
+ @default_gems = @db.get_children("rvm.gems.default")
12
+
13
+ if @db.has_key?("rvm.gems.source")
14
+ @default_gem_source = @db.get("rvm.gems.source")
15
+ end
13
16
  end
14
17
 
15
18
  def setup
16
- Utils.say "Rubies to be installed #{@rubies}...\n\n"
19
+ Utils.say "Rubies to be installed #{@rubies}...\n"
17
20
 
18
21
  @rubies.each do |r|
19
22
  patch = File.join(@app_root, 'rvm', "#{r}.patch")
@@ -26,6 +29,7 @@ module Popo
26
29
  end
27
30
 
28
31
  system(cmd)
32
+ install_default_gems(r)
29
33
  end
30
34
 
31
35
  Utils.say_with_time "Setting #{@default_ruby} as default ruby..." do
@@ -33,27 +37,34 @@ module Popo
33
37
  end
34
38
 
35
39
  Utils.say(POST_INSTALL_NOTE)
40
+ end
36
41
 
37
- # Utils.say_with_time "Reloading rvm..." do
38
- # `#{@rvm_bin} reload`
39
- # end
42
+ def install_default_gems(ruby_version)
43
+ gem_source = ''
44
+ gem_bin = File.join(@app_root, 'rvm', 'bin', "gem-#{ruby_version}")
45
+
46
+ @default_gems.each do |g|
47
+ if @db.has_key?("rvm.gems.default.#{g}.source")
48
+ gem_source = @db.get("rvm.gems.default.#{g}.source")
49
+ end
40
50
 
41
- # @default_gems.each do |g|
42
- # Utils.say_with_time "Installing gem #{g}" do
43
- # `gem install #{g} --source #{@gem_source}`
44
- # end
45
- # end
51
+ if !gem_source.empty?
52
+ gem_cmd = "#{gem_bin} install #{g} --source #{gem_source} --no-ri --no-rdoc"
53
+ elsif !@default_gem_source.empty?
54
+ gem_cmd = "#{gem_bin} install #{g} --source #{@default_gem_source} --no-ri --no-rdoc"
55
+ else
56
+ gem_cmd = "#{gem_bin} install #{g} --no-ri --no-rdoc"
57
+ end
58
+
59
+ system(gem_cmd)
60
+ end
46
61
  end
47
62
  end
48
63
 
49
64
  POST_INSTALL_NOTE = <<NOTE
50
- You're almost done!\n\n
65
+ You're almost done!\n
51
66
  Do the following inside popo:\n
52
67
  1. rvm reload\n
53
- 2. gem install cableguy popo dbget_client --source http://gems.caresharing.eu --no-ri --no-rdoc\n\n
54
- OPTIONAL: (If you use another ruby version). In this example, ree.\n
55
- 1. rvm use ree-1.8.7-2011.03\n
56
- 2. gem install cableguy popo dbget_client --source http://gems.caresharing.eu --no-ri --no-rdoc\n
57
68
  NOTE
58
69
 
59
70
  end
data/lib/popo/sync.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Popo
2
2
  class Sync
3
+ include Constants
4
+
3
5
  def initialize(app_root, args, db)
4
6
  @db = db
5
7
  @current_dir = File.basename(Dir.pwd)
@@ -27,7 +29,7 @@ module Popo
27
29
 
28
30
  if @repos.empty?
29
31
  if @cwd.eql? @app_root
30
- popo_folders = @db.get("popo_folders").split(',')
32
+ popo_folders = @db.get("sync.directories").split(',')
31
33
  popo_folders.each { |p| gather_many(p) }
32
34
  else
33
35
  repo = File.basename(@cwd)
@@ -54,6 +56,7 @@ module Popo
54
56
  if !File.exists?(@info[:path])
55
57
  GitUtils.git_clone(@info[:host], @info[:path], @info[:branch])
56
58
  else
59
+ GitUtils.git_stash(@info[:path]) if POPO_CONFIG['target'] == 'development'
57
60
  GitUtils.git_update(@info[:path], @info[:branch])
58
61
  end
59
62
  end
data/lib/popo/utils.rb CHANGED
@@ -24,7 +24,7 @@ module Popo
24
24
  true
25
25
  end
26
26
 
27
- def self.require_relative_work_popo(root_path)
27
+ def self.has_popo_config?(root_path)
28
28
  popo_work_path = File.expand_path(File.join(root_path, POPO_WORK_PATH))
29
29
 
30
30
  popo_yml = File.expand_path(File.join(popo_work_path, POPO_YML_FILE))
@@ -37,8 +37,11 @@ module Popo
37
37
  else
38
38
  raise "#{POPO_WORK_PATH}/#{POPO_YML_FILE} seems to be wrong."
39
39
  end
40
+
41
+ true
40
42
  else
41
- raise "#{POPO_YML_FILE} not found."
43
+ false
44
+ # raise "#{POPO_YML_FILE} not found."
42
45
  end
43
46
  end
44
47
  end
@@ -0,0 +1,3 @@
1
+ module Popo
2
+ VERSION = "0.1.4"
3
+ end
data/popo.gemspec CHANGED
@@ -1,10 +1,10 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- VERSION = "0.1.1"
3
+ require 'popo/version'
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "popo"
7
- s.version = VERSION
7
+ s.version = Popo::VERSION
8
8
  s.authors = ["Jan Mendoza"]
9
9
  s.email = ["poymode@gmail.com"]
10
10
  s.homepage = ""
data/script/envyrc CHANGED
@@ -4,11 +4,9 @@
4
4
  unset $(env | awk -F= '/^rvm_/{print $1" "}')
5
5
  export rvm_reload_flag=1
6
6
  export rvm_prefix=$popo_path
7
-
8
-
7
+ export rvm_path=$popo_path/rvm
9
8
  # Now let's load rvm inside popo
10
9
  source $rvm_prefix/rvm/scripts/rvm
11
-
12
10
  # Load default rvm
13
11
  rvm default 1>/dev/null 2>&1
14
12
  unset PALMADE_GEMS_DIR
@@ -16,30 +14,3 @@ export PATH="$popo_path/rvm/bin:$popo_path/tools:$PATH"
16
14
  export CABLING_PATH=$popo_path/.popo/cabling.yml
17
15
  export CABLING_TARGET=$popo_target
18
16
 
19
- # this section is for backup
20
- #unset PALMADE_GEMS_DIR
21
- #unset rvm_loaded_flag
22
- #rvm_loaded_flag=1
23
- #export PATH="$popo_path/rvm/bin:$popo_path/tools:$PATH"
24
- #export rvm_prefix=$popo_path
25
- #export rvm_path=$popo_path/rvm
26
- #export rvm_scripts_path=$rvm_path/scripts
27
- #export rvm_archives_path=$rvm_path/archives
28
- #export rvm_src_path=$rvm_path/src
29
- #export rvm_log_path=$rvm_path/log
30
- #export rvm_bin_path=$rvm_path/bin
31
- #export rvm_gems_path=$rvm_path/gems
32
- #export rvm_hooks_path=$rvm_path/hooks
33
- #export rvm_tmp_path=$rvm_path/tmp
34
- #export rvm_gemsets_path=$rvm_path/gemsets
35
- #export rvm_bin_path=$rvm_path/bin
36
- #export rvm_patchsets_path=$rvm_path/patchsets
37
- #export rvm_patches_path=$rvm_path/patches
38
- #export rvm_gems_cache_path=$rvm_path/gems/cache
39
- #export rvm_config_path=$rvm_path/config
40
- #export rvm_rubies_path=$rvm_path/rubies
41
- #export rvm_gems_path=$rvm_path/gems
42
- #export rvm_repo_path=$rvm_path/repos
43
- #unset rvm_loaded_flag
44
- #source $rvm_scripts_path/rvm
45
- #rvm default 1>/dev/null 2>&1
metadata CHANGED
@@ -1,72 +1,58 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: popo
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Jan Mendoza
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2012-01-01 00:00:00 +08:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-01-10 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: sequel
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &22157620 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: sqlite3
35
23
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *22157620
25
+ - !ruby/object:Gem::Dependency
26
+ name: sqlite3
27
+ requirement: &22157000 !ruby/object:Gem::Requirement
37
28
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
44
33
  type: :runtime
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- name: cableguy
48
34
  prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *22157000
36
+ - !ruby/object:Gem::Dependency
37
+ name: cableguy
38
+ requirement: &22156360 !ruby/object:Gem::Requirement
50
39
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
57
44
  type: :runtime
58
- version_requirements: *id003
45
+ prerelease: false
46
+ version_requirements: *22156360
59
47
  description: Ruby and rails repo tool
60
- email:
48
+ email:
61
49
  - poymode@gmail.com
62
- executables:
50
+ executables:
63
51
  - envy
64
52
  - popo
65
53
  extensions: []
66
-
67
54
  extra_rdoc_files: []
68
-
69
- files:
55
+ files:
70
56
  - .gitignore
71
57
  - Gemfile
72
58
  - README
@@ -85,6 +71,7 @@ files:
85
71
  - lib/popo/rvm.rb
86
72
  - lib/popo/sync.rb
87
73
  - lib/popo/utils.rb
74
+ - lib/popo/version.rb
88
75
  - lib/templates/envy.yml
89
76
  - popo.gemspec
90
77
  - script/Rakefile
@@ -97,37 +84,28 @@ files:
97
84
  - targets/production.rb
98
85
  - targets/staging.rb
99
86
  - targets/test.rb
100
- has_rdoc: true
101
- homepage: ""
87
+ homepage: ''
102
88
  licenses: []
103
-
104
89
  post_install_message:
105
90
  rdoc_options: []
106
-
107
- require_paths:
91
+ require_paths:
108
92
  - lib
109
- required_ruby_version: !ruby/object:Gem::Requirement
93
+ required_ruby_version: !ruby/object:Gem::Requirement
110
94
  none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- segments:
115
- - 0
116
- version: "0"
117
- required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
100
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- segments:
123
- - 0
124
- version: "0"
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
125
105
  requirements: []
126
-
127
106
  rubyforge_project: popo
128
- rubygems_version: 1.3.7
107
+ rubygems_version: 1.8.10
129
108
  signing_key:
130
109
  specification_version: 3
131
110
  summary: Popo ruby and rails repo tool
132
111
  test_files: []
133
-