-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7183164
commit da811e7
Showing
15 changed files
with
164 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module Semverse | ||
# Add utility functions | ||
class Version | ||
def to_simple | ||
"#{major}.#{minor}.#{patch}" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
module ElmInstall | ||
# Installer class | ||
class Installer < Base | ||
def initialize(options = {}) | ||
@identifier = Identifier.new Dir.new(Dir.pwd), options | ||
@resolver = Resolver.new @identifier | ||
end | ||
|
||
puts "Resolving packages..." | ||
|
||
def install | ||
puts 'Resolving packages...' | ||
@graph = @resolver.resolve | ||
|
||
initial = @identifier.initial_dependencies.map do |dependency| | ||
puts 'Solving dependencies...' | ||
(Populator.new results).populate | ||
|
||
puts 'Packages configured successfully!' | ||
end | ||
|
||
def results | ||
Solve | ||
.it!(@graph, initial_solve_constraints) | ||
.map do |name, version| | ||
dep = @resolver.dependencies[name] | ||
dep.version = Semverse::Version.new(version) | ||
dep | ||
end | ||
end | ||
|
||
def initial_solve_constraints | ||
@identifier.initial_dependencies.flat_map do |dependency| | ||
dependency.constraints.map do |constraint| | ||
[dependency.name, constraint] | ||
end | ||
end | ||
.flatten(1) | ||
|
||
puts "Solving dependencies..." | ||
|
||
results = | ||
Solve | ||
.it!(@graph, initial) | ||
.map { |name, version| | ||
dep = @resolver.dependencies[name] | ||
dep.version = Semverse::Version.new(version) | ||
dep | ||
} | ||
|
||
(Populator.new results).populate | ||
|
||
puts "Packages configured successfully!" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module ElmInstall | ||
# Handles git repositories. | ||
class Repository < Base | ||
extend Forwardable | ||
|
||
attr_reader :url, :path | ||
|
||
def_delegators :repo, :fetch | ||
|
||
def initialize(url, path) | ||
@path = path | ||
@url = url | ||
end | ||
|
||
# Downloads the version into a temporary directory | ||
Contract String => Dir | ||
def checkout(ref) | ||
repo.reset_hard | ||
repo.checkout ref | ||
directory | ||
end | ||
|
||
# Returns the directory of the repository | ||
Contract None => Dir | ||
def directory | ||
# This removes the .git from filename | ||
Dir.new(File.dirname(repo.repo.path)) | ||
end | ||
|
||
def versions | ||
repo | ||
.tags | ||
.map(&:name) | ||
.map { |tag| Semverse::Version.try_new tag } | ||
.compact | ||
end | ||
|
||
def repo | ||
return clone unless Dir.exist?(path) | ||
repo = Git.open path | ||
repo.reset_hard | ||
repo | ||
end | ||
|
||
# Clonse the repository | ||
Contract None => Git::Base | ||
def clone | ||
Logger.arrow "Package: #{url.bold} not found in cache, cloning..." | ||
FileUtils.mkdir_p path | ||
Git.clone(url, path) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module ElmInstall | ||
# Abstract class for a source | ||
class Source < Base | ||
attr_accessor :identifier, :options | ||
end | ||
|
Oops, something went wrong.