duty 0.3 → 0.4.2
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/.duty.yml.sample +3 -3
- data/README.md +34 -13
- data/lib/duty/cli.rb +7 -2
- data/lib/duty/plugins.rb +2 -53
- data/lib/duty/registry.rb +21 -7
- data/lib/duty/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a2fc971faafc1fa92c346f4deff2239c4ee96e9
|
4
|
+
data.tar.gz: be458adb95ddb3267909e23acba8af683c095ed7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84c72963c7be12155cf302e81f69f3421d0eb2adbcfbac510e70ba6744a05ee06a2f1980a14f5bcbc9fbd162196be0393d8ca2b45f796406e276568b220128ac
|
7
|
+
data.tar.gz: 9383bef581a7f9630947b8788b991ba18d1a885ed3e8b1521094eb06a68fc37f96b92956c7dea046f534676a77769509a1278b3fdc7a2381b314cabb45601407
|
data/.duty.yml.sample
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
tasks:
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
- /path/to/duty-git/lib/duty/git.rb
|
3
|
+
- /path/to/projectA/tasks.rb
|
4
|
+
- /path/to/projectB/i_dont_care_about_naming.rb
|
data/README.md
CHANGED
@@ -34,16 +34,37 @@ $ source duty.completion
|
|
34
34
|
$ duty <task> [<args>]
|
35
35
|
```
|
36
36
|
|
37
|
-
##
|
37
|
+
## Plugins
|
38
38
|
|
39
|
-
|
39
|
+
Duty ships with a plugin mechanism.
|
40
|
+
You can define tasks by using existing duty plugins or writing your own.
|
41
|
+
|
42
|
+
### Install a plugin
|
43
|
+
|
44
|
+
Install a plugin you want to use globally e.g.
|
45
|
+
|
46
|
+
```
|
47
|
+
gem install duty-git
|
48
|
+
```
|
40
49
|
|
41
|
-
|
50
|
+
or add it to your `Gemfile` e.g.
|
42
51
|
|
43
|
-
|
44
|
-
|
52
|
+
```
|
53
|
+
gem 'duty-git'
|
54
|
+
```
|
45
55
|
|
46
|
-
|
56
|
+
Add it to your `.duty` file. e.g.
|
57
|
+
|
58
|
+
```
|
59
|
+
tasks:
|
60
|
+
- duty/git
|
61
|
+
```
|
62
|
+
|
63
|
+
### List of existing duty plugins
|
64
|
+
|
65
|
+
* [duty-git](https://github.com/JanOwiesniak/duty-git)
|
66
|
+
|
67
|
+
## Extend duty with your own plugin
|
47
68
|
|
48
69
|
Example: `/path/to/your/duty-plugins/my_duty_plugin.rb`
|
49
70
|
|
@@ -51,6 +72,10 @@ Example: `/path/to/your/duty-plugins/my_duty_plugin.rb`
|
|
51
72
|
require 'duty'
|
52
73
|
|
53
74
|
module MyDutyPlugin
|
75
|
+
def self.namespace
|
76
|
+
'i am special'
|
77
|
+
end
|
78
|
+
|
54
79
|
def self.tasks
|
55
80
|
[
|
56
81
|
MyDutyTasks::MyFirstTask,
|
@@ -102,9 +127,7 @@ module MyDutyTasks
|
|
102
127
|
end
|
103
128
|
end
|
104
129
|
|
105
|
-
|
106
|
-
|
107
|
-
MyDutyPlugin
|
130
|
+
Duty::Registry.register(MyDutyPlugin)
|
108
131
|
```
|
109
132
|
|
110
133
|
## Task naming conventions
|
@@ -118,13 +141,11 @@ $ duty start-feature
|
|
118
141
|
|
119
142
|
### How to use my own tasks?
|
120
143
|
|
121
|
-
|
144
|
+
Deploy it as a gem and install it as described in the `Install a plugin` section above or link it against the absolute path in your `.duty` file.
|
122
145
|
|
123
146
|
```
|
124
147
|
tasks:
|
125
|
-
|
126
|
-
projectA: /path/to/projectA/my_duty_plugin.rb
|
127
|
-
projectB: /path/to/projectB/i_dont_care_about_naming.rb
|
148
|
+
- /path/to/your/duty-plugins/my_duty_plugin
|
128
149
|
```
|
129
150
|
|
130
151
|
Your new tasks will be immediately available from the CLI.
|
data/lib/duty/cli.rb
CHANGED
@@ -12,7 +12,8 @@ module Duty
|
|
12
12
|
def initialize(args)
|
13
13
|
@input = Duty::IO::CLI::Input.new(args)
|
14
14
|
@output = Duty::IO::CLI::Output.new($stdout, $stderr)
|
15
|
-
@registry = Duty::Registry.
|
15
|
+
@registry = Duty::Registry.instance
|
16
|
+
load_plugins
|
16
17
|
end
|
17
18
|
|
18
19
|
def exec
|
@@ -67,7 +68,11 @@ module Duty
|
|
67
68
|
input.verbose?
|
68
69
|
end
|
69
70
|
|
70
|
-
def
|
71
|
+
def load_plugins
|
72
|
+
Duty::Plugins.load(config)
|
73
|
+
end
|
74
|
+
|
75
|
+
def config
|
71
76
|
Duty::ConfigLoader.new.load(Dir.pwd)
|
72
77
|
end
|
73
78
|
end
|
data/lib/duty/plugins.rb
CHANGED
@@ -4,61 +4,10 @@ require 'yaml'
|
|
4
4
|
module Duty
|
5
5
|
module Plugins
|
6
6
|
def self.load(config)
|
7
|
-
|
8
|
-
|
9
|
-
list << Plugin.new(namespace, plugin_entry_point)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class List
|
15
|
-
require 'forwardable'
|
16
|
-
include Enumerable
|
17
|
-
extend Forwardable
|
18
|
-
def_delegators :@plugins, :each, :<<
|
19
|
-
def initialize
|
20
|
-
@plugins = []
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class Plugin
|
25
|
-
def initialize(namespace, entry)
|
26
|
-
@namespace = namespace
|
27
|
-
@entry = entry
|
28
|
-
@tasks = []
|
29
|
-
end
|
30
|
-
|
31
|
-
def namespace
|
32
|
-
@namespace
|
33
|
-
end
|
34
|
-
|
35
|
-
def tasks
|
36
|
-
@task_classes.select do |task_class|
|
37
|
-
valid?(task_class)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def load_tasks
|
42
|
-
require_tasks
|
43
|
-
expose_tasks
|
44
|
-
end
|
45
|
-
|
46
|
-
private
|
47
|
-
|
48
|
-
def require_tasks
|
49
|
-
path = @entry.gsub(/\.rb/,'')
|
7
|
+
config["tasks"].each do |plugin_entry_point|
|
8
|
+
path = plugin_entry_point.gsub(/\.rb/,'')
|
50
9
|
require path
|
51
10
|
end
|
52
|
-
|
53
|
-
def expose_tasks
|
54
|
-
@task_classes = eval(File.read(@entry)).tasks
|
55
|
-
end
|
56
|
-
|
57
|
-
private
|
58
|
-
|
59
|
-
def valid?(task_class)
|
60
|
-
task_class.ancestors.include? ::Duty::Tasks::Base
|
61
|
-
end
|
62
11
|
end
|
63
12
|
end
|
64
13
|
end
|
data/lib/duty/registry.rb
CHANGED
@@ -1,16 +1,30 @@
|
|
1
1
|
module Duty
|
2
2
|
class Registry
|
3
|
-
def self.
|
4
|
-
|
3
|
+
def self.instance
|
4
|
+
return @instance if @instance
|
5
|
+
@instance = new
|
5
6
|
end
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
@plugins = plugins
|
8
|
+
def self.register(plugin_class)
|
9
|
+
instance.send(:plugins) << Plugin.new(plugin_class)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
plugins
|
12
|
+
def plugins
|
13
|
+
@plugins
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
class Plugin
|
19
|
+
attr_reader :namespace, :tasks
|
20
|
+
def initialize(plugin_class)
|
21
|
+
@namespace = plugin_class.namespace
|
22
|
+
@tasks = plugin_class.tasks
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@plugins = []
|
14
28
|
end
|
15
29
|
end
|
16
30
|
end
|
data/lib/duty/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Owiesniak
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|