librarian 0.1.0.beta.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.1.0
4
+
5
+ * Extract the chef adapter to its own gem.
6
+
3
7
  ## 0.0.26
4
8
 
5
9
  * \#112. Prevent the git source being confused in certain cases by colorized
@@ -68,21 +68,15 @@ module Librarian
68
68
  end
69
69
 
70
70
  def run(specfile = nil, sources = [])
71
+ specfile, sources = nil, specfile if specfile.kind_of?(Array) && sources.empty?
72
+
71
73
  Target.new(self).tap do |target|
72
74
  target.precache_sources(sources)
73
75
  debug_named_source_cache("Pre-Cached Sources", target)
74
76
 
77
+ specfile ||= Proc.new if block_given?
75
78
  receiver = Receiver.new(target)
76
- if block_given?
77
- receiver.run(&Proc.new)
78
- else
79
- case specfile
80
- when Specfile, String, Proc
81
- receiver.run(specfile)
82
- else
83
- raise ArgumentError, "specfile must be a #{Specfile}, #{String}, or #{Proc} if no block is given (it was #{specfile.inspect})"
84
- end
85
- end
79
+ receiver.run(specfile)
86
80
 
87
81
  debug_named_source_cache("Post-Cached Sources", target)
88
82
  end.to_spec
@@ -1,4 +1,4 @@
1
- require 'librarian/specfile'
1
+ require "pathname"
2
2
 
3
3
  module Librarian
4
4
  class Dsl
@@ -26,21 +26,17 @@ module Librarian
26
26
  specfile = Proc.new if block_given?
27
27
 
28
28
  case specfile
29
- when Specfile
30
- eval(specfile.path.read, instance_binding, specfile.path.to_s, 1)
29
+ when Pathname
30
+ instance_eval(File.read(specfile), specfile.to_s, 1)
31
31
  when String
32
- eval(specfile, instance_binding)
32
+ instance_eval(specfile)
33
33
  when Proc
34
34
  instance_eval(&specfile)
35
35
  else
36
- raise ArgumentError, "specfile must be a #{Specfile}, #{String}, or #{Proc} if no block is given (it was #{specfile.inspect})"
36
+ raise ArgumentError, "specfile must be a #{Pathname}, #{String}, or #{Proc} if no block is given (it was #{specfile.inspect})"
37
37
  end
38
38
  end
39
39
 
40
- def instance_binding
41
- binding
42
- end
43
-
44
40
  end
45
41
  end
46
42
  end
@@ -1,3 +1,5 @@
1
+ require "pathname"
2
+
1
3
  module Librarian
2
4
  class Specfile
3
5
 
@@ -6,11 +8,11 @@ module Librarian
6
8
 
7
9
  def initialize(environment, path)
8
10
  self.environment = environment
9
- self.path = path
11
+ self.path = Pathname(path)
10
12
  end
11
13
 
12
14
  def read(precache_sources = [])
13
- environment.dsl(path.read, precache_sources)
15
+ environment.dsl(path, precache_sources)
14
16
  end
15
17
 
16
18
  end
@@ -1,3 +1,3 @@
1
1
  module Librarian
2
- VERSION = "0.1.0.beta.1"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -2,19 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "librarian"
5
- s.version = "0.1.0.beta.1"
5
+ s.version = "0.1.0"
6
6
 
7
- s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jay Feldblum"]
9
- s.date = "2013-03-09"
9
+ s.date = "2013-04-03"
10
10
  s.description = "Librarian"
11
11
  s.email = ["y_feldblum@yahoo.com"]
