librarian 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,16 @@
1
+ # Change Log
2
+
3
+ ## 0.0.16
4
+
5
+ * Recache site-sourced dependency metadata per each run.
6
+
7
+ * \#46. Always install.
8
+
9
+ * \#53. Abstract versions & requirements from rubygems.
10
+
11
+ * Own the install path. Recreate it on each install.
12
+ WARNING: If you have your own content in the install path, it will be deleted without mercy.
13
+
1
14
  ## 0.0.15
2
15
 
3
16
  * Rewrite the README.
@@ -47,7 +47,8 @@ module Librarian
47
47
  end
48
48
 
49
49
  def create_install_path
50
- install_path.mkpath unless install_path.exist?
50
+ install_path.rmtree if install_path.exist?
51
+ install_path.mkpath
51
52
  end
52
53
 
53
54
  def install_manifests(manifests)
@@ -6,8 +6,8 @@ module Librarian
6
6
  module Chef
7
7
  class Environment < Environment
8
8
 
9
- def specfile_name
10
- "Cheffile"
9
+ def adapter_name
10
+ "chef"
11
11
  end
12
12
 
13
13
  def install_path
@@ -144,7 +144,8 @@ module Librarian
144
144
  dependency_cache_path = cache_path.join(dependency.name)
145
145
  dependency_cache_path.mkpath
146
146
  metadata_cache_path = metadata_cache_path(dependency)
147
- unless metadata_cache_path.exist?
147
+
148
+ caching_metadata do
148
149
  dep_uri = URI.parse(dependency_uri(dependency))
149
150
  debug { "Caching #{dep_uri}" }
150
151
  http = Net::HTTP.new(dep_uri.host, dep_uri.port)
@@ -161,6 +162,13 @@ module Librarian
161
162
  end
162
163
  end
163
164
 
165
+ def caching_metadata
166
+ return if @_metadata_cached
167
+ result = yield
168
+ @_metadata_cached = true
169
+ result
170
+ end
171
+
164
172
  def cache_version_metadata!(dependency, version_uri)
165
173
  version_cache_path = version_cache_path(dependency, version_uri)
166
174
  unless version_cache_path.exist?
@@ -57,7 +57,7 @@ module Librarian
57
57
  clean!
58
58
  end
59
59
 
60
- desc "install", "Installs all of the dependencies you specify."
60
+ desc "install", "Resolves and installs all of the dependencies you specify."
61
61
  method_option "verbose"
62
62
  method_option "line-numbers"
63
63
  method_option "clean"
@@ -68,17 +68,7 @@ module Librarian
68
68
  install!
69
69
  end
70
70
 
71
- desc "resolve", "Resolves the dependencies you specify."
72
- method_option "verbose"
73
- method_option "line-numbers"
74
- method_option "clean"
75
- def resolve
76
- ensure!
77
- clean! if options["clean"]
78
- resolve!
79
- end
80
-
81
- desc "update", "Updates the dependencies you specify."
71
+ desc "update", "Updates and installs the dependencies you specify."
82
72
  method_option "verbose"
83
73
  method_option "line-numbers"
84
74
  def update(*names)
@@ -88,6 +78,7 @@ module Librarian
88
78
  else
89
79
  update!(:names => names)
90
80
  end
81
+ install!
91
82
  end
92
83
 
93
84
  desc "init", "Initializes the current directory."
@@ -5,7 +5,39 @@ require 'librarian/helpers/debug'
5
5
  module Librarian
6
6
  class Dependency
7
7
 
8
- class Requirement < Gem::Requirement
8
+ class Requirement
9
+ def initialize(*args)
10
+ args = initialize_normalize_args(args)
11
+
12
+ self.backing = Gem::Requirement.create(*args)
13
+ end
14
+
15
+ def to_gem_requirement
16
+ backing
17
+ end
18
+
19
+ def satisfied_by?(version)
20
+ to_gem_requirement.satisfied_by?(version.to_gem_version)
21
+ end
22
+
23
+ def ==(other)
24
+ to_gem_requirement == other.to_gem_requirement
25
+ end
26
+
27
+ def to_s
28
+ to_gem_requirement.to_s
29
+ end
30
+
31
+ private
32
+
33
+ def initialize_normalize_args(args)
34
+ args.map do |arg|
35
+ arg = [arg] if self.class === arg
36
+ arg
37
+ end
38
+ end
39
+
40
+ attr_accessor :backing
9
41
  end
10
42
 
11
43
  include Helpers::Debug
@@ -17,7 +49,7 @@ module Librarian
17
49
  assert_name_valid! name
18
50
 
19
51
  self.name = name
20
- self.requirement = Requirement.create(requirement)
52
+ self.requirement = Requirement.new(requirement)
21
53
  self.source = source
22
54
 
23
55
  @manifests = nil
@@ -21,17 +21,35 @@ module Librarian
21
21
 
22
22
  def initialize(options = { })
23
23
  @project_path = options[:project_path]
24
+ @specfile_name = options[:specfile_name]
24
25
  end
