local_gem 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +3 -0
- data/LICENSE.txt +1 -1
- data/Rakefile +24 -38
- data/gemspec +20 -0
- data/lib/local_gem.rb +19 -3
- data/lib/local_gem/version.rb +3 -0
- data/test/local_gem_test.rb +20 -20
- data/test/override_test.rb +6 -6
- data/test/test_helper.rb +6 -6
- metadata +69 -22
- data/VERSION.yml +0 -4
- data/lib/config_struct.rb +0 -18
data/CHANGELOG.rdoc
CHANGED
data/LICENSE.txt
CHANGED
data/Rakefile
CHANGED
@@ -1,49 +1,35 @@
|
|
1
1
|
require 'rake'
|
2
|
-
require '
|
3
|
-
require 'rake/rdoctask'
|
4
|
-
begin
|
5
|
-
require 'rcov/rcovtask'
|
2
|
+
require 'fileutils'
|
6
3
|
|
7
|
-
|
8
|
-
|
9
|
-
t.test_files = FileList['test/**/*_test.rb']
|
10
|
-
t.rcov_opts = ["-T -x '/Library/Ruby/*'"]
|
11
|
-
t.verbose = true
|
12
|
-
end
|
13
|
-
rescue LoadError
|
14
|
-
puts "Rcov not available. Install it for rcov-related tasks with: sudo gem install rcov"
|
4
|
+
def gemspec
|
5
|
+
@gemspec ||= eval(File.read('gemspec'), binding, 'gemspec')
|
15
6
|
end
|
16
7
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
s.files = FileList["CHANGELOG.rdoc", "VERSION.yml","Rakefile", "README.rdoc", "LICENSE.txt", "{bin,lib,test}/**/*"]
|
29
|
-
end
|
8
|
+
desc "Build the gem"
|
9
|
+
task :gem=>:gemspec do
|
10
|
+
sh "gem build gemspec"
|
11
|
+
FileUtils.mkdir_p 'pkg'
|
12
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Install the gem locally"
|
16
|
+
task :install => :gem do
|
17
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}}
|
18
|
+
end
|
30
19
|
|
31
|
-
|
32
|
-
|
20
|
+
desc "Generate the gemspec"
|
21
|
+
task :generate do
|
22
|
+
puts gemspec.to_ruby
|
33
23
|
end
|
34
24
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
t.verbose = false
|
25
|
+
desc "Validate the gemspec"
|
26
|
+
task :gemspec do
|
27
|
+
gemspec.validate
|
39
28
|
end
|
40
29
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
45
|
-
rdoc.rdoc_files.include('README*')
|
46
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
30
|
+
desc 'Run tests'
|
31
|
+
task :test do |t|
|
32
|
+
sh 'bacon -q -Ilib -I. test/*_test.rb'
|
47
33
|
end
|
48
34
|
|
49
|
-
task :default => :test
|
35
|
+
task :default => :test
|
data/gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'rubygems' unless Object.const_defined?(:Gem)
|
3
|
+
require File.dirname(__FILE__) + "/lib/local_gem/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "local_gem"
|
7
|
+
s.version = LocalGem::VERSION
|
8
|
+
s.authors = ["Gabriel Horner"]
|
9
|
+
s.email = "gabriel.horner@gmail.com"
|
10
|
+
s.homepage = "http://tagaholic.me/local_gem/"
|
11
|
+
s.summary = "Loads any gem/library simply given its path. Great for nascent gems and/or for trying the latest code on a gem."
|
12
|
+
s.description = "You have the beginnings of a ruby library and you want to access it quick. You don't want to bother making a gemspec for it and uninstalling/reinstalling its gem while you mess with it. Simply tell LocalGem what paths it should load for your local gem and they will be loaded. Note that it doesn't matter how gem-like your project is ie lib and bin directories etc. LocalGem only needs to know the full path to your gem/library."
|
13
|
+
s.required_rubygems_version = ">= 1.3.6"
|
14
|
+
s.rubyforge_project = 'tagaholic'
|
15
|
+
s.add_development_dependency 'bacon'
|
16
|
+
s.add_development_dependency 'mocha'
|
17
|
+
s.add_development_dependency 'mocha-on-bacon'
|
18
|
+
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c}]) + %w{Rakefile gemspec}
|
19
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
20
|
+
end
|
data/lib/local_gem.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
-
require 'config_struct'
|
1
|
+
require 'ostruct'
|
4
2
|
require 'yaml'
|
3
|
+
require 'local_gem/version'
|
5
4
|
|
6
5
|
module LocalGem
|
7
6
|
extend self
|
@@ -63,4 +62,21 @@ module LocalGem
|
|
63
62
|
end
|
64
63
|
end
|
65
64
|
end
|
65
|
+
|
66
|
+
class ConfigStruct < OpenStruct
|
67
|
+
# Converts the data within the given block to hash
|
68
|
+
def self.block_to_hash(block=nil)
|
69
|
+
config = self.new
|
70
|
+
if block
|
71
|
+
block.call(config)
|
72
|
+
config.to_hash
|
73
|
+
else
|
74
|
+
{}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def to_hash #:nodoc:
|
79
|
+
@table
|
80
|
+
end
|
81
|
+
end
|
66
82
|
end
|
data/test/local_gem_test.rb
CHANGED
@@ -1,70 +1,70 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
before
|
3
|
+
describe "LocalGem" do
|
4
|
+
before {
|
5
5
|
LocalGem::Singleton.config = { :gems=>{
|
6
6
|
'gem1'=>'path1', 'gem2'=>['path2','path3']}
|
7
7
|
}
|
8
8
|
}
|
9
9
|
|
10
|
-
|
10
|
+
it "local_gem adds gem's one path to $:" do
|
11
11
|
full_gem_path = File.expand_path(LocalGem::Singleton.config[:gems]['gem1'])
|
12
|
-
|
12
|
+
!$:.should.not.include?(full_gem_path)
|
13
13
|
LocalGem.local_gem('gem1')
|
14
|
-
|
14
|
+
$:.should.include?(full_gem_path)
|
15
15
|
end
|
16
16
|
|
17
|
-
|
17
|
+
it "local_gem adds gem's multiple paths to $:" do
|
18
18
|
full_gem_paths = LocalGem::Singleton.config[:gems]['gem2'].map {|e| File.expand_path(e) }
|
19
|
-
|
19
|
+
($: & full_gem_paths).should.be.empty?
|
20
20
|
LocalGem.local_gem('gem2')
|
21
|
-
|
21
|
+
($: & full_gem_paths).should.not.be.empty?
|
22
22
|
end
|
23
23
|
|
24
|
-
|
24
|
+
it "local_gem defaults to gem if no local gem found" do
|
25
25
|
LocalGem::Singleton.expects(:gem).once
|
26
26
|
LocalGem.local_gem('invalid')
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
it "local_gem calls load_local_gem for a valid gem" do
|
30
30
|
LocalGem::Singleton.expects(:load_local_gem).once.returns(true)
|
31
31
|
LocalGem.local_gem('blah')
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
it "local_require calls load_local_gem and require" do
|
35
35
|
LocalGem::Singleton.expects(:require).once
|
36
36
|
LocalGem::Singleton.expects(:load_local_gem).once
|
37
37
|
LocalGem.local_require('blah')
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
it "setup_config with hash initializes config" do
|
41
41
|
config = {:gems=>{'blah_gem'=>'blah_path'}}
|
42
42
|
LocalGem::Singleton.setup_config(config)
|
43
|
-
|
43
|
+
LocalGem::Singleton.config.should == config
|
44
44
|
end
|
45
45
|
|
46
|
-
|
46
|
+
it "setup_config with block initializes config" do
|
47
47
|
config = {:gems=>{'blah_gem'=>'blah_path'}}
|
48
48
|
LocalGem::Singleton.setup_config do |c|
|
49
49
|
c.gems = config[:gems]
|
50
50
|
end
|
51
|
-
|
51
|
+
LocalGem::Singleton.config.should == config
|
52
52
|
end
|
53
53
|
|
54
|
-
|
54
|
+
it "read_config uses existing config_file" do
|
55
55
|
LocalGem::Singleton.config_file = 'blah'
|
56
56
|
File.expects(:new)
|
57
57
|
YAML::expects(:load)
|
58
58
|
LocalGem::Singleton.read_config
|
59
|
-
|
59
|
+
LocalGem::Singleton.config_file.should == 'blah'
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
it "read_config uses config_file it detects" do
|
63
63
|
LocalGem::Singleton.config_file = nil
|
64
64
|
File.expects(:new)
|
65
65
|
YAML::expects(:load)
|
66
66
|
File.expects(:exists?).times(2).returns(false, true)
|
67
67
|
LocalGem::Singleton.read_config
|
68
|
-
|
68
|
+
File.basename(LocalGem::Singleton.config_file).should == '.local_gem.yml'
|
69
69
|
end
|
70
|
-
end
|
70
|
+
end
|
data/test/override_test.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
describe "Override" do
|
4
|
+
before_all { require 'local_gem/override' }
|
5
|
+
it "gem calls old_gem and load_local_gem" do
|
6
6
|
LocalGem::Singleton.expects(:load_local_gem).once
|
7
7
|
self.expects(:old_gem).once
|
8
8
|
gem('blah')
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
it "require calls old_require and load_local_gem" do
|
12
12
|
LocalGem::Singleton.expects(:load_local_gem).once
|
13
13
|
self.expects(:old_require).once
|
14
14
|
require('blah')
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
it "loading override should have included LocalGem in self" do
|
18
|
+
self.instance_eval("class<<self; self; end").ancestors.should.include?(LocalGem)
|
19
19
|
end
|
20
20
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require '
|
3
|
-
require 'context' #gem install jeremymcanally-context -s http://gems.github.com
|
1
|
+
require 'rubygems' # needed for override tests
|
2
|
+
require 'bacon'
|
4
3
|
require 'mocha'
|
5
|
-
|
4
|
+
require 'mocha-on-bacon'
|
6
5
|
require 'local_gem'
|
7
6
|
|
8
|
-
class
|
9
|
-
end
|
7
|
+
class Bacon::Context
|
8
|
+
def before_all; yield; end
|
9
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: local_gem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 4
|
9
|
+
version: 0.1.4
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Gabriel Horner
|
@@ -9,10 +14,48 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-06-10 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bacon
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: mocha
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mocha-on-bacon
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id003
|
16
59
|
description: You have the beginnings of a ruby library and you want to access it quick. You don't want to bother making a gemspec for it and uninstalling/reinstalling its gem while you mess with it. Simply tell LocalGem what paths it should load for your local gem and they will be loaded. Note that it doesn't matter how gem-like your project is ie lib and bin directories etc. LocalGem only needs to know the full path to your gem/library.
|
17
60
|
email: gabriel.horner@gmail.com
|
18
61
|
executables: []
|
@@ -20,49 +63,53 @@ executables: []
|
|
20
63
|
extensions: []
|
21
64
|
|
22
65
|
extra_rdoc_files:
|
23
|
-
- LICENSE.txt
|
24
66
|
- README.rdoc
|
25
|
-
files:
|
26
|
-
- CHANGELOG.rdoc
|
27
67
|
- LICENSE.txt
|
28
|
-
|
29
|
-
- Rakefile
|
30
|
-
- VERSION.yml
|
31
|
-
- lib/config_struct.rb
|
32
|
-
- lib/local_gem.rb
|
68
|
+
files:
|
33
69
|
- lib/local_gem/override.rb
|
70
|
+
- lib/local_gem/version.rb
|
71
|
+
- lib/local_gem.rb
|
34
72
|
- test/local_gem_test.rb
|
35
73
|
- test/override_test.rb
|
36
74
|
- test/test_helper.rb
|
75
|
+
- LICENSE.txt
|
76
|
+
- CHANGELOG.rdoc
|
77
|
+
- README.rdoc
|
78
|
+
- Rakefile
|
79
|
+
- gemspec
|
37
80
|
has_rdoc: true
|
38
81
|
homepage: http://tagaholic.me/local_gem/
|
39
82
|
licenses: []
|
40
83
|
|
41
84
|
post_install_message:
|
42
|
-
rdoc_options:
|
43
|
-
|
85
|
+
rdoc_options: []
|
86
|
+
|
44
87
|
require_paths:
|
45
88
|
- lib
|
46
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
47
91
|
requirements:
|
48
92
|
- - ">="
|
49
93
|
- !ruby/object:Gem::Version
|
94
|
+
segments:
|
95
|
+
- 0
|
50
96
|
version: "0"
|
51
|
-
version:
|
52
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
53
99
|
requirements:
|
54
100
|
- - ">="
|
55
101
|
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
102
|
+
segments:
|
103
|
+
- 1
|
104
|
+
- 3
|
105
|
+
- 6
|
106
|
+
version: 1.3.6
|
58
107
|
requirements: []
|
59
108
|
|
60
109
|
rubyforge_project: tagaholic
|
61
|
-
rubygems_version: 1.3.
|
110
|
+
rubygems_version: 1.3.7
|
62
111
|
signing_key:
|
63
112
|
specification_version: 3
|
64
113
|
summary: Loads any gem/library simply given its path. Great for nascent gems and/or for trying the latest code on a gem.
|
65
|
-
test_files:
|
66
|
-
|
67
|
-
- test/override_test.rb
|
68
|
-
- test/test_helper.rb
|
114
|
+
test_files: []
|
115
|
+
|
data/VERSION.yml
DELETED
data/lib/config_struct.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'ostruct'
|
2
|
-
|
3
|
-
class ConfigStruct < OpenStruct
|
4
|
-
# Converts the data within the given block to hash
|
5
|
-
def self.block_to_hash(block=nil)
|
6
|
-
config = self.new
|
7
|
-
if block
|
8
|
-
block.call(config)
|
9
|
-
config.to_hash
|
10
|
-
else
|
11
|
-
{}
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_hash #:nodoc:
|
16
|
-
@table
|
17
|
-
end
|
18
|
-
end
|