librarian 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,53 @@
1
+ ## 0.0.8
2
+
3
+ * A `version` task.
4
+
5
+ * A change log.
6
+
7
+ * \#10 Fixes the problem with bouncing the lockfile when updating, when using a git source with the default ref.
8
+
9
+ ## 0.0.7
10
+
11
+ * \#8 Add highline temporarily as a runtime dependency of `librarian` (@fnichol).
12
+ When the project is split into `librarian` and `librarian-chef`, the `chef` runtime dependency will
13
+ be moved to `librarian-chef`. If the project is further split into a knife plugin, the dependency
14
+ will be moved there.
15
+
16
+ ## 0.0.6
17
+
18
+ * \#7 Show a better error message when a cookbook is missing the required metadata file.
19
+
20
+ * Miscellaneous bugfixes.
21
+
22
+ ## 0.0.5
23
+
24
+ * \#4 An `init` task for `librarian-chef`.
25
+ This task creates a nearly-blank `Cheffile` with just the default Opscode Community Site source.
26
+
27
+ * Automatically create the `cookbooks` directory, if it's missing, when running the `install` task.
28
+
29
+ * \#3 Add `chef` temporarily as a runtime dependency of `librarian` (@fnichol).
30
+ When the project is split into `librarian` and `librarian-chef`, the `chef` runtime dependency will
31
+ be moved to `librarian-chef`.
32
+
33
+ ## 0.0.4
34
+
35
+ * A simple knife integration.
36
+ This integration allows you to specify a `librarian-chef`-managed tempdir as a `cookbook_path`.
37
+ This is useful to force knife only to upload the exact cookbooks that `librarian-chef` knows
38
+ about, rather than whatever happens to be found in the `cookbooks` directory.
39
+
40
+ ## 0.0.3
41
+
42
+ * Miscellaneous bugfixes.
43
+
44
+ ## 0.0.2
45
+
46
+ * An optional `:path` attribute for `:git` sources.
47
+ This allows you to specify exactly where within a git repository a given cookbook is to be found.
48
+
49
+ * A full example of a Cheffile and its usage in the readme.
50
+
51
+ ## 0.0.1
52
+
53
+ * Initial release.
data/lib/librarian.rb CHANGED
@@ -76,6 +76,10 @@ module Librarian
76
76
  SpecChangeSet.new(self, spec, lock)
77
77
  end
78
78
 
79
+ def version
80
+ VERSION
81
+ end
82
+
79
83
  def ensure!
80
84
  unless project_path
81
85
  raise Error, "Cannot find #{specfile_name}!"
@@ -117,10 +121,6 @@ module Librarian
117
121
  end
118
122
  previous_resolution = lockfile.load(lockfile_path.read)
119
123
  partial_manifests = ManifestSet.deep_strip(previous_resolution.manifests, dependency_names)
120
- debug { "Precaching Sources:" }
121
- previous_resolution.sources.each do |source|
122
- debug { " #{source}" }
123
- end
124
124
  spec = specfile.read(previous_resolution.sources)
125
125
  spec_changes = spec_change_set(spec, previous_resolution)
126
126
  raise Error, "Cannot update when the specfile has been changed." unless spec_changes.same?
@@ -146,10 +146,6 @@ module Librarian
146
146
  manifests = []
147
147
  else
148
148
  lock = lockfile.read
149
- debug { "Precaching Sources:" }
150
- lock.sources.each do |source|
151
- debug { " #{source}" }
152
- end
153
149
  spec = specfile.read(lock.sources)
154
150
  changes = spec_change_set(spec, lock)
155
151
  if changes.same?
@@ -1,9 +1,13 @@
1
1
  require 'librarian/dsl'
2
+ require 'librarian/chef/particularity'
2
3
  require 'librarian/chef/source'
3
4
 
4
5
  module Librarian
5
6
  module Chef
6
7
  class Dsl < Librarian::Dsl
8
+
9
+ include Particularity
10
+
7
11
  dependency :cookbook
8
12
 
9
13
  source :site => Source::Site
data/lib/librarian/cli.rb CHANGED
@@ -32,6 +32,11 @@ module Librarian
32
32
  root_module.ui.debug_line_numbers! if options["verbose"] && options["line-numbers"]
