depend 0.0.1.pre.rc2 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d369724bdd4e5ea3265934ee5f331f5700f9c3b
4
- data.tar.gz: a9938335cf39d63612e20e4d36cd19c1dac4382a
3
+ metadata.gz: cd730b57a1948b0210772ec767027abf067394d1
4
+ data.tar.gz: 0d8fb7412056aa7b4f86e7b153f62f694713902c
5
5
  SHA512:
6
- metadata.gz: 3251fc990c16bd0e639ab417c26d221c12e21240cc3809b6c218529d6a5cf0cc42bfafb6858e3b2d19489022c369c9b196254cacb1901fd586c080742374ee3f
7
- data.tar.gz: 78646ddec97d5aa9273296227dcd6f1806e7b2040f00d8b5ce201003def95ecefbd934ef855655be1b662b94e83482353b48b9b5a35faaeffb66c9cab3604a92
6
+ metadata.gz: 31a3058204a9fac8c08a05c799049c852c2d0627a1f63511119564c52b5f5ef32dae925c946e32bba2a1dec4178d4794ed589382deffcfa4f35e456269d1a6bd
7
+ data.tar.gz: 9b6e2f83093d9eb2b10bb73d4e8afd126d4a2a23f61bc034c4357a78794e8be85a18f554abc91c61fcfad9d6e16d67caa29891606936226122241d149fdf804c
data/depend.gemspec CHANGED
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.9"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "minitest", "~> 5.7.0"
26
+ spec.add_development_dependency "mocha", "~> 1.1.0"
26
27
  end
data/lib/depend.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "depend/version"
2
2
 
3
3
  module Depend
4
- autoload :Registerable, "depend/registerable"
4
+ autoload :Register, "depend/register"
5
5
  autoload :Dependent, "depend/dependent"
6
6
  autoload :Configuration, "depend/configuration"
7
7
 
@@ -28,22 +28,20 @@ module Depend
28
28
  yield(configuration)
29
29
  end
30
30
 
31
+ def self.register
32
+ @register_instance ||= Register.init_with_default_register
33
+ end
34
+
31
35
  class Base
32
- extend Registerable
33
36
  extend Dependent
34
37
 
35
- self.register PackageProvider::Apt, 'Ubuntu'
36
- self.register PackageProvider::Homebrew, 'MacOS'
37
-
38
- OPERATION_SYSTEMS = %w{ Ubuntu MacOS }.freeze
39
-
40
38
  def initialize(platform, platform_version = nil)
41
39
  @platform = platform
42
40
  @platform_version = platform_version
43
41
  end
44
42
 
45
43
  def package_providers
46
- self.class.package_providers_for(@platform, @platform_version)
44
+ Depend.register.package_providers_for(@platform, @platform_version)
47
45
  end
48
46
 
49
47
  def dependencies_for(package_provider)
@@ -1,13 +1,15 @@
1
1
  require 'os_platform'
2
2
 
3
3
  module Depend
4
+ class InstallError < ::Gem::InstallError; end
5
+
4
6
  class Installer
5
7
 
6
- def self.install
7
- install_platform_dependencies
8
+ def self.install(spec)
9
+ install_platform_dependencies(spec)
8
10
  end
9
11
 
10
- def self.install_platform_dependencies
12
+ def self.install_platform_dependencies(spec)
11
13
  puts "install dependency for gem"
12
14
  os_platform = OSPlatform.local
13
15
  depend_instance = Depend::Base.new(os_platform.platform, os_platform.platform_version)
@@ -20,7 +22,7 @@ module Depend
20
22
  puts "Trying to install native dependencies for Gem '#{spec.name}': #{deps.join ' '}"
21
23
  deps.each do |dep|
22
24
  unless package_provider.install(spec.name, dep)
23
- raise Gem::InstallError, "Failed to install native dependencies for '#{spec.name}'."
25
+ fail Depend::InstallError, "Failed to install native dependencies for '#{spec.name}'."
24
26
  end
25
27
  end
26
28
  end
@@ -17,6 +17,7 @@ module Depend
17
17
  # command: command for package_provider
18
18
  # dep: library need installed
