fnando-pez 0.0.2

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/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2008-09-01
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Nando Vieira
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,77 @@
1
+ pez
2
+ ===
3
+
4
+ * [http://github.com/fnando/pez](http://github.com/fnando/pez)
5
+
6
+ DESCRIPTION:
7
+ ------------
8
+
9
+ pez is a simple tool to manage plugins from GIT and Subversion repositories in
10
+ a easy way. Instead of adding plugins to the project repository, pez
11
+ checkouts/clones the specified version to a temporary directory and
12
+ creates a symlink to the Ruby on Rails plugin directory.
13
+
14
+ When pez is asked to update the plugins, it runs the correct command in that
15
+ directory, based on the repository type (GIT or Subversion), which in turn is
16
+ applied to the project through the symlink.
17
+
18
+ pez allows different environments to update plugins from a different directory.
19
+ So, when you deploy your Ruby on Rails application, you won't have to
20
+ checkout/update all plugins again, unless you explicit say so.
21
+
22
+ pez is based on braid (which I never had it working) but way simpler.
23
+
24
+ INSTALLATION:
25
+ -------------
26
+
27
+ git clone git://github.com/fnando/pez.git
28
+ cd pez
29
+ rake gem:install
30
+
31
+ or
32
+
33
+ sudo gem install fnando-pez --source=http://gems.github.com
34
+
35
+ USAGE:
36
+ ------
37
+
38
+ Run the command `pez setup` from your project root to create the file
39
+ `config/plugins.yml`. Then you can manage plugins with the following commands:
40
+
41
+ pez add git://github.com/fnando/has_cache.git
42
+ pez add http://some-url.com/fnando/has_cache --type=svn
43
+ pez update has_cache
44
+ pez update --all
45
+ pez show --all
46
+ pez remove has_cache
47
+ pez remove --all
48
+ pez symlink
49
+
50
+ MAINTAINER
51
+ ----------
52
+
53
+ * Nando Vieira ([http://simplesideias.com.br](http://simplesideias.com.br))
54
+
55
+ LICENSE:
56
+ --------
57
+
58
+ (The MIT License)
59
+
60
+ Permission is hereby granted, free of charge, to any person obtaining
61
+ a copy of this software and associated documentation files (the
62
+ 'Software'), to deal in the Software without restriction, including
63
+ without limitation the rights to use, copy, modify, merge, publish,
64
+ distribute, sublicense, and/or sell copies of the Software, and to
65
+ permit persons to whom the Software is furnished to do so, subject to
66
+ the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be
69
+ included in all copies or substantial portions of the Software.
70
+
71
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
72
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
73
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
74
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
75
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
76
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
77
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,74 @@
1
+ require 'rake'
2
+
3
+ PKG_FILES = %w(Rakefile pez.gemspec History.txt License.txt README.markdown TODO.txt templates/plugins.yml) +
4
+ Dir["{bin,lib}/**/*"]
5
+
6
+ spec = Gem::Specification.new do |s|
7
+ s.name = "pez"
8
+ s.version = "0.0.2"
9
+ s.summary = "Manage Ruby on Rails plugins from GIT and Subversion repositories in a simple way"
10
+ s.authors = ["Nando Vieira"]
11
+ s.email = ["fnando.vieira@gmail.com"]
12
+ s.homepage = "http://github.com/fnando/pez"
13
+ s.description = "A simpler plugin manager that checkouts/clones the repository and just do the updates right in"
14
+ s.has_rdoc = false
15
+ s.files = PKG_FILES
16
+ s.bindir = "bin"
17
+ s.executables = "pez"
18
+
19
+ s.add_dependency "rubigen"
20
+ s.add_dependency "main"
21
+ s.requirements << "You'll need GIT and Subversion installed"
22
+ end
23
+
24
+ namespace :gem do
25
+ # Thanks to the Merb project for this code.
26
+ desc "Update Github Gemspec"
27
+ task :update_gemspec do
28
+ skip_fields = %w(new_platform original_platform specification_version loaded required_ruby_version rubygems_version platform )
29
+
30
+ result = "# WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!\n"
31
+ result << "# RUN : 'rake gem:update_gemspec'\n\n"
32
+ result << "Gem::Specification.new do |s|\n"
33
+
34
+ spec.instance_variables.each do |ivar|
35
+ value = spec.instance_variable_get(ivar)
36
+ name = ivar.split("@").last
37
+ value = Time.now if name == "date"
38
+
39
+ next if skip_fields.include?(name) || value.nil? || value == "" || (value.respond_to?(:empty?) && value.empty?)
40
+ if name == "dependencies"
41
+ value.each do |d|
42
+ dep, *ver = d.to_s.split(" ")
43
+ result << " s.add_dependency #{dep.inspect}, #{ver.join(" ").inspect.gsub(/[()]/, "").gsub(", runtime", "")}\n"
44
+ end
45
+ else
46
+ case value
47
+ when Array
48
+ value = name != "files" ? value.inspect : value.inspect.split(",").join(",\n")
49
+ when FalseClass
50
+ when TrueClass
51
+ when Fixnum
52
+ when String
53
+ value = value.inspect
54
+ else
55
+ value = value.to_s.inspect
56
+ end
57
+ result << " s.#{name} = #{value}\n"
58
+ end
59
+ end
60
+
61
+ result << "end"
62
+ File.open(File.join(File.dirname(__FILE__), "#{spec.name}.gemspec"), "w"){|f| f << result}
63
+ end
64
+
65
+ desc "Build gem"
66
+ task :build => [:update_gemspec] do
67
+ system "gem build #{spec.instance_variable_get('@name')}.gemspec"
68
+ end
69
+
70
+ desc "Install gem"
71
+ task :install => [:update_gemspec, :build] do
72
+ system "sudo gem install #{spec.instance_variable_get('@name')}"
73
+ end
74
+ end
data/TODO.txt ADDED
@@ -0,0 +1,2 @@
1
+ - Add git branch support
2
+ - Add svn revision checkout
data/bin/pez ADDED
@@ -0,0 +1,186 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
4
+ require 'pez'
5
+
6
+ # hey, this was taken from braid! thanks guys!
7
+ Main {
8
+ description <<-TXT
9
+ pez is a simple tool to manage Ruby on Rails plugins from GIT or Subversion repositories.
10
+
11
+ Run 'pez help commandname' for more details.
12
+ TXT
13
+
14
+ mode(:add) {
15
+ description <<-TXT
16
+ Add a new mirror to be tracked.
17
+
18
+ * adds metadata about the mirror to config/plugins.yml
19
+ * fetches and merges remote code into given directory
20
+
21
+ --type defaults:
22
+
23
+ * svn://path # => svn
24
+ * git://path # => git
25
+ * http://path/trunk # => svn
26
+ * http://path.git # => git
27
+
28
+ Name defaults:
29
+
30
+ * remote/path # => path
31
+ * remote/path/trunk # => path
32
+ * remote/path.git # => path
33
+ TXT
34
+
35
+ examples <<-TXT
36
+ . pez add svn://remote/path
37
+ . pez add svn://remote/path --type=git
38
+ . pez add git://remote/path --name=some_plugin_name
39
+ TXT
40
+
41
+ mixin :argument_url, :option_type, :option_name
42
+
43
+ run {
44
+ Pez::Command.add(url, { :type => type, :name => name })
45
+ }
46
+ }
47
+
48
+ mode(:update) {
49
+ description <<-TXT
50
+ Update a plugin mirror.
51
+
52
+ * get new changes from remote
53
+ * checkout/clone the repository when directory is missing
54
+ TXT
55
+
56
+ examples <<-TXT
57
+ . pez update plugin_name
58
+ . pez update --all
59
+ TXT
60
+
61
+ mixin :optional_name, :option_all
62
+
63
+ run {
64
+ Pez::Command.update(name, { :all => all })
65
+ }
66
+ }
67
+
68
+ mode(:remove) {
69
+ description <<-TXT
70
+ Remove a mirror.
71
+
72
+ * removes metadata from config/plugins.yml
73
+ * removes the local directory and commits the removal
74
+ * removes the vendor/plugin symlink
75
+ TXT
76
+
77
+ examples <<-TXT
78
+ . pez remove plugin_name
79
+ . pez remove --all
80
+ TXT
81
+
82
+ mixin :optional_name, :option_all
83
+
84
+ run {
85
+ Pez::Command.remove(name, {:all => all})
86
+ }
87
+ }
88
+
89
+ mode(:show) {
90
+ description <<-TXT
91
+ Show mirror info.
92
+ TXT
93
+
94
+ examples <<-TXT
95
+ . pez show plugin_name
96
+ . pez show --all
97
+ TXT
98
+
99
+ mixin :optional_name, :option_all
100
+
101
+ run {
102
+ Pez::Command.show(name, {:all => all})
103
+ }
104
+ }
105
+
106
+ mode(:setup) {
107
+ description <<-TXT
108
+ Create the config file.
109
+ TXT
110
+
111
+ examples <<-TXT
112
+ pez setup
113
+ TXT
114
+
115
+ run {
116
+ Pez::Command.setup
117
+ }
118
+ }
119
+
120
+ mode(:version) {
121
+ description 'Show pez version.'
122
+
123
+ run {
124
+ puts "pez #{Pez::VERSION}"
125
+ }
126
+ }
127
+
128
+ mode(:symlink) {
129
+ description <<-TXT
130
+ Create the symlinks.
131
+
132
+ * if a plugin source directory doesn't exist, pez will get it first
133
+ TXT
134
+
135
+ run {
136
+ Pez::Command.symlink
137
+ }
138
+ }
139
+
140
+ mixin(:argument_path) {
141
+ argument(:path) {
142
+ attr
143
+ }
144
+ }
145
+
146
+ mixin(:argument_url) {
147
+ argument(:url) {
148
+ attr
149
+ }
150
+ }
151
+
152
+ mixin(:option_type) {
153
+ option(:type, :t) {
154
+ optional
155
+ argument :required
156
+ desc 'mirror type'
157
+ attr
158
+ }
159
+ }
160
+
161
+ mixin(:option_name) {
162
+ option(:name, :n) {
163
+ optional
164
+ argument :required
165
+ desc 'plugin name'
166
+ attr
167
+ }
168
+ }
169
+
170
+ mixin(:option_all) {
171
+ option(:all, :a) {
172
+ optional
173
+ desc 'apply to all plugins'
174
+ attr
175
+ }
176
+ }
177
+
178
+ mixin(:optional_name) {
179
+ argument(:name) {
180
+ optional
181
+ attr
182
+ }
183
+ }
184
+
185
+ run { help! }
186
+ }
data/lib/pez/base.rb ADDED
@@ -0,0 +1,146 @@
1
+ module Pez
2
+ VERSION = "0.0.2"
3
+ CONFIG_FILE = File.dirname(__FILE__) + '/../../templates/plugins.yml'
4
+
5
+ module Base
6
+ def self.git?(url, options={})
7
+ options["type"] == "git" || url =~ /^git:/ || url =~ /\.git$/
8
+ end
9
+
10
+ def self.name(url, options={})
11
+ return options[:name] if options[:name]
12
+
13
+ if git?(url, options)
14
+ m, name = *url.match(/\/([^\/]+)\.git$/)
15
+ else
16
+ m, name = *url.match(/\/([^\/]+)\/?(?:trunk\/?)?$/)
17
+ end
18
+
19
+ name
20
+ end
21
+
22
+ def self.config
23
+ YAML.load_file('config/plugins.yml')
24
+ end
25
+
26
+ def self.add_to_config(name, url, options={})
27
+ c = config
28
+ c['plugins'] ||= {}
29
+ c['plugins'][name] = {'repo' => url, 'type' => options[:type]}
30
+
31
+ File.open('config/plugins.yml', 'w+') do |f|
32
+ f << YAML::dump(c)
33
+ end
34
+ end
35
+
36
+ def self.remove_from_config(name)
37
+ c = config
38
+ c['plugins'] ||= {}
39
+ c['plugins'].delete(name)
40
+
41
+ File.open('config/plugins.yml', 'w+') do |f|
42
+ f << YAML::dump(c)
43
+ end
44
+
45
+ system "rm -rf #{destination}/#{name}"
46
+ system "rm vendor/plugins/#{name}"
47
+ end
48
+
49
+ def self.destination
50
+ config[Rails.env] || 'tmp/plugins'
51
+ end
52
+
53
+ def self.plugins(name, options={})
54
+ if name
55
+ [name]
56
+ elsif options[:all]
57
+ Pez::Base.config["plugins"].keys
58
+ else
59
+ []
60
+ end
61
+ end
62
+ end
63
+
64
+ module Command
65
+ def self.setup
66
+ puts 'Configuration file already generated at config/plugins.yml' and return if File.exists?('config/plugins.yml')
67
+
68
+ File.open('config/plugins.yml', 'w') do |f|
69
+ base_path = IO.popen('pwd').read.chomp
70
+ contents = File.read(CONFIG_FILE)
71
+ contents.gsub!(/%base_path%/, base_path)
72
+
73
+ f << contents
74
+ end
75
+ end
76
+
77
+ def self.add(url, options={}, skip_config=false)
78
+ name = Pez::Base.name(url, options)
79
+
80
+ puts "Retrieving #{name}..."
81
+
82
+ if Pez::Base.git?(url, options)
83
+ options[:type] = "git"
84
+ system "mkdir -p #{Pez::Base.destination}; cd #{Pez::Base.destination}; git clone #{url} #{name}"
85
+ else
86
+ options[:type] = "svn"
87
+ system "mkdir -p #{Pez::Base.destination}; cd #{Pez::Base.destination}; svn co #{url} #{name}"
88
+ end
89
+
90
+ puts
91
+ Pez::Base.add_to_config(name, url, options) unless skip_config
92
+ system "ln -s #{Pez::Base.destination}/#{name} vendor/plugins/#{name}"
93
+ end
94
+
95
+ def self.remove(name=nil, options={})
96
+ Pez::Base.plugins(name, options).each {|name| Pez::Base.remove_from_config(name) }
97
+ end
98
+
99
+ def self.update(name=nil, options={})
100
+ c = Pez::Base.config
101
+
102
+ Pez::Base.plugins(name, options).each do |name|
103
+ dirname = "#{Pez::Base.destination}/#{name}"
104
+ data = c['plugins'][name]
105
+
106
+ puts "Retrieving #{name}..."
107
+
108
+ if File.directory?(dirname)
109
+ if data['type'] == 'git'
110
+ system "cd #{dirname}; git pull"
111
+ else
112
+ system "cd #{dirname}; svn up"
113
+ end
114
+ else
115
+ add(data['repo'], {:type => data['type'], :name => name}, true)
116
+ end
117
+
118
+ puts
119
+ end
120
+ end
121
+
122
+ def self.symlink
123
+ c = Pez::Base.config
124
+
125
+ Pez::Base.plugins(nil, {:all => 'all'}).each do |name|
126
+ dirname = "#{Pez::Base.destination}/#{name}"
127
+
128
+ if File.directory?(dirname)
129
+ system "ln -s #{dirname} vendor/plugins/#{name}"
130
+ else
131
+ add(data['repo'], {:type => data['type'], :name => name}, true)
132
+ end
133
+ end
134
+ end
135
+
136
+ def self.show(name=nil, options={})
137
+ c = Pez::Base.config
138
+
139
+ Pez::Base.plugins(name, options).each do |name|
140
+ puts "Plugin: %s" % name
141
+ puts "Repository: %s" % c['plugins'][name]['repo']
142
+ puts
143
+ end
144
+ end
145
+ end
146
+ end
data/lib/pez.rb ADDED
@@ -0,0 +1,20 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require "rubygems"
5
+ require "main"
6
+ require "yaml"
7
+ require "fileutils"
8
+ require "pez/base"
9
+
10
+ begin
11
+ require "config/environment"
12
+ rescue LoadError => e
13
+ nil
14
+ end
15
+
16
+ begin
17
+ require "ruby-debug"
18
+ rescue LoadError => e
19
+ nil
20
+ end
data/pez.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ # WARNING : RAKE AUTO-GENERATED FILE. DO NOT MANUALLY EDIT!
2
+ # RUN : 'rake gem:update_gemspec'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.date = "Mon Sep 01 21:04:00 -0300 2008"
6
+ s.executables = ["pez"]
7
+ s.authors = ["Nando Vieira"]
8
+ s.required_rubygems_version = ">= 0"
9
+ s.version = "0.0.2"
10
+ s.files = ["Rakefile",
11
+ "pez.gemspec",
12
+ "History.txt",
13
+ "License.txt",
14
+ "README.markdown",
15
+ "TODO.txt",
16
+ "templates/plugins.yml",
17
+ "bin/pez",
18
+ "lib/pez",
19
+ "lib/pez/base.rb",
20
+ "lib/pez.rb"]
21
+ s.has_rdoc = false
22
+ s.requirements = ["You'll need GIT and Subversion installed"]
23
+ s.email = ["fnando.vieira@gmail.com"]
24
+ s.name = "pez"
25
+ s.bindir = "bin"
26
+ s.homepage = "http://github.com/fnando/pez"
27
+ s.summary = "Manage Ruby on Rails plugins from GIT and Subversion repositories in a simple way"
28
+ s.description = "A simpler plugin manager that checkouts/clones the repository and just do the updates right in"
29
+ s.add_dependency "rubigen", ">= 0"
30
+ s.add_dependency "main", ">= 0"
31
+ s.require_paths = ["lib"]
32
+ end
@@ -0,0 +1,2 @@
1
+ development: %base_path%/tmp/plugins
2
+ production: %base_path%/tmp/plugins
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fnando-pez
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Nando Vieira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-09-01 17:04:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubigen
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: main
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: "0"
32
+ version:
33
+ description: A simpler plugin manager that checkouts/clones the repository and just do the updates right in
34
+ email:
35
+ - fnando.vieira@gmail.com
36
+ executables:
37
+ - pez
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - Rakefile
44
+ - pez.gemspec
45
+ - History.txt
46
+ - License.txt
47
+ - README.markdown
48
+ - TODO.txt
49
+ - templates/plugins.yml
50
+ - bin/pez
51
+ - lib/pez
52
+ - lib/pez/base.rb
53
+ - lib/pez.rb
54
+ has_rdoc: false
55
+ homepage: http://github.com/fnando/pez
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: "0"
66
+ version:
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: "0"
72
+ version:
73
+ requirements:
74
+ - You'll need GIT and Subversion installed
75
+ rubyforge_project:
76
+ rubygems_version: 1.2.0
77
+ signing_key:
78
+ specification_version: 2
79
+ summary: Manage Ruby on Rails plugins from GIT and Subversion repositories in a simple way
80
+ test_files: []
81
+