12
- s.files = [".gitignore", ".rspec", ".travis.yml", "CHANGELOG.md", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "lib/librarian.rb", "lib/librarian/action.rb", "lib/librarian/action/base.rb", "lib/librarian/action/clean.rb", "lib/librarian/action/ensure.rb", "lib/librarian/action/install.rb", "lib/librarian/action/persist_resolution_mixin.rb", "lib/librarian/action/resolve.rb", "lib/librarian/action/update.rb", "lib/librarian/chef/version.rb", "lib/librarian/cli.rb", "lib/librarian/cli/manifest_presenter.rb", "lib/librarian/config.rb", "lib/librarian/config/database.rb", "lib/librarian/config/file_source.rb", "lib/librarian/config/hash_source.rb", "lib/librarian/config/source.rb", "lib/librarian/dependency.rb", "lib/librarian/dsl.rb", "lib/librarian/dsl/receiver.rb", "lib/librarian/dsl/target.rb", "lib/librarian/environment.rb", "lib/librarian/error.rb", "lib/librarian/helpers.rb", "lib/librarian/linter/source_linter.rb", "lib/librarian/lockfile.rb", "lib/librarian/lockfile/compiler.rb", "lib/librarian/lockfile/parser.rb", "lib/librarian/logger.rb", "lib/librarian/manifest.rb", "lib/librarian/manifest_set.rb", "lib/librarian/mock.rb", "lib/librarian/mock/cli.rb", "lib/librarian/mock/dsl.rb", "lib/librarian/mock/environment.rb", "lib/librarian/mock/extension.rb", "lib/librarian/mock/source.rb", "lib/librarian/mock/source/mock.rb", "lib/librarian/mock/source/mock/registry.rb", "lib/librarian/mock/version.rb", "lib/librarian/resolution.rb", "lib/librarian/resolver.rb", "lib/librarian/resolver/implementation.rb", "lib/librarian/rspec/support/cli_macro.rb", "lib/librarian/source.rb", "lib/librarian/source/basic_api.rb", "lib/librarian/source/git.rb", "lib/librarian/source/git/repository.rb", "lib/librarian/source/local.rb", "lib/librarian/source/path.rb", "lib/librarian/spec.rb", "lib/librarian/spec_change_set.rb", "lib/librarian/specfile.rb", "lib/librarian/support/abstract_method.rb", "lib/librarian/ui.rb", "lib/librarian/version.rb", "librarian.gemspec", "spec/functional/cli_spec.rb", "spec/functional/source/git/repository_spec.rb", "spec/support/method_patch_macro.rb", "spec/support/with_env_macro.rb", "spec/unit/action/base_spec.rb", "spec/unit/action/clean_spec.rb", "spec/unit/action/ensure_spec.rb", "spec/unit/action/install_spec.rb", "spec/unit/config/database_spec.rb", "spec/unit/dependency_spec.rb", "spec/unit/dsl_spec.rb", "spec/unit/environment_spec.rb", "spec/unit/lockfile/parser_spec.rb", "spec/unit/lockfile_spec.rb", "spec/unit/manifest_set_spec.rb", "spec/unit/manifest_spec.rb", "spec/unit/mock/source/mock_spec.rb", "spec/unit/resolver_spec.rb", "spec/unit/source/git_spec.rb", "spec/unit/spec_change_set_spec.rb"]
12
+ s.files = [".gitignore", ".rspec", ".travis.yml", "CHANGELOG.md", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "lib/librarian.rb", "lib/librarian/action.rb", "lib/librarian/action/base.rb", "lib/librarian/action/clean.rb", "lib/librarian/action/ensure.rb", "lib/librarian/action/install.rb", "lib/librarian/action/persist_resolution_mixin.rb", "lib/librarian/action/resolve.rb", "lib/librarian/action/update.rb", "lib/librarian/cli.rb", "lib/librarian/cli/manifest_presenter.rb", "lib/librarian/config.rb", "lib/librarian/config/database.rb", "lib/librarian/config/file_source.rb", "lib/librarian/config/hash_source.rb", "lib/librarian/config/source.rb", "lib/librarian/dependency.rb", "lib/librarian/dsl.rb", "lib/librarian/dsl/receiver.rb", "lib/librarian/dsl/target.rb", "lib/librarian/environment.rb", "lib/librarian/error.rb", "lib/librarian/helpers.rb", "lib/librarian/linter/source_linter.rb", "lib/librarian/lockfile.rb", "lib/librarian/lockfile/compiler.rb", "lib/librarian/lockfile/parser.rb", "lib/librarian/logger.rb", "lib/librarian/manifest.rb", "lib/librarian/manifest_set.rb", "lib/librarian/mock.rb", "lib/librarian/mock/cli.rb", "lib/librarian/mock/dsl.rb", "lib/librarian/mock/environment.rb", "lib/librarian/mock/extension.rb", "lib/librarian/mock/source.rb", "lib/librarian/mock/source/mock.rb", "lib/librarian/mock/source/mock/registry.rb", "lib/librarian/mock/version.rb", "lib/librarian/resolution.rb", "lib/librarian/resolver.rb", "lib/librarian/resolver/implementation.rb", "lib/librarian/rspec/support/cli_macro.rb", "lib/librarian/source.rb", "lib/librarian/source/basic_api.rb", "lib/librarian/source/git.rb", "lib/librarian/source/git/repository.rb", "lib/librarian/source/local.rb", "lib/librarian/source/path.rb", "lib/librarian/spec.rb", "lib/librarian/spec_change_set.rb", "lib/librarian/specfile.rb", "lib/librarian/support/abstract_method.rb", "lib/librarian/ui.rb", "lib/librarian/version.rb", "librarian.gemspec", "spec/functional/cli_spec.rb", "spec/functional/source/git/repository_spec.rb", "spec/support/fakefs.rb", "spec/support/method_patch_macro.rb", "spec/support/with_env_macro.rb", "spec/unit/action/base_spec.rb", "spec/unit/action/clean_spec.rb", "spec/unit/action/ensure_spec.rb", "spec/unit/action/install_spec.rb", "spec/unit/config/database_spec.rb", "spec/unit/dependency_spec.rb", "spec/unit/dsl_spec.rb", "spec/unit/environment_spec.rb", "spec/unit/lockfile/parser_spec.rb", "spec/unit/lockfile_spec.rb", "spec/unit/manifest_set_spec.rb", "spec/unit/manifest_spec.rb", "spec/unit/mock/source/mock_spec.rb", "spec/unit/resolver_spec.rb", "spec/unit/source/git_spec.rb", "spec/unit/spec_change_set_spec.rb"]
13
13
  s.homepage = ""
