isolate-git 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
data/.gemtest ADDED
File without changes
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.sw[op]
2
+ tmp
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2012-12-31
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,7 @@
1
+ .autotest
2
+ .gitignore
3
+ History.txt
4
+ Manifest.txt
5
+ README.txt
6
+ Rakefile
7
+ lib/isolate/git.rb
data/README.txt ADDED
@@ -0,0 +1,81 @@
1
+ = isolate-git
2
+
3
+ * https://github.com/bhenderson/isolate-git
4
+
5
+ == DESCRIPTION:
6
+
7
+ Git plugin for Isolate.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ I now know why jbarnette did not add this functionality. There is no standard
12
+ way to build a gem from source. If you want to use this you have to make sure
13
+ you do a couple of things:
14
+
15
+ * make sure the git source url is cloneable from the machine that isolates.
16
+ * make sure that you have all the dependencies to build the gem (rake, hoe,
17
+ etc.) in your isolate environment.
18
+
19
+ == SYNOPSIS:
20
+
21
+ Require the file (usually in the Isolate file)
22
+
23
+ require 'isolate/git'
24
+
25
+ Add git source urls to gems in your Isolate file.
26
+
27
+ gem "your-cool-code", :git => "git://example.com/your/cool/code.git"
28
+
29
+ Isolate::Git adds an Isolate::Events hook for Entry/installing. For every
30
+ entry it checks if the :git option was added. Then does a git clone in a
31
+ subdirectory of your isolate path. Then it builds the gem if a gemspec file
32
+ exists or runs `rake package` if there is a Rakefile (assuming the use of
33
+ something like Hoe). If any of this fails it will try to get out of the way
34
+ and just let Isolate continue to try and install the gem.
35
+
36
+ My rational for this is that you should just be installing packaged gems. This
37
+ can be useful for code which has not been released (ever). Please let me know
38
+ (by way of pull requests) if there are other ways to build gems or bugs or
39
+ whatever.
40
+
41
+ == REQUIREMENTS:
42
+
43
+ * isolate
44
+
45
+ == INSTALL:
46
+
47
+ * gem install isolate-git
48
+
49
+ == DEVELOPERS:
50
+
51
+ After checking out the source, run:
52
+
53
+ $ rake newb
54
+
55
+ This task will install any missing dependencies, run the tests/specs,
56
+ and generate the RDoc.
57
+
58
+ == LICENSE:
59
+
60
+ (The MIT License)
61
+
62
+ Copyright (c) 2012 bhenderson
63
+
64
+ Permission is hereby granted, free of charge, to any person obtaining
65
+ a copy of this software and associated documentation files (the
66
+ 'Software'), to deal in the Software without restriction, including
67
+ without limitation the rights to use, copy, modify, merge, publish,
68
+ distribute, sublicense, and/or sell copies of the Software, and to
69
+ permit persons to whom the Software is furnished to do so, subject to
70
+ the following conditions:
71
+
72
+ The above copyright notice and this permission notice shall be
73
+ included in all copies or substantial portions of the Software.
74
+
75
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
76
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
77
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
78
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
79
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
80
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
81
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.plugin :isolate
7
+ Hoe.plugin :minitest
8
+
9
+ Hoe.spec 'isolate-git' do
10
+ developer 'Brian Henderson', 'henderson.bj@gmail.com'
11
+
12
+ dependency "isolate", "~> 3.2.2"
13
+ end
14
+
15
+ $:.unshift 'lib'
16
+ require 'isolate/git'
17
+
18
+ # vim: syntax=ruby
@@ -0,0 +1,120 @@
1
+ require 'isolate'
2
+ require 'fileutils'
3
+
4
+ module Isolate
5
+ class Git
6
+
7
+ VERSION = '0.1.0'
8
+
9
+ def self.setup entry
10
+ new(entry).setup
11
+ end
12
+
13
+ def initialize entry
14
+ @entry = entry
15
+ end
16
+
17
+ def build
18
+ gemspec_path = Dir['**/*.gemspec'].first.to_s
19
+
20
+ # does the repo contain a gemspec? Just build it.
21
+ if File.size? gemspec_path
22
+ sh 'gem', 'build', gemspec_path
23
+ # try running rake package. Projects that use Hoe for example don't come
24
+ # with a gemspec, but one can be built. One may have to add build
25
+ # dependencies to the Isolate file. ie. rake, hoe.
26
+ elsif File.size? 'Rakefile'
27
+ sh 'rake', 'package'
28
+ else
29
+ # don't know what to do
30
+ end
31
+
32
+ built_path = Dir['**/*.gem'].first.to_s
33
+
34
+ if File.size? built_path
35
+ built_path
36
+ else
37
+ log "unable to build or find #{@entry.name} gem"
38
+ false
39
+ end
40
+ end
41
+
42
+ def clone
43
+ src = @entry.options[:git]
44
+ name = @entry.name
45
+
46
+ unless sh 'git','clone', src, name
47
+ log "unable to clone #{src}"
48
+ end
49
+
50
+ name if File.directory? name
51
+ end
52
+
53
+ def git?
54
+ @entry.options.key? :git
55
+ end
56
+
57
+ # For each entry, if options[:git] exists try to clone the repo and build
58
+ # the gem. If either fails, warn and let Isolate continue doing it's normal
59
+ # thing.
60
+ def setup
61
+ return unless git?
62
+
63
+ Dir.chdir source_path do
64
+
65
+ path = clone
66
+
67
+ Dir.chdir path do
68
+
69
+ if name = build then
70
+ file = File.expand_path name
71
+
72
+ # private instance variable. When this is set Entry#install looks
73
+ # for a local file instead of trying to download by name
74
+ @entry.instance_variable_set :@file, file
75
+ end
76
+
77
+ end if path
78
+
79
+ end
80
+ end
81
+
82
+ # Where to put the git repos.
83
+ def source_path
84
+ src = File.join *[
85
+ sandbox.path,
86
+ ('..' if sandbox.multiruby?),
87
+ 'src'
88
+ ].compact
89
+
90
+ FileUtils.mkdir_p src
91
+
92
+ src
93
+ end
94
+
95
+ private
96
+
97
+ def log s
98
+ sandbox.log s
99
+ end
100
+
101
+ def sandbox
102
+ # I don't like looking in private variables
103
+ @sandbox ||= @entry.instance_variable_get(:@sandbox)
104
+ end
105
+
106
+ def sh *args
107
+ IO.popen(args) do |io|
108
+ log io.gets until io.eof?
109
+ end
110
+ $?.success?
111
+ end
112
+
113
+ end
114
+
115
+ # setup installing hook so that each entry that has a :git option is setup
116
+ # correctly for activiation.
117
+ Events.watch Entry, :installing do |entry|
118
+ Git.setup entry
119
+ end
120
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: isolate-git
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Brian Henderson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: isolate
16
+ requirement: &15163920 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *15163920
25
+ - !ruby/object:Gem::Dependency
26
+ name: minitest
27
+ requirement: &15163080 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '4.2'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *15163080
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &15162380 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '3.10'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *15162380
47
+ - !ruby/object:Gem::Dependency
48
+ name: hoe
49
+ requirement: &15161560 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *15161560
58
+ description: Git plugin for Isolate.
59
+ email:
60
+ - henderson.bj@gmail.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files:
64
+ - History.txt
65
+ - Manifest.txt
66
+ - README.txt
67
+ files:
68
+ - .autotest
69
+ - .gitignore
70
+ - History.txt
71
+ - Manifest.txt
72
+ - README.txt
73
+ - Rakefile
74
+ - lib/isolate/git.rb
75
+ - .gemtest
76
+ homepage: https://github.com/bhenderson/isolate-git
77
+ licenses: []
78
+ post_install_message:
79
+ rdoc_options:
80
+ - --main
81
+ - README.txt
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ requirements: []
97
+ rubyforge_project: isolate-git
98
+ rubygems_version: 1.8.11
99
+ signing_key:
100
+ specification_version: 3
101
+ summary: Git plugin for Isolate.
102
+ test_files: []