bits-installer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/bits.rb CHANGED
@@ -9,6 +9,7 @@ require 'bits/commands/install'
9
9
  require 'bits/commands/remove'
10
10
  require 'bits/commands/show'
11
11
  require 'bits/commands/sync'
12
+ require 'bits/commands/setup'
12
13
 
13
14
  require 'bits/provider/python'
14
15
  require 'bits/provider/apt'
@@ -9,7 +9,7 @@ module Bits
9
9
  end
10
10
 
11
11
  def to_s
12
- "<BitReference #{@atom}>"
12
+ "<BitReference '#{@atom}'>"
13
13
  end
14
14
  end
15
15
 
@@ -25,6 +25,19 @@ module Bits
25
25
  end
26
26
  end
27
27
 
28
+ class BitDependency
29
+ attr_reader :atom, :parameters
30
+
31
+ def initialize(atom, parameters)
32
+ @atom = atom
33
+ @parameters = parameters
34
+ end
35
+
36
+ def to_s
37
+ "<BitDependency '#{@atom}' parameters=#{@parameters}>"
38
+ end
39
+ end
40
+
28
41
  # Class used to manage state of a bit declaration file.
29
42
  class BitDeclaration
30
43
  attr_accessor :provider_data, :dependencies
@@ -108,7 +121,11 @@ module Bits
108
121
  raise "Expected :atom to be not null in dependency"
109
122
  end
110
123
 
111
- h[atom] = BitParameters.new item
124
+ unless h[atom].nil?
125
+ raise "Dependency already specified: #{atom}"
126
+ end
127
+
128
+ h[atom] = BitDependency.new atom, item
112
129
  end
113
130
  end
114
131
 
@@ -31,10 +31,11 @@ module Bits
31
31
 
32
32
  repository = ns[:repository]
33
33
 
34
- parameters = {}
35
- parameters[:compiled] = ns[:compiled] if ns.has_key? :compiled
34
+ criteria = {
35
+ :compiled => ns[:compiled]
36
+ }
36
37
 
37
- p = repository.find_package atom, parameters
38
+ p = repository.find_package atom, criteria
38
39
 
39
40
  if p.installed? and not ns[:force]
40
41
  log.info "Already installed '#{atom}' using provider(s): #{p.providers_s}"
@@ -0,0 +1,62 @@
1
+ require 'bits/command'
2
+ require 'bits/logging'
3
+ require 'bits/exceptions'
4
+
5
+ require 'bits/bit_reader/local'
6
+ require 'bits/bit'
7
+
8
+ module Bits
9
+ define_command :setup, :desc => "Setup a local Bits declaration" do
10
+ include Bits::Logging
11
+
12
+ def setup(opts)
13
+ ns[:compiled] = nil
14
+
15
+ opts.banner = "Usage: bits setup"
16
+ opts.separator ""
17
+ opts.separator "Setup a local Bits declaration"
18
+
19
+ opts.on('--[no-]compiled', "Insist on installing an already compiled variant or not") do |v|
20
+ ns[:compiled] = v
21
+ end
22
+ end
23
+
24
+ def entry(args)
25
+ repository = ns[:repository]
26
+
27
+ criteria = {
28
+ :compiled => ns[:compiled]
29
+ }
30
+
31
+ path = File.join Dir.pwd, 'Bits'
32
+
33
+ raise "No such file: #{path}" unless File.file? path
34
+
35
+ reader = BitReaderLocal.new path
36
+
37
+ bit = Bit.eval reader, nil
38
+
39
+ bit.dependencies.each do |atom, dependency|
40
+ package = repository.find_package dependency.atom, criteria
41
+
42
+ if package.installed?
43
+ log.info "Dependency already installed '#{atom}'"
44
+ next
45
+ end
46
+
47
+ log.info "Installing dependency '#{atom}'"
48
+
49
+ matching = package.matching_ppps
50
+
51
+ raise "No matching PPP could be found" if matching.empty?
52
+
53
+ ppp = matching[0]
54
+
55
+ provider = ppp.provider
56
+ package = ppp.package
57
+
58
+ provider.install package
59
+ end
60
+ end
61
+ end
62
+ end
data/lib/bits/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bits
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bits-installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -108,6 +108,7 @@ files:
108
108
  - lib/bits/commands/sync.rb
109
109
  - lib/bits/commands/install.rb
110
110
  - lib/bits/commands/show.rb
111
+ - lib/bits/commands/setup.rb
111
112
  - lib/bits/package.rb
112
113
  - lib/bits/user.rb
113
114
  - lib/bits/bit_reader/local.rb