19
19
  def exec_install(dep)
20
+ puts "Run: #{command} install #{dep}"
20
21
  `#{command} install #{dep}`
21
22
  end
22
23
 
@@ -8,6 +8,7 @@ module Depend
8
8
  end
9
9
 
10
10
  def installed?(dep)
11
+ puts "Run: #{command} info #{dep}"
11
12
  !!system("#{command} info #{dep}")
12
13
  end
13
14
  end
@@ -1,14 +1,29 @@
1
1
  module Depend
2
2
  class PlatformNotSupportedError < StandardError; end
3
3
 
4
- module Registerable
5
- OPERATION_SYSTEMS = %w{ Ubuntu MacOS }.freeze
6
- attr_accessor :platforms
4
+ class Register
5
+
6
+ OPERATION_SYSTEMS = %w{ Ubuntu mac_os_x }.freeze
7
+ attr_reader :platforms
8
+
9
+ def self.init_with_default_register
10
+ instance = self.new
11
+ instance.register PackageProvider::Apt, 'Ubuntu'
12
+ instance.register PackageProvider::Homebrew, 'mac_os_x'
13
+ instance
14
+ end
7
15
 
8
16
  def acceptable_operations_systems
9
17
  OPERATION_SYSTEMS
10
18
  end
11
19
 
20
+ def package_providers_for(platform, platform_version)
21
+ puts @platforms
22
+ return [] if @platforms.nil? || @platforms.empty?
23
+ _platform = @platforms[platform] || []
24
+ _platform.select{|plat| version_include?(plat.shift, platform_version)}.map(&:last)
25
+ end
26
+
12
27
  def register(package_provider, platform, platform_version = nil)
13
28
  puts "in register"
14
29
  fail PlatformNotSupportedError unless platform_accepted?(platform)
@@ -20,12 +35,6 @@ module Depend
20
35
  end
21
36
  end
22
37
 
23
- def package_providers_for(platform, platform_version)
24
- return [] if @platforms.nil? || @platforms.empty?
25
- _platform = @platforms[platform]
26
- _platform.select{|plat| version_include?(plat.shift, platform_version)}.map(&:last)
27
- end
28
-
29
38
  private
30
39
 
31
40
  def version_include?(version_string, platform_version)
@@ -41,7 +50,8 @@ module Depend
41
50
  end
42
51
 
43
52
  def platform_accepted?(platform)
44
- OPERATION_SYSTEMS.map(&:downcase).include?(platform.downcase)
53
+ acceptable_operations_systems.map(&:downcase).include?(platform.downcase)
45
54
  end
55
+
46
56
  end
47
57
  end
@@ -1,3 +1,3 @@
1
1
  module Depend
2
- VERSION = "0.0.1-rc2"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,6 +1,7 @@
1
+ require 'depend'
1
2
  require 'depend/installer'
2
3
 
3
4
  Gem.pre_install do |gem_installer|
4
5
  puts "inside gem pre install"
5
- Depend::Installer.install
6
+ Depend::Installer.install(gem_installer.spec)
6
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: depend
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.rc2
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Newell Zhu
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 5.7.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.1.0
69
83
  description: RubyGems Native Depend Solution.
70
84
  email:
71
85
  - zlx.star@gmail.com
@@ -88,7 +102,7 @@ files:
88
102
  - lib/depend/package_provider/apt.rb
89
103
  - lib/depend/package_provider/common.rb
90
104
  - lib/depend/package_provider/homebrew.rb
91
- - lib/depend/registerable.rb
105
+ - lib/depend/register.rb
92
106
  - lib/depend/version.rb
93
107
  - lib/rubygems_plugin.rb
94
108
  homepage: https://github.com/zlx/depend
@@ -106,9 +120,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
120
  version: '0'
107
121
  required_rubygems_version: !ruby/object:Gem::Requirement
108
122
  requirements:
109
- - - ">"
123
+ - - ">="
110
124
  - !ruby/object:Gem::Version
111
- version: 1.3.1
125
+ version: '0'
112
126
  requirements: []
113
127
  rubyforge_project:
114
128
  rubygems_version: 2.2.0