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 CHANGED
@@ -1,3 +1,6 @@
1
+ == 0.1.4
2
+ * Converted tests to bacon and tests pass on all major ruby versions
3
+
1
4
  == 0.1.3
2
5
  * Bug fix for 1.9 and Rubyforge release
3
6
 
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT LICENSE
2
2
 
3
- Copyright (c) 2009 Gabriel Horner
3
+ Copyright (c) 2010 Gabriel Horner
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -1,49 +1,35 @@
1
1
  require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
- begin
5
- require 'rcov/rcovtask'
2
+ require 'fileutils'
6
3
 
7
- Rcov::RcovTask.new do |t|
8
- t.libs << 'test'
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
- begin
18
- require 'jeweler'
19
- Jeweler::Tasks.new do |s|
20
- s.name = "local_gem"
21
- s.summary = "Loads any gem/library simply given its path. Great for nascent gems and/or for trying the latest code on a gem."
22
- 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."
23
- s.email = "gabriel.horner@gmail.com"
24
- s.homepage = "http://tagaholic.me/local_gem/"
25
- s.authors = ["Gabriel Horner"]
26
- s.rubyforge_project = 'tagaholic'
27
- s.has_rdoc = true
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
- rescue LoadError
32
- puts "Jeweler not available. Install it for jeweler-related tasks with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
20
+ desc "Generate the gemspec"
21
+ task :generate do
22
+ puts gemspec.to_ruby
33
23
  end
34
24
 
35
- Rake::TestTask.new do |t|
36
- t.libs << 'lib'
37
- t.pattern = 'test/**/*_test.rb'
38
- t.verbose = false
25
+ desc "Validate the gemspec"
26
+ task :gemspec do
27
+ gemspec.validate
39
28
  end
40
29
 
41
- Rake::RDocTask.new do |rdoc|
42
- rdoc.rdoc_dir = 'rdoc'
43
- rdoc.title = 'test'
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
- $:.unshift(File.dirname(__FILE__)) unless
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
@@ -0,0 +1,3 @@
1
+ module LocalGem
2
+ VERSION = '0.1.4'
3
+ end
@@ -1,70 +1,70 @@
1
1
  require File.join(File.dirname(__FILE__), 'test_helper')
2
2
 
3
- class LocalGem::Test < Test::Unit::TestCase
4
- before(:each) {
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
- test "local_gem adds gem's one path to $:" do
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
- assert !$:.include?(full_gem_path)
12
+ !$:.should.not.include?(full_gem_path)
13
13
  LocalGem.local_gem('gem1')
14
- assert $:.include?(full_gem_path)
14
+ $:.should.include?(full_gem_path)
15
15
  end
16
16
 
17
- test "local_gem adds gem's multiple paths to $:" do
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
- assert ($: & full_gem_paths).empty?
19
+ ($: & full_gem_paths).should.be.empty?
20
20
  LocalGem.local_gem('gem2')
21
- assert !($: & full_gem_paths).empty?
21
+ ($: & full_gem_paths).should.not.be.empty?
22
22
  end
23
23
 
24
- test "local_gem defaults to gem if no local gem found" do
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
- test "local_gem calls load_local_gem for a valid gem" do
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
- test "local_require calls load_local_gem and require" do
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
- test "setup_config with hash initializes config" do
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
- assert_equal config, LocalGem::Singleton.config
43
+ LocalGem::Singleton.config.should == config
44
44
  end
45
45
 
46
- test "setup_config with block initializes config" do
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
- assert_equal config, LocalGem::Singleton.config
51
+ LocalGem::Singleton.config.should == config
52
52
  end
53
53
 
54
- test "read_config uses existing config_file" do
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
- assert_equal 'blah', LocalGem::Singleton.config_file
59
+ LocalGem::Singleton.config_file.should == 'blah'
60
60
  end
61
61
 
62
- test "read_config uses config_file it detects" do
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
- assert 'local_gem.yml', File.basename(LocalGem::Singleton.config_file)
68
+ File.basename(LocalGem::Singleton.config_file).should == '.local_gem.yml'
69
69
  end
70
- end
70
+ end
@@ -1,20 +1,20 @@
1
1
  require File.join(File.dirname(__FILE__), 'test_helper')
2
2
 
3
- class LocalGem::OverrideTest < Test::Unit::TestCase
4
- before(:all) { require 'local_gem/override' }
5
- test "gem calls old_gem and load_local_gem" do
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
- test "require calls old_require and load_local_gem" do
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
- test "loading override should have included LocalGem in self" do
18
- assert self.instance_eval("class<<self; self; end").ancestors.include?(LocalGem)
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 'test/unit'
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
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ require 'mocha-on-bacon'
6
5
  require 'local_gem'
7
6
 
8
- class Test::Unit::TestCase
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
- version: 0.1.3
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: 2009-10-22 00:00:00 -04:00
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
- - README.rdoc
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
- - --charset=UTF-8
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
- version: "0"
57
- version:
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.5
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
- - test/local_gem_test.rb
67
- - test/override_test.rb
68
- - test/test_helper.rb
114
+ test_files: []
115
+
data/VERSION.yml DELETED
@@ -1,4 +0,0 @@
1
- ---
2
- :major: 0
3
- :minor: 1
4
- :patch: 3
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