33
33
  end
34
34
 
35
+ desc "version", "Displays the version."
36
+ def version
37
+ say "librarian-#{root_module.version}"
38
+ end
39
+
35
40
  desc "clean", "Cleans out the cache and install paths."
36
41
  method_option "verbose"
37
42
  method_option "line-numbers"
data/lib/librarian/dsl.rb CHANGED
@@ -1,10 +1,15 @@
1
1
  require 'librarian/dependency'
2
2
  require 'librarian/dsl/receiver'
3
3
  require 'librarian/dsl/target'
4
+ require 'librarian/helpers/debug'
5
+ require 'librarian/particularity'
4
6
 
5
7
  module Librarian
6
8
  class Dsl
7
9
 
10
+ include Particularity
11
+ include Helpers::Debug
12
+
8
13
  class Error < Exception
9
14
  end
10
15
 
@@ -63,14 +68,28 @@ module Librarian
63
68
  def run(specfile = nil, sources = [])
64
69
  Target.new(self).tap do |target|
65
70
  target.precache_sources(sources)
71
+ debug_named_source_cache("Pre-Cached Sources", target)
72
+
66
73
  receiver = Receiver.new(target)
67
74
  if block_given?
68
75
  receiver.run(&Proc.new)
69
76
  else
70
77
  receiver.run(specfile)
71
78
  end
79
+
80
+ debug_named_source_cache("Post-Cached Sources", target)
72
81
  end.to_spec
73
82
  end
74
83
 
84
+ def debug_named_source_cache(name, target)
85
+ source_cache = target.source_cache
86
+ debug { "#{name}:" }
87
+ source_cache.each do |key, value|
88
+ type = key[0]
89
+ attributes = key[1...key.size]
90
+ debug { " #{key.inspect}" }
91
+ end
92
+ end
93
+
75
94
  end
76
95
  end
@@ -1,9 +1,13 @@
1
1
  require 'librarian/dsl'
2
+ require 'librarian/mock/particularity'
2
3
  require 'librarian/mock/source'
3
4
 
4
5
  module Librarian
5
6
  module Mock
6
7
  class Dsl < Librarian::Dsl
8
+
9
+ include Particularity
10
+
7
11
  dependency :dep
8
12
 
9
13
  source :src => Source::Mock
@@ -1,7 +1,9 @@
1
1
  module Librarian
2
- module Particularity
3
- def root_module
4
- Mock
2
+ module Mock
3
+ module Particularity
4
+ def root_module
5
+ Mock
6
+ end
5
7
  end
6
8
  end
7
9
  end
@@ -52,7 +52,8 @@ module Librarian
52
52
  end
53
53
 
54
54
  def to_spec_args
55
- options = {:ref => ref}
55
+ options = {}
56
+ options.merge!(:ref => ref) if ref != DEFAULTS[:ref]
56
57
  options.merge!(:path => path) if path
57
58
  [uri, options]
58
59
  end
@@ -1,3 +1,3 @@
1
1
  module Librarian
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
@@ -14,6 +14,8 @@ module Librarian
14
14
  project_path = project_path.dirname until project_path.join("Rakefile").exist?
15
15
  tmp_path = project_path.join("tmp/spec/chef/git-source")
16
16
 
17
+ cookbooks_path = tmp_path.join('cookbooks')
18
+
17
19
  context "a single dependency with a git source" do
18
20
 
19
21
  sample_path = tmp_path.join('sample')
@@ -21,6 +23,16 @@ module Librarian
21
23
  version '0.6.5'
22
24
  METADATA
23
25
 
26
+ first_sample_path = cookbooks_path.join('first-sample')
27
+ first_sample_metadata = Helpers.strip_heredoc(<<-METADATA)
28
+ version '3.2.1'
29
+ METADATA
30
+
31
+ second_sample_path = cookbooks_path.join('second-sample')
32
+ second_sample_metadata = Helpers.strip_heredoc(<<-METADATA)
33
+ version '4.3.2'
34
+ METADATA
35
+
24
36
  before :all do
25
37
  sample_path.rmtree if sample_path.exist?
26
38
  sample_path.mkpath