14
14
  s.require_paths = ["lib"]
15
15
  s.rubygems_version = "1.8.25"
16
16
  s.summary = "Librarian"
17
- s.test_files = ["spec/functional/cli_spec.rb", "spec/functional/source/git/repository_spec.rb", "spec/support/method_patch_macro.rb", "spec/support/with_env_macro.rb", "spec/unit/action/base_spec.rb", "spec/unit/action/clean_spec.rb", "spec/unit/action/ensure_spec.rb", "spec/unit/action/install_spec.rb", "spec/unit/config/database_spec.rb", "spec/unit/dependency_spec.rb", "spec/unit/dsl_spec.rb", "spec/unit/environment_spec.rb", "spec/unit/lockfile/parser_spec.rb", "spec/unit/lockfile_spec.rb", "spec/unit/manifest_set_spec.rb", "spec/unit/manifest_spec.rb", "spec/unit/mock/source/mock_spec.rb", "spec/unit/resolver_spec.rb", "spec/unit/source/git_spec.rb", "spec/unit/spec_change_set_spec.rb"]
17
+ s.test_files = ["spec/functional/cli_spec.rb", "spec/functional/source/git/repository_spec.rb", "spec/support/fakefs.rb", "spec/support/method_patch_macro.rb", "spec/support/with_env_macro.rb", "spec/unit/action/base_spec.rb", "spec/unit/action/clean_spec.rb", "spec/unit/action/ensure_spec.rb", "spec/unit/action/install_spec.rb", "spec/unit/config/database_spec.rb", "spec/unit/dependency_spec.rb", "spec/unit/dsl_spec.rb", "spec/unit/environment_spec.rb", "spec/unit/lockfile/parser_spec.rb", "spec/unit/lockfile_spec.rb", "spec/unit/manifest_set_spec.rb", "spec/unit/manifest_spec.rb", "spec/unit/mock/source/mock_spec.rb", "spec/unit/resolver_spec.rb", "spec/unit/source/git_spec.rb", "spec/unit/spec_change_set_spec.rb"]
18
18
 
19
19
  if s.respond_to? :specification_version then
20
20
  s.specification_version = 3
