shanty 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/shanty.rb +11 -21
- data/lib/shanty/cli.rb +35 -19
- data/lib/shanty/discoverer.rb +9 -3
- data/lib/shanty/discoverers/rubygem.rb +17 -0
- data/lib/shanty/discoverers/shantyfile.rb +9 -2
- data/lib/shanty/env.rb +51 -0
- data/lib/shanty/graph.rb +43 -32
- data/lib/shanty/mixins/acts_as_link_graph_node.rb +0 -10
- data/lib/shanty/mixins/callbacks.rb +20 -8
- data/lib/shanty/mutator.rb +10 -3
- data/lib/shanty/mutators/bundler.rb +13 -0
- data/lib/shanty/mutators/changed.rb +78 -0
- data/lib/shanty/plugin.rb +6 -13
- data/lib/shanty/project.rb +12 -4
- data/lib/shanty/project_template.rb +13 -9
- data/lib/shanty/projects/{ruby.rb → rubygem.rb} +1 -1
- data/lib/shanty/task_env.rb +24 -0
- data/lib/shanty/task_set.rb +45 -0
- data/lib/shanty/{tasks → task_sets}/basic.rb +16 -11
- metadata +24 -126
- data/lib/shanty/discoverers/gradle.rb +0 -18
- data/lib/shanty/global.rb +0 -49
- data/lib/shanty/mutators/git.rb +0 -24
- data/lib/shanty/task.rb +0 -45
- data/lib/shanty/vcs_range.rb +0 -31
- data/lib/shanty/vcs_ranges/local_git.rb +0 -20
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'shanty/discoverer'
|
2
|
-
require 'shanty/projects/static'
|
3
|
-
|
4
|
-
module Shanty
|
5
|
-
# Gradle discoverer
|
6
|
-
class ShantyfileDiscoverer < Discoverer
|
7
|
-
def discover
|
8
|
-
Dir['**/build.gradle'].map do |path|
|
9
|
-
create_project(
|
10
|
-
File.dirname(path),
|
11
|
-
type: GradleProject,
|
12
|
-
options: { foo: 'bar' },
|
13
|
-
plugins: [GradlePlugin], parents: ['']
|
14
|
-
)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/shanty/global.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'yaml'
|
2
|
-
require 'deep_merge'
|
3
|
-
|
4
|
-
module Shanty
|
5
|
-
# Global configuration variables for shanty
|
6
|
-
module Global
|
7
|
-
module_function
|
8
|
-
|
9
|
-
def config_file
|
10
|
-
'.shanty.yml'
|
11
|
-
end
|
12
|
-
|
13
|
-
def environment
|
14
|
-
@environment = ENV['SHANTY_ENV'] || 'local'
|
15
|
-
end
|
16
|
-
|
17
|
-
def default_config
|
18
|
-
@default_config ||= {}
|
19
|
-
end
|
20
|
-
|
21
|
-
def add_default_config(new_config)
|
22
|
-
@default_config.merge!(new_config)
|
23
|
-
end
|
24
|
-
|
25
|
-
def root
|
26
|
-
@root ||= find_root
|
27
|
-
end
|
28
|
-
|
29
|
-
def config
|
30
|
-
file_config = YAML.load_file("#{root}/#{config_file}") || {}
|
31
|
-
@config ||= default_config.deep_merge!(file_config[environment]) || default_config
|
32
|
-
end
|
33
|
-
|
34
|
-
def find_root
|
35
|
-
if root_dir.nil?
|
36
|
-
fail "Could not find a #{Global.config_file} file in this or any parent directories. \
|
37
|
-
Please run `shanty init` in the directory you want to be the root of your project structure."
|
38
|
-
end
|
39
|
-
|
40
|
-
root_dir
|
41
|
-
end
|
42
|
-
|
43
|
-
def root_dir
|
44
|
-
Pathname.new(Dir.pwd).ascend do |d|
|
45
|
-
return d if d.join(Global.config_file).exist?
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/lib/shanty/mutators/git.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'shanty/mutator'
|
2
|
-
require 'shanty/vcs_ranges/local_git'
|
3
|
-
|
4
|
-
module Shanty
|
5
|
-
# Git VCS mutator
|
6
|
-
class Git < Mutator
|
7
|
-
def initialize
|
8
|
-
@vcs_range = VCSRange.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def mutate(graph)
|
12
|
-
git_root = `git rev-parse --show-toplevel`.strip
|
13
|
-
diff_files = `git diff --name-only #{@vcs_range.from_commit} #{@vcs_range.to_commit}`.split("\n")
|
14
|
-
diff_files.each do |path|
|
15
|
-
next if path.nil?
|
16
|
-
path = File.join(git_root, path)
|
17
|
-
project = graph.owner_of_file(path)
|
18
|
-
project.changed = true unless project.nil?
|
19
|
-
end
|
20
|
-
|
21
|
-
graph
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/lib/shanty/task.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
module Shanty
|
2
|
-
# Public: Discover shanty tasks
|
3
|
-
class Task
|
4
|
-
class << self
|
5
|
-
attr_reader :tasks
|
6
|
-
attr_reader :task_definitions, :task_definiton
|
7
|
-
end
|
8
|
-
|
9
|
-
# This method is auto-triggred by Ruby whenever a class inherits from
|
10
|
-
# Shanty::Task. This means we can build up a list of all the tasks
|
11
|
-
# without requiring them to register with us - neat!
|
12
|
-
def self.inherited(task)
|
13
|
-
@tasks ||= []
|
14
|
-
@tasks << task
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.desc(desc)
|
18
|
-
task_definition[:desc] = desc
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.param(name, options = {})
|
22
|
-
task_definition[:params][name] = options
|
23
|
-
end
|
24
|
-
|
25
|
-
def self.option(name, options = {})
|
26
|
-
task_definition[:options][name] = options
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.method_added(name)
|
30
|
-
@task_definitions ||= {}
|
31
|
-
@task_definitions[name] = task_definition.merge(klass: self)
|
32
|
-
|
33
|
-
# Now reset the task definition.
|
34
|
-
@task_definition = {}
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.task_definition
|
38
|
-
@task_definition ||= {}
|
39
|
-
@task_definition[:params] ||= {}
|
40
|
-
@task_definition[:options] ||= {}
|
41
|
-
|
42
|
-
@task_definition
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/lib/shanty/vcs_range.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'shanty/util'
|
2
|
-
|
3
|
-
module Shanty
|
4
|
-
# Public: Enables discovery of rangeerent types of CI provider
|
5
|
-
# utilises inherited class method to find all implementing
|
6
|
-
# classes
|
7
|
-
class VCSRange
|
8
|
-
class << self
|
9
|
-
attr_reader :vcs_range
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.inherited(vcs_range)
|
13
|
-
Util.logger.debug("Detected VCS range #{vcs_range}")
|
14
|
-
@vcs_range = vcs_range
|
15
|
-
end
|
16
|
-
|
17
|
-
def from_commit
|
18
|
-
vcs_range.from_commit
|
19
|
-
end
|
20
|
-
|
21
|
-
def to_commit
|
22
|
-
vcs_range.to_commit
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def vcs_range
|
28
|
-
@vcs_range ||= self.class.vcs_range.new
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'shanty/vcs_range'
|
2
|
-
|
3
|
-
module Shanty
|
4
|
-
# Use range of local vs remote changes
|
5
|
-
class LocalGit < VCSRange
|
6
|
-
def from_commit
|
7
|
-
"origin/#{branch}"
|
8
|
-
end
|
9
|
-
|
10
|
-
def to_commit
|
11
|
-
'HEAD'
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def branch
|
17
|
-
`git rev-parse --abbrev-ref HEAD`.strip
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|