expert 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +15 -0
  3. data/History.txt +3 -0
  4. data/README.md +0 -0
  5. data/Rakefile +18 -0
  6. data/bin/expert +4 -0
  7. data/expert.gemspec +19 -0
  8. data/lib/expert.rb +76 -0
  9. data/lib/expert/classpath_file.rb +27 -0
  10. data/lib/expert/cli.rb +21 -0
  11. data/lib/expert/environment.rb +51 -0
  12. data/lib/expert/jar_dependency.rb +17 -0
  13. data/lib/expert/jarfile.rb +40 -0
  14. data/lib/expert/jarfile_parser.rb +81 -0
  15. data/lib/expert/jarfile_tokenizer.rb +41 -0
  16. data/lib/expert/maven.rb +28 -0
  17. data/lib/expert/pom_file.rb +97 -0
  18. data/lib/expert/version.rb +5 -0
  19. data/vendor/apache-maven-3.3.3/LICENSE +305 -0
  20. data/vendor/apache-maven-3.3.3/NOTICE +8 -0
  21. data/vendor/apache-maven-3.3.3/README.txt +79 -0
  22. data/vendor/apache-maven-3.3.3/bin/m2.conf +8 -0
  23. data/vendor/apache-maven-3.3.3/bin/mvn +232 -0
  24. data/vendor/apache-maven-3.3.3/bin/mvn.cmd +176 -0
  25. data/vendor/apache-maven-3.3.3/bin/mvnDebug +41 -0
  26. data/vendor/apache-maven-3.3.3/bin/mvnDebug.cmd +31 -0
  27. data/vendor/apache-maven-3.3.3/bin/mvnyjp +42 -0
  28. data/vendor/apache-maven-3.3.3/boot/plexus-classworlds-2.5.2.jar +0 -0
  29. data/vendor/apache-maven-3.3.3/conf/logging/simplelogger.properties +25 -0
  30. data/vendor/apache-maven-3.3.3/conf/settings.xml +257 -0
  31. data/vendor/apache-maven-3.3.3/conf/toolchains.xml +103 -0
  32. data/vendor/apache-maven-3.3.3/lib/aether-api-1.0.2.v20150114.jar +0 -0
  33. data/vendor/apache-maven-3.3.3/lib/aether-api.license +261 -0
  34. data/vendor/apache-maven-3.3.3/lib/aether-connector-basic-1.0.2.v20150114.jar +0 -0
  35. data/vendor/apache-maven-3.3.3/lib/aether-connector-basic.license +261 -0
  36. data/vendor/apache-maven-3.3.3/lib/aether-impl-1.0.2.v20150114.jar +0 -0
  37. data/vendor/apache-maven-3.3.3/lib/aether-impl.license +261 -0
  38. data/vendor/apache-maven-3.3.3/lib/aether-spi-1.0.2.v20150114.jar +0 -0
  39. data/vendor/apache-maven-3.3.3/lib/aether-spi.license +261 -0
  40. data/vendor/apache-maven-3.3.3/lib/aether-transport-wagon-1.0.2.v20150114.jar +0 -0
  41. data/vendor/apache-maven-3.3.3/lib/aether-transport-wagon.license +261 -0
  42. data/vendor/apache-maven-3.3.3/lib/aether-util-1.0.2.v20150114.jar +0 -0
  43. data/vendor/apache-maven-3.3.3/lib/aether-util.license +261 -0
  44. data/vendor/apache-maven-3.3.3/lib/aopalliance-1.0.jar +0 -0
  45. data/vendor/apache-maven-3.3.3/lib/cdi-api-1.0.jar +0 -0
  46. data/vendor/apache-maven-3.3.3/lib/cdi-api.license +389 -0
  47. data/vendor/apache-maven-3.3.3/lib/commons-cli-1.2.jar +0 -0
  48. data/vendor/apache-maven-3.3.3/lib/commons-io-2.2.jar +0 -0
  49. data/vendor/apache-maven-3.3.3/lib/commons-lang-2.6.jar +0 -0
  50. data/vendor/apache-maven-3.3.3/lib/ext/README.txt +2 -0
  51. data/vendor/apache-maven-3.3.3/lib/guava-18.0.jar +0 -0
  52. data/vendor/apache-maven-3.3.3/lib/javax.inject-1.jar +0 -0
  53. data/vendor/apache-maven-3.3.3/lib/jsoup-1.7.2.jar +0 -0
  54. data/vendor/apache-maven-3.3.3/lib/jsoup.license +65 -0
  55. data/vendor/apache-maven-3.3.3/lib/jsr250-api-1.0.jar +0 -0
  56. data/vendor/apache-maven-3.3.3/lib/jsr250-api.license +406 -0
  57. data/vendor/apache-maven-3.3.3/lib/maven-aether-provider-3.3.3.jar +0 -0
  58. data/vendor/apache-maven-3.3.3/lib/maven-aether-provider.license +202 -0
  59. data/vendor/apache-maven-3.3.3/lib/maven-artifact-3.3.3.jar +0 -0
  60. data/vendor/apache-maven-3.3.3/lib/maven-artifact.license +202 -0
  61. data/vendor/apache-maven-3.3.3/lib/maven-builder-support-3.3.3.jar +0 -0
  62. data/vendor/apache-maven-3.3.3/lib/maven-builder-support.license +202 -0
  63. data/vendor/apache-maven-3.3.3/lib/maven-compat-3.3.3.jar +0 -0
  64. data/vendor/apache-maven-3.3.3/lib/maven-compat.license +202 -0
  65. data/vendor/apache-maven-3.3.3/lib/maven-core-3.3.3.jar +0 -0
  66. data/vendor/apache-maven-3.3.3/lib/maven-core.license +202 -0
  67. data/vendor/apache-maven-3.3.3/lib/maven-embedder-3.3.3.jar +0 -0
  68. data/vendor/apache-maven-3.3.3/lib/maven-embedder.license +202 -0
  69. data/vendor/apache-maven-3.3.3/lib/maven-model-3.3.3.jar +0 -0
  70. data/vendor/apache-maven-3.3.3/lib/maven-model-builder-3.3.3.jar +0 -0
  71. data/vendor/apache-maven-3.3.3/lib/maven-model-builder.license +202 -0
  72. data/vendor/apache-maven-3.3.3/lib/maven-model.license +202 -0
  73. data/vendor/apache-maven-3.3.3/lib/maven-plugin-api-3.3.3.jar +0 -0
  74. data/vendor/apache-maven-3.3.3/lib/maven-plugin-api.license +202 -0
  75. data/vendor/apache-maven-3.3.3/lib/maven-repository-metadata-3.3.3.jar +0 -0
  76. data/vendor/apache-maven-3.3.3/lib/maven-repository-metadata.license +202 -0
  77. data/vendor/apache-maven-3.3.3/lib/maven-settings-3.3.3.jar +0 -0
  78. data/vendor/apache-maven-3.3.3/lib/maven-settings-builder-3.3.3.jar +0 -0
  79. data/vendor/apache-maven-3.3.3/lib/maven-settings-builder.license +202 -0
  80. data/vendor/apache-maven-3.3.3/lib/maven-settings.license +202 -0
  81. data/vendor/apache-maven-3.3.3/lib/org.eclipse.sisu.inject-0.3.0.jar +0 -0
  82. data/vendor/apache-maven-3.3.3/lib/org.eclipse.sisu.inject.license +261 -0
  83. data/vendor/apache-maven-3.3.3/lib/org.eclipse.sisu.plexus-0.3.0.jar +0 -0
  84. data/vendor/apache-maven-3.3.3/lib/org.eclipse.sisu.plexus.license +261 -0
  85. data/vendor/apache-maven-3.3.3/lib/plexus-cipher-1.7.jar +0 -0
  86. data/vendor/apache-maven-3.3.3/lib/plexus-cipher.license +389 -0
  87. data/vendor/apache-maven-3.3.3/lib/plexus-component-annotations-1.5.5.jar +0 -0
  88. data/vendor/apache-maven-3.3.3/lib/plexus-interpolation-1.21.jar +0 -0
  89. data/vendor/apache-maven-3.3.3/lib/plexus-sec-dispatcher-1.3.jar +0 -0
  90. data/vendor/apache-maven-3.3.3/lib/plexus-sec-dispatcher.license +389 -0
  91. data/vendor/apache-maven-3.3.3/lib/plexus-utils-3.0.20.jar +0 -0
  92. data/vendor/apache-maven-3.3.3/lib/sisu-guice-3.2.5-no_aop.jar +0 -0
  93. data/vendor/apache-maven-3.3.3/lib/slf4j-api-1.7.5.jar +0 -0
  94. data/vendor/apache-maven-3.3.3/lib/slf4j-api.license +191 -0
  95. data/vendor/apache-maven-3.3.3/lib/slf4j-simple-1.7.5.jar +0 -0
  96. data/vendor/apache-maven-3.3.3/lib/slf4j-simple.license +191 -0
  97. data/vendor/apache-maven-3.3.3/lib/wagon-file-2.9.jar +0 -0
  98. data/vendor/apache-maven-3.3.3/lib/wagon-file.license +202 -0
  99. data/vendor/apache-maven-3.3.3/lib/wagon-http-2.9-shaded.jar +0 -0
  100. data/vendor/apache-maven-3.3.3/lib/wagon-http-shared-2.9.jar +0 -0
  101. data/vendor/apache-maven-3.3.3/lib/wagon-http-shared.license +202 -0
  102. data/vendor/apache-maven-3.3.3/lib/wagon-http.license +202 -0
  103. data/vendor/apache-maven-3.3.3/lib/wagon-provider-api-2.9.jar +0 -0
  104. data/vendor/apache-maven-3.3.3/lib/wagon-provider-api.license +202 -0
  105. metadata +148 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 916ed2662d22a6ac4391d57c19c84e80ae5c154a