@@ -0,0 +1,24 @@
1
+ require "fakefs/safe"
2
+ require "fakefs/spec_helpers"
3
+ require "support/method_patch_macro"
4
+
5
+ module Support
6
+ module FakeFS
7
+
8
+ def self.included(base)
9
+ base.module_exec do
10
+ include ::FakeFS::SpecHelpers
11
+ end
12
+
13
+ # Since ruby-1.9.3-p286, Kernel#Pathname was changed in a way that broke
14
+ # FakeFS's assumptions. It used to lookup the Pathname constant (which is
15
+ # where FakeFS hooks) and send it #new, but now it keeps a reference to
16
+ # the Pathname constant (breaking the FakeFS hook).
17
+ base.module_exec do
18
+ include MethodPatchMacro
19
+ with_module_method(Kernel, :Pathname){|s| Pathname.new(s)}
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -1,23 +1,23 @@
1
1
  require "securerandom"
2
2
 
3
- module MethodPatchMacro
3
+ module Support
4
+ module MethodPatchMacro
4
5
 
5
- def self.included(base)
6
- base.extend ClassMethods
7
- end
6
+ def self.included(base)
7
+ base.extend ClassMethods
8
+ end
8
9
 
9
- module ClassMethods
10
- def with_module_method(mod, meth, &block)
11
- tag = SecureRandom.hex(8)
12
- orig_meth = "_#{tag}_#{meth}".to_sym
13
- around do |example|
14
- mod.module_eval do
15
- alias_method orig_meth, meth
16
- define_method meth, &block
10
+ module ClassMethods
11
+ def with_module_method(mod, meth, &block)
12
+ tag = SecureRandom.hex(8)
13
+ orig_meth = "_#{tag}_#{meth}".to_sym
14
+ before do
15
+ mod.module_eval do
16
+ alias_method orig_meth, meth
17
+ define_method meth, &block
18
+ end
17
19
  end
18
- begin
19
- example.run
20
- ensure
20
+ after do
21
21
  mod.module_eval do
22
22
  alias_method meth, orig_meth
23
23
  remove_method orig_meth
@@ -25,6 +25,6 @@ module MethodPatchMacro
25
25
  end
26
26
  end
27
27
  end
28
- end
29
28
 
29
+ end
30
30
  end
@@ -1,20 +1,22 @@
1
- module WithEnvMacro
1
+ module Support
2
+ module WithEnvMacro
2
3
 
3
- module ClassMethods
4
+ module ClassMethods
4
5
 
5
- def with_env(new)
6
- old = Hash[new.map{|k, v| [k, ENV[k]]}]
6
+ def with_env(new)
7
+ old = Hash[new.map{|k, v| [k, ENV[k]]}]
8
+
9
+ before { ENV.update(new) }
10
+ after { ENV.update(old) }
11
+ end
7
12
 
8
- before { ENV.update(new) }
9
- after { ENV.update(old) }
10
13
  end
11
14
 
12
- end
15
+ private
13
16
 
14
- private
17
+ def self.included(base)
18
+ base.extend(ClassMethods)
19
+ end
15
20
 
16
- def self.included(base)
17
- base.extend(ClassMethods)
18
21
  end
19
-
20
22
  end
@@ -1,21 +1,14 @@
1
1
  require "fileutils"
2
2
  require "pathname"
3
+ require "tmpdir"
3
4
  require "yaml"
4
5
 
5
- require "fakefs/spec_helpers"
6
-
7
- require "support/method_patch_macro"
6
+ require "support/fakefs"
8
7
 
9
8
  require "librarian/config/database"
10
9
 
11
10
  describe Librarian::Config::Database do
12
- include FakeFS::SpecHelpers
13
- include MethodPatchMacro
14
-
15
- # FakeFS seems to need this because Kernel#Pathname was changed in 1.9.3-p286.
16
- # It used to indicate the Pathname class by name, but now it references the
17
- # Pathname class directly by object. FakeFS relies on the old behavior.
18
- with_module_method(Kernel, :Pathname){|s| Pathname.new(s)}
11
+ include ::Support::FakeFS
19
12
 
20
13
  def write_yaml!(path, *yamlables)
21
14
  path = Pathname(path)
@@ -26,7 +19,7 @@ describe Librarian::Config::Database do
26
19
  let(:adapter_name) { "gem" }
27
20
 