@@ -30,6 +42,18 @@ module Librarian
30
42
  `git add metadata.rb`
31
43
  `git commit -m "Initial commit."`
32
44
  end
45
+
46
+ cookbooks_path.rmtree if cookbooks_path.exist?
47
+ cookbooks_path.mkpath
48
+ first_sample_path.mkpath
49
+ first_sample_path.join('metadata.rb').open('wb') { |f| f.write(first_sample_metadata) }
50
+ second_sample_path.mkpath
51
+ second_sample_path.join('metadata.rb').open('wb') { |f| f.write(second_sample_metadata) }
52
+ Dir.chdir(cookbooks_path) do
53
+ `git init`
54
+ `git add .`
55
+ `git commit -m "Initial commit."`
56
+ end
33
57
  end
34
58
 
35
59
  it "should resolve" do
@@ -86,6 +110,30 @@ module Librarian
86
110
  repo_path.join('cookbooks/sample/metadata.rb').should be_exist
87
111
  end
88
112
 
113
+ it "should resolve, change, and resolve" do
114
+ repo_path = tmp_path.join('repo/resolve-update')
115
+ repo_path.rmtree if repo_path.exist?
116
+ repo_path.mkpath
117
+ repo_path.join('cookbooks').mkpath
118
+ cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
119
+ git #{cookbooks_path.to_s.inspect}
120
+ cookbook "first-sample"
121
+ CHEFFILE
122
+ repo_path.join('Cheffile').open('wb') { |f| f.write(cheffile) }
123
+ Chef.stub!(:project_path) { repo_path }
124
+ Chef.resolve!
125
+ repo_path.join('Cheffile.lock').should exist
126
+
127
+ cheffile = Helpers.strip_heredoc(<<-CHEFFILE)
128
+ git #{cookbooks_path.to_s.inspect}
129
+ cookbook "first-sample"
130
+ cookbook "second-sample"
131
+ CHEFFILE
132
+ repo_path.join('Cheffile').open('wb') { |f| f.write(cheffile) }
133
+ Chef.stub!(:project_path) { repo_path }
134
+ Chef.resolve!
135
+ end
136
+
89
137
  end
90
138
 
91
139
  context "with a path" do
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.7
4
+ version: 0.0.8
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: 2011-09-18 00:00:00.000000000Z
12
+ date: 2011-10-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
16
- requirement: &19020680 !ruby/object:Gem::Requirement
16
+ requirement: &34375080 !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: *19020680
24
+ version_requirements: *34375080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &19020240 !ruby/object:Gem::Requirement
27
+ requirement: &34374660 !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: *19020240
35
+ version_requirements: *34374660
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: cucumber
38
- requirement: &19019780 !ruby/object:Gem::Requirement
38
+ requirement: &34374240 !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: *19019780
46
+ version_requirements: *34374240
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: aruba
49
- requirement: &19019300 !ruby/object:Gem::Requirement
49
+ requirement: &34373820 !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: *19019300
57
+ version_requirements: *34373820
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: webmock
60
- requirement: &18979780 !ruby/object:Gem::Requirement
60
+ requirement: &34373400 !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: *18979780
68
+ version_requirements: *34373400
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: chef
71
- requirement: &18979280 !ruby/object:Gem::Requirement
71
+ requirement: &34372900 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0.10'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *18979280
79
+ version_requirements: *34372900
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: highline
82
- requirement: &18978860 !ruby/object:Gem::Requirement
82
+ requirement: &34372480 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *18978860
90
+ version_requirements: *34372480
91
91
  description: Librarian
92
92
  email:
93
93
  - y_feldblum@yahoo.com
@@ -99,6 +99,7 @@ extra_rdoc_files: []
99
99
  files:
100
100
  - .gitignore
101
101
  - .rspec
102
+ - CHANGELOG.md
102
103
  - Gemfile
103
104
  - MIT-LICENSE
104
105
  - README.md
@@ -185,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
186
  version: '0'
186
187
  requirements: []
187
188
  rubyforge_project: librarian
188
- rubygems_version: 1.8.5
189
+ rubygems_version: 1.8.10
189
190
  signing_key:
190
191
  specification_version: 3
191
192
  summary: Librarian