4
+ data.tar.gz: 5680a35349f5c0db60a3538cf9530938bf5b8081
5
+ SHA512:
6
+ metadata.gz: 9b09c9a30d8f558beed1e3c11a9e82b2255a7b96ab2f174d035500a0098a490d51f8219bf459a8e4e93722ee9692b05203319e901c6a5ba1949882fcb617f425
7
+ data.tar.gz: cf799ff38ae14b103f6a04fc556b53900303e25e690d3ac1376919936155913e2513fe26acec3fd79dc0d1eb4e1e285c0283ebeddc49052500a9be295da8be8d
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ ruby '2.0.0', engine: 'jruby', engine_version: JRUBY_VERSION
6
+
7
+ group :development, :test do
8
+ gem 'pry-nav'
9
+ gem 'rake'
10
+ end
11
+
12
+ group :test do
13
+ gem 'simplecov'
14
+ gem 'rspec'
15
+ end
@@ -0,0 +1,3 @@
1
+ == 1.0.0
2
+
3
+ * Birthday!
File without changes
@@ -0,0 +1,18 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
4
+
5
+ require 'bundler'
6
+ require 'rspec/core/rake_task'
7
+ require 'rubygems/package_task'
8
+
9
+ require './lib/expert'
10
+
11
+ Bundler::GemHelper.install_tasks
12
+
13
+ task :default => :spec
14
+
15
+ desc 'Run specs'
16
+ RSpec::Core::RakeTask.new do |t|
17
+ t.pattern = './spec/**/*_spec.rb'
18
+ end
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'expert'
4
+ Expert::Cli.start(ARGV)
@@ -0,0 +1,19 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), 'lib')
2
+ require 'expert/version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'expert'
6
+ s.version = ::Expert::VERSION
7
+ s.authors = ['Cameron Dutro']
8
+ s.email = ['camertron@gmail.com']
9
+ s.homepage = 'http://github.com/camertron'
10
+
11
+ s.description = s.summary = 'Manage and install jar dependencies (an alternative to jbundler).'
12
+
13
+ s.platform = Gem::Platform::RUBY
14
+ s.has_rdoc = true
15
+
16
+ s.require_path = 'lib'
17
+ s.executables << 'expert'
18
+ s.files = Dir['{lib,spec,vendor}/**/*', 'Gemfile', 'History.txt', 'README.md', 'Rakefile', 'expert.gemspec']
19
+ end
@@ -0,0 +1,76 @@
1
+ # encoding: UTF-8
2
+
3
+ module Expert
4
+ autoload :ClasspathFile, 'expert/classpath_file'
5
+ autoload :Cli, 'expert/cli'
6
+ autoload :Environment, 'expert/environment'
7
+ autoload :Jarfile, 'expert/jarfile'
8
+ autoload :JarDependency, 'expert/jar_dependency'
9
+ autoload :JarfileParser, 'expert/jarfile_parser'
10
+ autoload :JarfileTokenizer, 'expert/jarfile_tokenizer'
11
+ autoload :Maven, 'expert/maven'
12
+ autoload :PomFile, 'expert/pom_file'
13
+
14
+ # The Jarfile declares dependencies. The pom/classpath function like a
15
+ # Gemfile.lock or Jarfile.lock.
16
+ DEFAULT_JARFILE_PATH = './Jarfile'
17
+ DEFAULT_POM_PATH = './pom.xml'
18
+ DEFAULT_CLASSPATH_FILE = './classpath.txt'
19
+ MAVEN_VERSION = '3.3.3'
20
+
21
+ class << self
22
+ def environment
23
+ @environment ||= begin
24
+ check_bundler_required
25
+ check_jarfile_exists
26
+
27
+ Environment.new(load_jarfile, load_pom, load_classpath)
28
+ end
29
+ end
30
+
31
+ def jarfile_path
32
+ ENV.fetch('EXPERT_JARFILE', DEFAULT_JARFILE_PATH)
33
+ end
34
+
35
+ def pom_path
36
+ ENV.fetch('EXPERT_POM', DEFAULT_POM_PATH)
37
+ end
38
+
39
+ def classpath_file_path
40
+ ENV.fetch('EXPERT_CLASSPATH_FILE', DEFAULT_CLASSPATH_FILE)
41
+ end
42
+
43
+ protected
44
+
45
+ def check_bundler_required
46
+ unless defined?(Bundler)
47
+ raise "Bundler hasn't been required. Please run expert in the context "\
48
+ "of your bundle."
49
+ end
50
+ end
51
+
52
+ def check_jarfile_exists
53
+ unless File.exist?(jarfile_path)
54
+ raise "Couldn't find a Jarfile at #{jarfile_path}. A Jarfile is "\
55
+ "required to declare jar dependencies. You can manually specify a "\
56
+ "Jarfile location via the EXPERT_JARFILE environment variable."
57
+ end
58
+ end
59
+
60
+ def load_jarfile
61
+ Jarfile.from_path(jarfile_path)
62
+ end
63
+
64
+ def load_pom
65
+ if File.exist?(pom_path)
66
+ PomFile.from_path(pom_path)
67
+ end
68
+ end
69
+
70
+ def load_classpath
71
+ if File.exist?(classpath_file_path)
72
+ ClasspathFile.from_path(classpath_file_path)
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,27 @@
1
+ # encoding: UTF-8
2
+
3
+ module Expert
4
+ class ClasspathFile
5
+ attr_reader :paths
6
+
7
+ class << self
8
+ def from_path(path)
9
+ new(load(path))
10
+ end
11
+
12
+ protected
13
+
14
+ def load(path)
15
+ File.read(path).split(':')
16
+ end
17
+ end
18
+
19
+ def initialize(paths)
20
+ @paths = paths
21
+ end
22
+
23
+ def require_all
24
+ paths.each { |p| Kernel.require(p) }
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,21 @@
1
+ # encoding: UTF-8
2
+
3
+ module Expert
4
+ class Cli
5
+ class << self
6
+ def start(argv)
7
+ cmd = argv[0].to_sym
8
+
9
+ if respond_to?(cmd)
10
+ public_send(cmd, argv[1..-1])
11
+ else
12
+ raise "Couldn't find command '#{cmd}'"
13
+ end
14
+ end
15
+
16
+ def install(args)
17
+ Expert.environment.install
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: UTF-8
2
+
3
+ module Expert
4
+ class DependenciesNotInstalledError < StandardError; end
5
+
6
+ class Environment
7
+ attr_reader :jarfile, :pom, :classpath
8
+
9
+ def initialize(jarfile, pom, classpath)
10
+ @jarfile = jarfile
11
+ @pom = pom
12
+ @classpath = classpath
13
+ end
14
+
15
+ def install
16
+ install_pom
17
+ install_classpath
18
+ end
19
+
20
+ def installed?
21
+ pom && classpath
22
+ end
23
+
24
+ def require_all
25
+ if installed?
26
+ classpath.require_all
27
+ else
28
+ raise DependenciesNotInstalledError,
29
+ "Maven dependencies haven't been installed yet (did you forget to "\
30
+ "run `expert install`?)"
31
+ end
32
+ end
33
+
34
+ protected
35
+
36
+ def install_pom
37
+ @pom = PomFile.new(jarfile.dependencies)
38
+ pom.write(Expert.pom_path)
39
+ end
40
+
41
+ def install_classpath
42
+ mvn.resolve
43
+ mvn.build_classpath(Expert.classpath_file_path)
44
+ @classpath = ClasspathFile.from_path(Expert.classpath_file_path)
45
+ end
46
+
47
+ def mvn
48
+ Expert::Maven
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,17 @@
1
+ # encoding: UTF-8
2
+
3
+ module Expert
4
+ class JarDependency
5
+ attr_reader :group_id, :artifact_id, :version
6
+
7
+ def initialize(group_id, artifact_id, version)
8
+ @group_id = group_id
9
+ @artifact_id = artifact_id
10
+ @version = version
11
+ end
12
+
13
+ def classifier
14
+ "#{group_id}:#{artifact_id}"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,40 @@
1
+ # encoding: UTF-8
2
+
3
+ module Expert
4
+ class Jarfile
5
+ attr_reader :dependencies
6
+
7
+ class << self
8
+ def from_path(jarfile_path)
9
+ new(load(jarfile_path))
10
+ end
11
+
12
+ protected
13
+
14
+ def load(jarfile_path)
15
+ jar_deps = parse(jar_requirements_from_gems.join("\n"))
16
+ jarfile_deps = parse(File.read(jarfile_path))
17
+ (jar_deps + jarfile_deps).uniq(&:classifier)
18
+ end
19
+
20
+ def parse(contents)
21
+ tokens = JarfileTokenizer.tokenize(contents)
22
+ JarfileParser.new(tokens).dependencies
23
+ end
24
+
25
+ def jar_requirements_from_gems
26
+ requirements_from_gems.select do |requirement|
27
+ requirement.respond_to?(:start_with?) && requirement.start_with?('jar ')
28
+ end
29
+ end
30
+
31
+ def requirements_from_gems
32
+ Bundler.environment.specs.flat_map(&:requirements)
33
+ end
34
+ end
35
+
36
+ def initialize(dependencies)
37
+ @dependencies = dependencies
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,81 @@
1
+ # encoding: UTF-8
2
+
3
+ module Expert
4
+ class UnexpectedTokenError < StandardError; end
5
+
6
+ class JarfileParser
7
+ attr_reader :tokens, :index
8
+
9
+ def initialize(tokens)
10
+ @tokens = tokens
11
+ end
12
+
13
+ def each_dependency(&block)
14
+ rewind
15
+ each_jar(&block)
16
+ end
17
+
18
+ def dependencies
19
+ rewind
20
+ each_jar.to_a
21
+ end
22
+
23
+ protected
24
+
25
+ def each_jar
26
+ if block_given?
27
+ consume
28
+ yield jar until eos?
29
+ else
30
+ to_enum(__method__)
31
+ end
32
+ end
33
+
34
+ def jar
35
+ consume(:jar)
36
+ consume(:quote)
37
+ group_id, artifact_id = consume(:string).value.split(':')
38
+ consume(:quote)
39
+ consume(:comma)
40
+ consume(:quote)
41
+ version = consume(:string).value
42
+ consume(:quote)
43
+ JarDependency.new(group_id, artifact_id, version)
44
+ end
45
+
46
+ def consume(type = nil)
47
+ token = current_token
48
+
49
+ if type
50
+ if current_token.type == type && !eos?
51
+ @index += 1
52
+ else
53
+ raise UnexpectedTokenError,
54
+ "Expected token of type '#{type}', got '#{current_token.type}'"
55
+ end
56
+ end
57
+
58
+ while should_skip_current?
59
+ @index += 1
60
+ end
61
+
62
+ token
63
+ end
64
+
65
+ def should_skip_current?
66
+ !eos? && current_token.type == :comment
67
+ end
68
+
69
+ def current_token
70
+ tokens[index]
71
+ end
72
+
73
+ def eos?
74
+ index >= tokens.size
75
+ end
76
+
77
+ def rewind
78
+ @index = 0
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,41 @@
1
+ # encoding: UTF-8
2
+
3
+ module Expert
4
+ Token = Struct.new(:type, :value)
5
+
6
+ # jar 'org.eclipse.jgit:org.eclipse.jgit', '3.4.1.201406201815-r'
7
+ class JarfileTokenizer
8
+ TOKEN_TYPE_REGEXES = {
9
+ jar: /jar/,
10
+ quote: /['"]/,
11
+ comma: /,/,
12
+ comment: /#.*\z/m
13
+ }
14
+
15
+ TOKEN_TYPES = TOKEN_TYPE_REGEXES.keys
16
+ DEFAULT_TOKEN_TYPE = :string
17
+
18
+ SPLITTER = Regexp.new(
19
+ "(#{TOKEN_TYPE_REGEXES.values.map(&:source).join('|')})"
20
+ )
21
+
22
+ class << self
23
+ def tokenize(content)
24
+ raw_tokens = content.split(SPLITTER)
25
+ identify(raw_tokens.reject { |t| t.strip.empty? })
26
+ end
27
+
28
+ protected
29
+
30
+ def identify(raw_tokens)
31
+ raw_tokens.map do |token|
32
+ type = TOKEN_TYPES.find do |type|
33
+ token =~ TOKEN_TYPE_REGEXES[type]
34
+ end
35
+
36
+ Token.new(type || DEFAULT_TOKEN_TYPE, token)
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: UTF-8
2
+
3
+ module Expert
4
+ class Maven
5
+
6
+ class << self
7
+ def execute(cmd)
8
+ system("#{mvn_path} #{cmd}")
9
+ end
10
+
11
+ def resolve
12
+ execute('dependency:resolve')
13
+ end
14
+
15
+ def build_classpath(output_file)
16
+ execute("dependency:build-classpath -Dmdep.outputFile=#{output_file}")
17
+ end
18
+
19
+ def mvn_path
20
+ @mvn_path ||= File.expand_path(
21
+ "../../../vendor/apache-maven-#{Expert::MAVEN_VERSION}/bin/mvn",
22
+ __FILE__
23
+ )
24
+ end
25
+ end
26
+
27
+ end
28
+ end