aiwilliams-plugit 0.0.1
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/README.txt +64 -0
- data/lib/plugit/descriptor.rb +33 -0
- data/lib/plugit/environment.rb +30 -0
- data/lib/plugit/library.rb +49 -0
- data/lib/plugit/version.rb +9 -0
- data/lib/plugit.rb +11 -0
- data/plugit.gemspec +16 -0
- metadata +60 -0
data/README.txt
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
= plugit
|
2
|
+
|
3
|
+
* http://github.com/aiwilliams/plugit
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Having written a number of libraries, I have found that many of them depend on other libraries.
|
8
|
+
Often, those other libraries have multiple revisions and the people who use my libraries want
|
9
|
+
my libraries to work with all revisions of those other libraries. This can get hard to manage!
|
10
|
+
|
11
|
+
The goal of plugit is to make it easy to construct library environments within which you can
|
12
|
+
run tests, to show that your code works in more than just one environment. It also allows you
|
13
|
+
to keep from having copies of those libraries checked into your own repository. If they are
|
14
|
+
available for others to download, and you expect that they will, then you should have no problem
|
15
|
+
depending on them being available to you for future download, either!
|
16
|
+
|
17
|
+
This may all only prove useful to Rails plugin developers ;)
|
18
|
+
|
19
|
+
== FEATURES/PROBLEMS:
|
20
|
+
|
21
|
+
* FIX (list of features or problems)
|
22
|
+
|
23
|
+
== SYNOPSIS:
|
24
|
+
|
25
|
+
Plugit.describe do |mything|
|
26
|
+
mything.environment :default, 'The one we want everyone using' do |env|
|
27
|
+
env.library :example, '1.0', "cp -R #{File.dirname(__FILE__)}/../../../repositories/example/*"
|
28
|
+
env.library :another, '2.0', "svn co http://something.com/svn/ALibrary"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
The :default environment is loaded unless you specify otherwise through ENV['PLUGIT_ENV']. This is necessary since you will be
|
33
|
+
running your specs from Rakefile, which will load independent processes for each environment you want to run.
|
34
|
+
|
35
|
+
== REQUIREMENTS:
|
36
|
+
|
37
|
+
== INSTALL:
|
38
|
+
|
39
|
+
sudo gem install plugit --source=http://gems.github.com
|
40
|
+
|
41
|
+
== LICENSE:
|
42
|
+
|
43
|
+
(The MIT License)
|
44
|
+
|
45
|
+
Copyright (c) 2008 Adam Williams (aiwilliams)
|
46
|
+
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
48
|
+
a copy of this software and associated documentation files (the
|
49
|
+
'Software'), to deal in the Software without restriction, including
|
50
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
51
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
52
|
+
permit persons to whom the Software is furnished to do so, subject to
|
53
|
+
the following conditions:
|
54
|
+
|
55
|
+
The above copyright notice and this permission notice shall be
|
56
|
+
included in all copies or substantial portions of the Software.
|
57
|
+
|
58
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
59
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
60
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
61
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
62
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
63
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
64
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Plugit
|
2
|
+
class Descriptor
|
3
|
+
attr_writer :library_root_path
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@environments = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def environment(*init_args, &block)
|
10
|
+
@environments << (env = Environment.new(*init_args))
|
11
|
+
block.call(EnvironmentBuilder.new(env))
|
12
|
+
end
|
13
|
+
|
14
|
+
def install_environment(name)
|
15
|
+
Environment.library_root_path = @library_root_path || File.expand_path('environments')
|
16
|
+
env = @environments.detect {|e| e.name == name.to_sym}
|
17
|
+
env.libraries.each do |lib|
|
18
|
+
lib.update(env)
|
19
|
+
lib.install(env)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class EnvironmentBuilder
|
25
|
+
def initialize(env)
|
26
|
+
@env = env
|
27
|
+
end
|
28
|
+
|
29
|
+
def library(*init_args)
|
30
|
+
@env.add_library(Library.new(*init_args))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Plugit
|
2
|
+
class Environment
|
3
|
+
class UninitializedRootError < StandardError; end
|
4
|
+
|
5
|
+
class << self
|
6
|
+
attr_accessor :library_root_path
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :name, :description
|
10
|
+
|
11
|
+
def initialize(name, description)
|
12
|
+
@name, @description = name, description
|
13
|
+
@libraries = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_library(library)
|
17
|
+
@libraries << library
|
18
|
+
end
|
19
|
+
|
20
|
+
def libraries
|
21
|
+
@libraries.dup
|
22
|
+
end
|
23
|
+
|
24
|
+
def library_root_path
|
25
|
+
root_path = self.class.library_root_path
|
26
|
+
raise UninitializedRootError unless root_path
|
27
|
+
File.join(root_path, name.to_s)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Plugit
|
4
|
+
class Library
|
5
|
+
include FileUtils
|
6
|
+
|
7
|
+
attr_accessor :load_paths, :requires
|
8
|
+
attr_reader :name, :version, :scm_export_command
|
9
|
+
|
10
|
+
def initialize(name, version, scm_export_command)
|
11
|
+
@name, @version, @scm_export_command = name, version, scm_export_command
|
12
|
+
@load_paths = ['/lib']
|
13
|
+
@requires = []
|
14
|
+
yield self if block_given?
|
15
|
+
end
|
16
|
+
|
17
|
+
def after_update(&block)
|
18
|
+
@after_update = block
|
19
|
+
end
|
20
|
+
|
21
|
+
def checkout(target_path)
|
22
|
+
command = "#{scm_export_command} #{target_path}"
|
23
|
+
puts "Checking out #{name}: #{command}"
|
24
|
+
`#{command}`
|
25
|
+
end
|
26
|
+
|
27
|
+
def install(environment)
|
28
|
+
load_paths.each { |l| $LOAD_PATH << File.join(target_path(environment), l) }
|
29
|
+
Object.send :require, *requires unless requires.empty?
|
30
|
+
end
|
31
|
+
|
32
|
+
def update(environment, force = false)
|
33
|
+
target_path = self.target_path(environment)
|
34
|
+
mkdir_p(File.dirname(target_path))
|
35
|
+
if !File.directory?(target_path) || force
|
36
|
+
rm_rf(target_path)
|
37
|
+
checkout(target_path)
|
38
|
+
cd(target_path) do
|
39
|
+
instance_eval(&@after_update)
|
40
|
+
end if @after_update
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
def target_path(environment)
|
46
|
+
File.join(environment.library_root_path, name.to_s, version)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/lib/plugit.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/plugit/library'
|
2
|
+
require File.dirname(__FILE__) + '/plugit/environment'
|
3
|
+
require File.dirname(__FILE__) + '/plugit/descriptor'
|
4
|
+
|
5
|
+
module Plugit
|
6
|
+
def self.describe(&block)
|
7
|
+
descriptor = Descriptor.new
|
8
|
+
block.call(descriptor)
|
9
|
+
descriptor.install_environment(ENV['PLUGIT_ENV'] || :default)
|
10
|
+
end
|
11
|
+
end
|
data/plugit.gemspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "plugit"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.date = "2008-05-19"
|
5
|
+
s.summary = "Helping you write tests for code that depends on libraries"
|
6
|
+
s.email = "adam@thewilliams.ws"
|
7
|
+
s.homepage = "http://github.com/aiwilliams/plugit"
|
8
|
+
s.description = ""
|
9
|
+
s.has_rdoc = false
|
10
|
+
s.authors = ["Adam Williams"]
|
11
|
+
s.files = ["README.txt", "plugit.gemspec", "lib/plugit.rb", "lib/plugit/descriptor.rb", "lib/plugit/environment.rb", "lib/plugit/library.rb", "lib/plugit/version.rb"]
|
12
|
+
s.test_files = []
|
13
|
+
s.rdoc_options = ["--main", "README.txt"]
|
14
|
+
s.extra_rdoc_files = ["README.txt"]
|
15
|
+
# s.add_dependency("mime-types", ["> 0.0.0"])
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: aiwilliams-plugit
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-19 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: ""
|
17
|
+
email: adam@thewilliams.ws
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.txt
|
24
|
+
files:
|
25
|
+
- README.txt
|
26
|
+
- plugit.gemspec
|
27
|
+
- lib/plugit.rb
|
28
|
+
- lib/plugit/descriptor.rb
|
29
|
+
- lib/plugit/environment.rb
|
30
|
+
- lib/plugit/library.rb
|
31
|
+
- lib/plugit/version.rb
|
32
|
+
has_rdoc: false
|
33
|
+
homepage: http://github.com/aiwilliams/plugit
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options:
|
36
|
+
- --main
|
37
|
+
- README.txt
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
requirements: []
|
53
|
+
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.0.1
|
56
|
+
signing_key:
|
57
|
+
specification_version: 2
|
58
|
+
summary: Helping you write tests for code that depends on libraries
|
59
|
+
test_files: []
|
60
|
+
|