gem-milkode 1.0.2 → 1.0.3
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/Gemfile +21 -0
- data/README.md +1 -1
- data/gem-milkode.gemspec +34 -0
- data/lib/rubygems_plugin.rb +36 -22
- metadata +4 -2
data/Gemfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
|
7
|
+
# published by the Free Software Foundation, either version 3 of the
|
|
8
|
+
# License, or (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful, but
|
|
11
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
# Lesser General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
# License along with this program. If not, see
|
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
source :rubygems
|
|
20
|
+
|
|
21
|
+
gemspec
|
data/README.md
CHANGED
data/gem-milkode.gemspec
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
|
2
|
+
#
|
|
3
|
+
# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU Lesser General Public License as
|
|
7
|
+
# published by the Free Software Foundation, either version 3 of the
|
|
8
|
+
# License, or (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful, but
|
|
11
|
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
# Lesser General Public License for more details.
|
|
14
|
+
#
|
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
# License along with this program. If not, see
|
|
17
|
+
# <http://www.gnu.org/licenses/>.
|
|
18
|
+
|
|
19
|
+
Gem::Specification.new do |spec|
|
|
20
|
+
spec.name = "gem-milkode"
|
|
21
|
+
spec.version = "1.0.3"
|
|
22
|
+
spec.authors = ["Kouhei Sutou"]
|
|
23
|
+
spec.email = ["kou@cozmixng.org"]
|
|
24
|
+
spec.summary = "Make all installed gems milkable"
|
|
25
|
+
spec.description = "Add installed gems to Milkode index autamatically"
|
|
26
|
+
spec.homepage = "https://github.com/kou/gem-milkode"
|
|
27
|
+
|
|
28
|
+
spec.files = ["README.md", "COPYING", "Gemfile", "#{spec.name}.gemspec"]
|
|
29
|
+
spec.files += Dir.glob("lib/**/*.rb")
|
|
30
|
+
spec.require_paths = ["lib"]
|
|
31
|
+
|
|
32
|
+
spec.add_runtime_dependency("milkode")
|
|
33
|
+
spec.add_development_dependency("bundler")
|
|
34
|
+
end
|
data/lib/rubygems_plugin.rb
CHANGED
|
@@ -14,32 +14,46 @@
|
|
|
14
14
|
# License along with this program. If not, see
|
|
15
15
|
# <http://www.gnu.org/licenses/>.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
package_name = "gem-milkode"
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if user
|
|
25
|
-
milk_command_line.unshift("sudo", "-u", ENV["SUDO_USER"], "-H")
|
|
26
|
-
milkode_directory = File.expand_path("~#{user}/.milkode")
|
|
27
|
-
else
|
|
28
|
-
milkode_directory = File.expand_path("~/.milkode")
|
|
19
|
+
current_version = File.basename(File.dirname(File.dirname(__FILE__)))
|
|
20
|
+
rubygems_dir = File.join(File.dirname(__FILE__), "..", "..")
|
|
21
|
+
installed_directories = Dir.glob(File.join(rubygems_dir, "#{package_name}-*"))
|
|
22
|
+
installed_packages = installed_directories.collect do |directory|
|
|
23
|
+
File.basename(directory)
|
|
29
24
|
end
|
|
25
|
+
sorted_installed_versions = installed_packages.sort_by do |package_name|
|
|
26
|
+
package_name.gsub(/\A#{Regexp.escape(package_name)}-/, "")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
if current_version == sorted_installed_versions.last
|
|
30
|
+
require "rubygems"
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
milk_command_line = [
|
|
33
|
+
Gem.ruby,
|
|
34
|
+
Gem.bin_path("milkode", "milk"),
|
|
35
|
+
]
|
|
36
|
+
sudo_user = ENV["SUDO_USER"]
|
|
37
|
+
if sudo_user
|
|
38
|
+
milk_command_line.unshift("sudo", "-u", sudo_user, "-H")
|
|
39
|
+
milkode_directory = File.expand_path("~#{sudo_user}/.milkode")
|
|
40
|
+
else
|
|
41
|
+
milkode_directory = File.expand_path("~/.milkode")
|
|
34
42
|
end
|
|
35
|
-
end
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
end
|
|
44
|
+
ensure_init = lambda do
|
|
45
|
+
unless File.exist?(milkode_directory)
|
|
46
|
+
system(*(milk_command_line + ["init", "--default"]))
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
Gem.post_install do |installer|
|
|
51
|
+
ensure_init.call
|
|
52
|
+
system(*(milk_command_line + ["add", installer.gem_dir]))
|
|
53
|
+
end
|
|
41
54
|
|
|
42
|
-
Gem.post_uninstall do |uninstaller|
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
Gem.post_uninstall do |uninstaller|
|
|
56
|
+
ensure_init.call
|
|
57
|
+
system(*(milk_command_line + ["remove", uninstaller.spec.gem_dir]))
|
|
58
|
+
end
|
|
45
59
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: gem-milkode
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-10-
|
|
12
|
+
date: 2012-10-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: milkode
|
|
@@ -52,6 +52,8 @@ extra_rdoc_files: []
|
|
|
52
52
|
files:
|
|
53
53
|
- README.md
|
|
54
54
|
- COPYING
|
|
55
|
+
- Gemfile
|
|
56
|
+
- gem-milkode.gemspec
|
|
55
57
|
- lib/rubygems_plugin.rb
|
|
56
58
|
homepage: https://github.com/kou/gem-milkode
|
|
57
59
|
licenses: []
|