depend 0.0.1.pre.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 64069d3806ad6dc7187205281ebab1c2ecdca6f4
4
+ data.tar.gz: 07e94403564b0fb3e5429332d05e53f6992d5fcd
5
+ SHA512:
6
+ metadata.gz: ac3ed0bad5ed9ca186636830bd8b28fad5dfc4a7a2ba536c4bba83b0b68ab0ed9af42b761f61b47de67b6a3116be61c0d0b5c6a43ddbea7c86eab42176677852
7
+ data.tar.gz: afd577b26a039a9887de36f5637d0fae561a597caa1d2776bc63c6c14ca2b41eac7d916e630aa41030d82db2ddbd1ad8d417c8896201feee9f9b969abfefd865
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in depend.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Depend
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/depend`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ With Depend, you can handle native dependent more easily for rubygems
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'depend'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install depend
22
+
23
+ ## Usage
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/[my-github-username]/depend/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+
8
+ desc "Run tests"
9
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "depend"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/data/fedora.yml ADDED
@@ -0,0 +1,154 @@
1
+ basic_build_deps:
2
+ - gcc
3
+ - ruby-devel
4
+ - make
5
+ gems:
6
+ atk:
7
+ - atk-devel
8
+ atk-devel:
9
+ - atk-devel
10
+ bigdecimal:
11
+ - db4-devel
12
+ - gdbm-devel
13
+ - libffi-devel
14
+ - libyaml-devel
15
+ - ncurses-devel
16
+ - openssl-devel
17
+ - readline-devel
18
+ - tk-devel
19
+ cairo:
20
+ - cairo-devel
21
+ cairo-devel:
22
+ - cairo-devel
23
+ curb:
24
+ - libcurl-devel
25
+ eventmachine:
26
+ - openssl-devel
27
+ ffi:
28
+ - libffi-devel
29
+ gdk_pixbuf2:
30
+ - gdk-pixbuf2-devel
31
+ - rubygem-cairo-devel
32
+ gdk_pixbuf2-devel:
33
+ - gdk-pixbuf2-devel
34
+ - rubygem-cairo-devel
35
+ glib2:
36
+ - glib2-devel
37
+ glib2-devel:
38
+ - glib2-devel
39
+ gtk2:
40
+ - gtk2-devel
41
+ - rubygem-cairo-devel
42
+ gtk2-devel:
43
+ - gtk2-devel
44
+ - rubygem-cairo-devel
45
+ gtksourceview2:
46
+ - gtksourceview2-devel
47
+ gtksourceview2-devel:
48
+ - gtksourceview2-devel
49
+ idn:
50
+ - libidn-devel
51
+ io-console:
52
+ - db4-devel
53
+ - gdbm-devel
54
+ - libffi-devel
55
+ - libyaml-devel
56
+ - ncurses-devel
57
+ - openssl-devel
58
+ - readline-devel
59
+ - tk-devel
60
+ krb5-auth:
61
+ - krb5-devel
62
+ mkrf:
63
+ - libxml2-devel
64
+ nokogiri:
65
+ - libxml2-devel
66
+ - libxslt-devel
67
+ pango:
68
+ - pango-devel
69
+ - rubygem-cairo-devel
70
+ pango-devel:
71
+ - pango-devel
72
+ - rubygem-cairo-devel
73
+ passenger:
74
+ - httpd-devel
75
+ - libcurl-devel
76
+ - libev-devel
77
+ - zlib-devel
78
+ passenger-devel:
79
+ - httpd-devel
80
+ - libcurl-devel
81
+ - libev-devel
82
+ - zlib-devel
83
+ passenger-native:
84
+ - httpd-devel
85
+ - libcurl-devel
86
+ - libev-devel
87
+ - zlib-devel
88
+ passenger-native-libs:
89
+ - httpd-devel
90
+ - libcurl-devel
91
+ - libev-devel
92
+ - zlib-devel
93
+ pg:
94
+ - postgresql-devel
95
+ pkg-config:
96
+ - cairo-devel
97
+ poppler:
98
+ - poppler-glib-devel
99
+ - rubygem-cairo-devel
100
+ - rubygem-gtk2-devel
101
+ poppler-devel:
102
+ - poppler-glib-devel
103
+ - rubygem-cairo-devel
104
+ - rubygem-gtk2-devel
105
+ qpid:
106
+ - qpid-cpp-client-devel
107
+ rake:
108
+ - db4-devel
109
+ - gdbm-devel
110
+ - libffi-devel
111
+ - libyaml-devel
112
+ - ncurses-devel
113
+ - openssl-devel
114
+ - readline-devel
115
+ - tk-devel
116
+ rdoc:
117
+ - db4-devel
118
+ - gdbm-devel
119
+ - libffi-devel
120
+ - libyaml-devel
121
+ - ncurses-devel
122
+ - openssl-devel
123
+ - readline-devel
124
+ - tk-devel
125
+ rsvg2:
126
+ - librsvg2-devel
127
+ - rubygem-cairo-devel
128
+ rsvg2-devel:
129
+ - librsvg2-devel
130
+ - rubygem-cairo-devel
131
+ ruby-libvirt:
132
+ - libvirt-devel
133
+ ruby-opengl:
134
+ - freeglut-devel
135
+ - libGL-devel
136
+ - libGLU-devel
137
+ sqlite3:
138
+ - sqlite-devel
139
+ thin:
140
+ - libcurl-devel
141
+ typhoeus:
142
+ - libcurl-devel
143
+ vte:
144
+ - vte-devel
145
+ vte-devel:
146
+ - vte-devel
147
+ xmlparser:
148
+ - expat-devel
149
+ zoom:
150
+ - libgcrypt-devel
151
+ - libgpg-error-devel
152
+ - libxslt-devel
153
+ - libyaz-devel
154
+ - tcp_wrappers-devel
data/depend.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'depend/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "depend"
8
+ spec.version = Depend::VERSION
9
+ spec.authors = ["Newell Zhu"]
10
+ spec.email = ["zlx.star@gmail.com"]
11
+ spec.license = 'MIT'
12
+ spec.summary = %q{RubyGems Native Depend Solution.}
13
+ spec.description = %q{RubyGems Native Depend Solution.}
14
+ spec.homepage = "https://github.com/zlx/depend"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "ohai", "~> 6.20.0"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.9"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "minitest", "~> 5.7.0"
26
+ end
data/lib/depend.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "depend/version"
2
+ require "depend/bundler"
3
+
4
+ module Depend
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,9 @@
1
+ Bundler::Source::Path.instance_eval do
2
+ unless instance_methods.include?(:orig_install)
3
+ alias_method :orig_install, :install
4
+ define_method(:install) do |*args|
5
+ Gem.load_plugins
6
+ orig_install(*args)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Depend
2
+ VERSION = "0.0.1-rc1"
3
+ end
@@ -0,0 +1,48 @@
1
+ module Gem
2
+ pre_install do |gem_installer|
3
+ puts "install some gem append depend module"
4
+ unless gem_installer.spec.extensions.empty?
5
+ gem_installer.extend Gem::Installer::Depend
6
+ end
7
+ end
8
+
9
+
10
+ class Installer
11
+ module Depend
12
+ require 'rubygems/user_interaction'
13
+ require 'rubygems/depend/host_detection'
14
+ require 'rubygems/depend/installer'
15
+
16
+ include Gem::UserInteraction
17
+
18
+ def build_extensions
19
+ super
20
+ puts "in build extension"
21
+ rescue ExtensionBuildError => e
22
+ # Install platform dependencies and try the build again.
23
+ if install_platform_dependencies
24
+ super
25
+ else
26
+ raise
27
+ end
28
+ end
29
+
30
+ def install_platform_dependencies
31
+ puts "install dependency for gem"
32
+ platform = Depend::HostDetection.new.platform
33
+ package_provider = Depend::HostDetection.new.package_provider
34
+ if installer = Depend::Installer.installer_for(package_provider)
35
+ missing_deps = Depend::Dependency.dependencies_for(platform, spec.name)
36
+
37
+ unless missing_deps.empty?
38
+ say "Trying to install native dependencies for Gem '#{spec.name}': #{missing_deps.join ' '}"
39
+ unless installer.install(spec.name, missing_deps)
40
+ raise Gem::InstallError, "Failed to install native dependencies for '#{spec.name}'."
41
+ end
42
+ end
43
+ return true
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ module Depend
2
+ class Dependency
3
+ def self.dependencies_for(platform, spec)
4
+ []
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require 'rubygems/depend/host_detection/platform'
2
+ require 'rubygems/depend/host_detection/package_provider'
3
+
4
+ module Depend
5
+ class HostDetection
6
+
7
+ def initialize(opts={})
8
+ @detect_platform = opts.fetch(:detect_platform) { Platform.new }
9
+ @detect_package_provider = opts.fetch(:detect_package_provider) {
10
+ PackageProvider.new(@detect_platform) }
11
+ end
12
+
13
+ def platform
14
+ @detect_platform.name
15
+ end
16
+
17
+ def platform_version
18
+ @detect_platform.version
19
+ end
20
+
21
+ def package_provider
22
+ @detect_package_provider.name
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,83 @@
1
+ module Depend
2
+ class HostDetection
3
+ class PackageProvider
4
+ COMMANDS = {
5
+ 'aix' => 'installp',
6
+ 'yum' => 'yum',
7
+ 'packman' => 'packman',
8
+ 'apt' => 'apt-get',
9
+ 'feebsd' => 'pkg_add',
10
+ 'portage' => 'emerge',
11
+ 'homebrew' => 'brew',
12
+ 'macports' => 'port',
13
+ 'solaris' => 'pkg_add',
14
+ 'ips' => 'pkg',
15
+ 'zypper' => 'zypper',
16
+ 'smartos' => 'pkgin'
17
+ }.freeze
18
+
19
+ PROVIDERS = {
20
+ 'aix' => 'aix',
21
+ 'amazon' => 'yum',
22
+ 'arch' => 'pacman',
23
+ 'centos' => 'yum',
24
+ 'debian' => 'apt',
25
+ 'fedora' => 'yum',
26
+ 'freebsd' => 'freebsd',
27
+ 'gcel' => 'apt',
28
+ 'gentoo' => 'portage',
29
+ 'linaro' => 'apt',
30
+ 'linuxmint' => 'apt',
31
+ 'mac_os_x' => ['homebrew', 'macports'],
32
+ 'mac_os_x_server' => 'macports',
33
+ 'nexentacore' => 'solaris',
34
+ 'omnios' => 'ips',
35
+ 'openindiana' => 'ips',
36
+ 'opensolaris' => 'ips',
37
+ 'opensuse' => 'zypper',
38
+ 'oracle' => 'yum',
39
+ 'raspbian' => 'apt',
40
+ 'redhat' => 'yum',
41
+ 'scientific' => 'yum',
42
+ 'smartos' => 'smartos',
43
+ 'solaris2' => 'ips',
44
+ 'suse' => 'zypper',
45
+ 'ubuntu' => 'apt',
46
+ 'xcp' => 'yum',
47
+ 'xenserver' => 'yum'
48
+ }.freeze
49
+
50
+ def initialize(platform)
51
+ @platform = platform
52
+ end
53
+
54
+ def name
55
+ providers = Array(PROVIDERS[@platform.name])
56
+ return providers.first if providers.count < 2
57
+
58
+ providers.find do |provider|
59
+ which(COMMANDS[provider]) != nil
60
+ end
61
+ end
62
+
63
+ protected
64
+
65
+ # copied from Chef cookbook 'apt'
66
+ # source: apt/libraries/helpers.rb
67
+ def which(cmd)
68
+ paths = (
69
+ ENV['PATH'].split(::File::PATH_SEPARATOR) +
70
+ %w(/bin /usr/bin /sbin /usr/sbin /opt/local/bin)
71
+ )
72
+
73
+ paths.each do |path|
74
+ possible = File.join(path, cmd)
75
+ return possible if File.executable?(possible)
76
+ end
77
+
78
+ nil
79
+ end
80
+
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,34 @@
1
+ require 'ohai'
2
+
3
+ module Depend
4
+ class HostDetection
5
+ class Platform
6
+
7
+ def initialize
8
+ @ohai = build_ohai
9
+ end
10
+
11
+ def name
12
+ ohai_hash[:platform]
13
+ end
14
+
15
+ def version
16
+ ohai_hash[:platform_version]
17
+ end
18
+
19
+ def ohai_hash
20
+ @ohai
21
+ end
22
+
23
+ protected
24
+
25
+ def build_ohai
26
+ ohai = Ohai::System.new
27
+ ohai.require_plugin 'os'
28
+ ohai.require_plugin 'platform'
29
+ ohai
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ require 'rubygems/depend/installer/base_installer'
2
+ require 'rubygems/depend/installer/yum_installer'
3
+ require 'rubygems/depend/installer/homebrew_installer'
4
+ require 'rubygems/depend/installer/apt_installer'
5
+
6
+ module Depend
7
+ class Installer
8
+
9
+ package_installers = {
10
+ 'yum' => YumInstaller,
11
+ 'homebrew' => HomebrewInstaller,
12
+ 'apt' => AptInstaller
13
+ }.freeze
14
+
15
+ def self.installer(package_provider)
16
+ package_installers[package_provider]
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,8 @@
1
+ module Depend
2
+ class AptInstaller < BaseInstaller
3
+
4
+ def self.install(names)
5
+ system "su -c 'apt-get install #{names.join(' ')}'"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Depend
2
+ class BaseInstaller
3
+
4
+ def self.install(names)
5
+ fail NotImplementedError
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Depend
2
+ class HomebrewInstaller < BaseInstaller
3
+
4
+ def self.install(names)
5
+ system "su -c 'brew install #{names.join(' ')}'"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Depend
2
+ class YumInstaller < BaseInstaller
3
+
4
+ def self.install(names)
5
+ system "su -c 'yum install #{names.join(' ')}'"
6
+ end
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ require 'rubygems/depend'
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: depend
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Newell Zhu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ohai
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.20.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.20.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 5.7.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 5.7.0
69
+ description: RubyGems Native Depend Solution.
70
+ email:
71
+ - zlx.star@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - data/fedora.yml
84
+ - depend.gemspec
85
+ - lib/depend.rb
86
+ - lib/depend/bundler.rb
87
+ - lib/depend/version.rb
88
+ - lib/rubygems/depend.rb
89
+ - lib/rubygems/depend/dependency.rb
90
+ - lib/rubygems/depend/host_detection.rb
91
+ - lib/rubygems/depend/host_detection/package_provider.rb
92
+ - lib/rubygems/depend/host_detection/platform.rb
93
+ - lib/rubygems/depend/installer.rb
94
+ - lib/rubygems/depend/installer/apt_installer.rb
95
+ - lib/rubygems/depend/installer/base_installer.rb
96
+ - lib/rubygems/depend/installer/homebrew_installer.rb
97
+ - lib/rubygems/depend/installer/yum_installer.rb
98
+ - lib/rubygems_plugin.rb
99
+ homepage: https://github.com/zlx/depend
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">"
115
+ - !ruby/object:Gem::Version
116
+ version: 1.3.1
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.2.0
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: RubyGems Native Depend Solution.
123
+ test_files: []