28
21
  let(:env) { { } }
29
- let(:pwd) { Pathname("/tmp") }
22
+ let(:pwd) { Pathname(Dir.tmpdir) }
30
23
  let(:home) { Pathname("~").expand_path }
31
24
  let(:project_path) { nil }
32
25
  let(:specfile_name) { nil }
@@ -4,7 +4,7 @@ require "support/with_env_macro"
4
4
 
5
5
  module Librarian
6
6
  describe Environment do
7
- include WithEnvMacro
7
+ include ::Support::WithEnvMacro
8
8
 
9
9
  let(:env) { described_class.new }
10
10
 
@@ -1,9 +1,15 @@
1
+ require "pathname"
2
+ require "tmpdir"
3
+
4
+ require "support/fakefs"
5
+
1
6
  require 'librarian/resolver'
2
7
  require 'librarian/spec_change_set'
3
8
  require 'librarian/mock'
4
9
 
5
10
  module Librarian
6
11
  describe Resolver do
12
+ include ::Support::FakeFS
7
13
 
8
14
  let(:env) { Mock::Environment.new }
9
15
  let(:resolver) { env.resolver }
@@ -229,5 +235,24 @@ module Librarian
229
235
 
230
236
  end
231
237
 
238
+ context "a pathname to a simple specfile" do
239
+ let(:pwd) { Pathname(Dir.tmpdir) }
240
+ let(:specfile_path) { pwd + "Mockfile" }
241
+ before { FileUtils.mkpath(pwd) }
242
+
243
+ def write!(path, text)
244
+ Pathname(path).open("wb"){|f| f.write(text)}
245
+ end
246
+
247
+ it "loads the specfile with the __FILE__" do
248
+ write! specfile_path, "src __FILE__"
249
+ spec = env.dsl(specfile_path)
250
+ spec.sources.should have(1).item
251
+ source = spec.sources.first
252
+ source.name.should == specfile_path.to_s
253
+ end
254
+
255
+ end
256
+
232
257
  end
233
258
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: librarian
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: 6
5
- version: 0.1.0.beta.1
4
+ prerelease:
5
+ version: 0.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jay Feldblum
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-09 00:00:00.000000000 Z
12
+ date: 2013-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  type: :runtime
@@ -131,7 +131,6 @@ files:
131
131
  - lib/librarian/action/persist_resolution_mixin.rb
132
132
  - lib/librarian/action/resolve.rb
133
133
  - lib/librarian/action/update.rb
134
- - lib/librarian/chef/version.rb
135
134
  - lib/librarian/cli.rb
136
135
  - lib/librarian/cli/manifest_presenter.rb
137
136
  - lib/librarian/config.rb
@@ -181,6 +180,7 @@ files:
181
180
  - librarian.gemspec
182
181
  - spec/functional/cli_spec.rb
183
182
  - spec/functional/source/git/repository_spec.rb
183
+ - spec/support/fakefs.rb
184
184
  - spec/support/method_patch_macro.rb
185
185
  - spec/support/with_env_macro.rb
186
186
  - spec/unit/action/base_spec.rb
@@ -212,14 +212,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
212
212
  - !ruby/object:Gem::Version
213
213
  segments:
214
214
  - 0
215
- hash: 3722250136317234111
215
+ hash: -845093804329551248
216
216
  version: '0'
217
217
  required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  none: false
219
219
  requirements:
220
- - - ! '>'
220
+ - - ! '>='
221
221
  - !ruby/object:Gem::Version
222
- version: 1.3.1
222
+ version: '0'
223
223
  requirements: []
224
224
  rubyforge_project:
225
225
  rubygems_version: 1.8.25
@@ -229,6 +229,7 @@ summary: Librarian
229
229
  test_files:
230
230
  - spec/functional/cli_spec.rb
231
231
  - spec/functional/source/git/repository_spec.rb
232
+ - spec/support/fakefs.rb
232
233
  - spec/support/method_patch_macro.rb
233
234
  - spec/support/with_env_macro.rb
234
235
  - spec/unit/action/base_spec.rb
@@ -1,5 +0,0 @@
1
- module Librarian
2
- module Chef
3
- VERSION = "0.0.1"
4
- end
5
- end