25
26
 
26
27
  def project_path
27
28
  @project_path ||= begin
28
29
  root = Pathname.new(Dir.pwd)
29
- root = root.dirname until root.join(specfile_name).exist? || root.dirname == root
30
+ root = root.dirname until project_path?(root)
30
31
  path = root.join(specfile_name)
31
- path.exist? ? root : nil
32
+ path.file? ? root : nil
32
33
  end
33
34
  end
34
35
 
36
+ def project_path?(path)
37
+ path.join(config_name).directory? ||
38
+ path.join(specfile_name).file? ||
39
+ path.dirname == path
40
+ end
41
+
42
+ def default_specfile_name
43
+ @default_specfile_name ||= begin
44
+ capped = adapter_name.capitalize
45
+ "#{capped}file"
46
+ end
47
+ end
48
+
49
+ def specfile_name
50
+ @specfile_name ||= default_specfile_name
51
+ end
52
+
35
53
  def specfile_path
36
54
  project_path.join(specfile_name)
37
55
  end
@@ -40,6 +58,18 @@ module Librarian
40
58
  Specfile.new(self, specfile_path)
41
59
  end
42
60
 
61
+ def adapter_name
62
+ nil
63
+ end
64
+
65
+ def config_name
66
+ File.join(*[config_prefix, adapter_name].compact)
67
+ end
68
+
69
+ def config_prefix
70
+ ".librarian"
71
+ end
72
+
43
73
  def lockfile_name
44
74
  "#{specfile_name}.lock"
45
75
  end
@@ -6,7 +6,37 @@ require 'librarian/support/abstract_method'
6
6
  module Librarian
7
7
  class Manifest
8
8
 
9
- class Version < Gem::Version
9
+ class Version
10
+ include Comparable
11
+
12
+ def initialize(*args)
13
+ args = initialize_normalize_args(args)
14
+
15
+ self.backing = Gem::Version.new(*args)
16
+ end
17
+
18
+ def to_gem_version
19
+ backing
20
+ end
21
+
22
+ def <=>(other)
23
+ to_gem_version <=> other.to_gem_version
24
+ end
25
+
26
+ def to_s
27
+ to_gem_version.to_s
28
+ end
29
+
30
+ private
31
+
32
+ def initialize_normalize_args(args)
33
+ args.map do |arg|
34
+ arg = [arg] if self.class === arg
35
+ arg
36
+ end
37
+ end
38
+
39
+ attr_accessor :backing
10
40
  end
11
41
 
12
42
  include Support::AbstractMethod
@@ -5,8 +5,8 @@ module Librarian
5
5
  module Mock
6
6
  class Environment < Environment
7
7
 
8
- def specfile_name
9
- "Mockfile"
8
+ def adapter_name
9
+ "mock"
10
10
  end
11
11
 
12
12
  def install_path
@@ -1,3 +1,3 @@
1
1
  module Librarian
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
@@ -94,13 +94,14 @@ module Librarian
94
94
  end
95
95
  end
96
96
 
97
- it "should not try to create the install path if it already exists" do
97
+ it "should recreate the install path if it already exists" do
98
98
  action.stub(:sorted_manifests) { sorted_manifests }
99
99
  action.stub(:cache_manifests)
100
100
  action.stub(:install_manifests)
101
101
 
102
102
  install_path.stub(:exist?) { true }
103
- install_path.should_not_receive(:mkpath)
103
+ install_path.should_receive(:rmtree)
104
+ install_path.should_receive(:mkpath)
104
105
  end
105
106
 
106
107
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librarian
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-12 00:00:00.000000000 Z
12
+ date: 2012-04-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &12899900 !ruby/object:Gem::Requirement
16
+ requirement: &13668800 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12899900
24
+ version_requirements: *13668800
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &12899480 !ruby/object:Gem::Requirement
27
+ requirement: &13668380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *12899480
35
+ version_requirements: *13668380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &12899060 !ruby/object:Gem::Requirement
38
+ requirement: &13667960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *12899060
46
+ version_requirements: *13667960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cucumber
49
- requirement: &12898640 !ruby/object:Gem::Requirement
49
+ requirement: &13667540 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *12898640
57
+ version_requirements: *13667540
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: aruba
60
- requirement: &12898220 !ruby/object:Gem::Requirement
60
+ requirement: &13667120 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *12898220
68
+ version_requirements: *13667120
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &12897800 !ruby/object:Gem::Requirement
71
+ requirement: &13666700 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *12897800
79
+ version_requirements: *13666700
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: chef
82
- requirement: &12897300 !ruby/object:Gem::Requirement
82
+ requirement: &13666200 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0.10'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *12897300
90
+ version_requirements: *13666200
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: highline
93
- requirement: &12896880 !ruby/object:Gem::Requirement
93
+ requirement: &13665780 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :runtime
100
100
  prerelease: false
101
- version_requirements: *12896880
101
+ version_requirements: *13665780
102
102
  description: Librarian
103
103
  email:
104
104
  - y_feldblum@yahoo.com