woro 0.2.1 → 0.2.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/README.md +20 -1
- data/bin/woro +40 -12
- data/features/configuration.feature +35 -0
- data/features/manage_tasks.feature +53 -0
- data/features/step_definitions/woro_steps.rb +20 -0
- data/features/support/env.rb +10 -0
- data/lib/woro/configuration.rb +7 -5
- data/lib/woro/task.rb +6 -11
- data/lib/woro/task_helper.rb +1 -1
- data/lib/woro/templates/{task.rake → task.rake.erb} +0 -0
- data/lib/woro/version.rb +1 -1
- data/spec/fixtures/{fresh_template.yml → cleanup.rake} +1 -1
- data/spec/lib/woro/configuration_spec.rb +1 -1
- data/spec/lib/woro/task_spec.rb +3 -3
- data/spec/spec_helper.rb +0 -1
- metadata +13 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b95b362f677b55672cbf3f6fd70ee7b1d66551af
|
4
|
+
data.tar.gz: 2be0c9ad7365d1c755d1d2b24dbfab13c2b88f50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db55fd8f7bbee3528608990b764da0d6747492087bc94fae475bd5f8cd4d5634913bd73658fc8a44289ad20d920bb6ea561de61e26a5fb33a231095b2cb4118e
|
7
|
+
data.tar.gz: 4aed67765b981c0f2ff6da55a2c06f8f2aadd33f8c935ac236920244ec605280e80ab749a9523b0d3f2668c9647c1f385d0a15403e5d106be09e4cce9e029773
|
data/README.md
CHANGED
@@ -38,7 +38,11 @@ Then run:
|
|
38
38
|
$ woro init
|
39
39
|
```
|
40
40
|
|
41
|
-
This
|
41
|
+
This creates the `woro.yml` in the `config/` folder. This configuration
|
42
|
+
stores the settings of the available remote collection adapters, eg the
|
43
|
+
Gist id.
|
44
|
+
|
45
|
+
It also creates the `lib/woro_tasks/` folder and `lib/tasks/woro.rake`.
|
42
46
|
Here the Woro task files are stored, edited locally and run using rake.
|
43
47
|
|
44
48
|
### for use with Mina
|
@@ -115,6 +119,21 @@ And finally you can download an existing task to your local woro tasks directory
|
|
115
119
|
$ woro pull gist:cleanup_users
|
116
120
|
```
|
117
121
|
|
122
|
+
## Testing
|
123
|
+
|
124
|
+
The project classes are tested through rspec.
|
125
|
+
|
126
|
+
```shell
|
127
|
+
$ rspec
|
128
|
+
```
|
129
|
+
|
130
|
+
The command line interface
|
131
|
+
is tested through cucmber/aruba.
|
132
|
+
|
133
|
+
```shell
|
134
|
+
$ cucumber
|
135
|
+
```
|
136
|
+
|
118
137
|
## Contributing
|
119
138
|
|
120
139
|
1. Fork it
|
data/bin/woro
CHANGED
@@ -24,6 +24,31 @@ executed by rake and cleaned up afterwards.'
|
|
24
24
|
|
25
25
|
default_command :list
|
26
26
|
|
27
|
+
def create_directory_unless_existing(directory)
|
28
|
+
unless File.exists? directory
|
29
|
+
FileUtils.mkdir_p directory
|
30
|
+
say "Created #{directory}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_required_files
|
35
|
+
create_directory_unless_existing Woro::Configuration.woro_task_dir
|
36
|
+
create_directory_unless_existing Woro::Configuration.rake_task_dir
|
37
|
+
|
38
|
+
unless File.exists? File.join(Woro::Configuration.rake_task_dir, 'woro.rake')
|
39
|
+
FileUtils.cp(File.dirname(__FILE__) + '/../lib/woro/templates/woro.rake',
|
40
|
+
Woro::Configuration.rake_task_dir)
|
41
|
+
say "Created woro.rake in #{Woro::Configuration.rake_task_dir}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def woro_environment_setup?
|
46
|
+
File.exists?(Woro::Configuration.woro_task_dir) &&
|
47
|
+
File.exists?(File.join('config', 'woro.yml')) &&
|
48
|
+
File.exists?(Woro::Configuration.rake_task_dir) &&
|
49
|
+
File.exists?(File.join(Woro::Configuration.rake_task_dir, 'woro.rake'))
|
50
|
+
end
|
51
|
+
|
27
52
|
command :init do |c|
|
28
53
|
c.syntax = 'woro init [options]'
|
29
54
|
c.description = 'Initialize Woro in the current Rails directory and setup Gist collection'
|
@@ -39,7 +64,12 @@ command :init do |c|
|
|
39
64
|
|
40
65
|
# create Gist with welcome file
|
41
66
|
# additional tasks will be added to this first gist
|
42
|
-
|
67
|
+
begin
|
68
|
+
require File.join(Dir.pwd, 'config', 'application.rb')
|
69
|
+
app_name = Rails.application.class.parent_name
|
70
|
+
rescue LoadError
|
71
|
+
app_name = ask('Application name: ')
|
72
|
+
end
|
43
73
|
result = Woro::Adapters::Gist.create_initial_remote_task(app_name)
|
44
74
|
|
45
75
|
# configure adapters
|
@@ -51,30 +81,23 @@ command :init do |c|
|
|
51
81
|
unless File.exists? File.dirname(Woro::Configuration.config_file)
|
52
82
|
FileUtils.mkdir_p File.dirname(Woro::Configuration.config_file)
|
53
83
|
end
|
54
|
-
say 'Initialized at `./config/woro.yml`'
|
55
84
|
|
56
85
|
options.default(adapters: { gist: gist_adapter } )
|
57
86
|
config = Woro::Configuration.save(options.__hash__)
|
58
|
-
|
59
|
-
unless File.exists? config.woro_task_dir
|
60
|
-
FileUtils.mkdir_p config.woro_task_dir
|
61
|
-
say "Create #{config.woro_task_dir}"
|
62
|
-
end
|
63
|
-
|
64
|
-
say "Create woro.rake in #{config.rake_task_dir}"
|
65
|
-
FileUtils.mkdir_p config.rake_task_dir if !File.exists? config.rake_task_dir
|
66
|
-
FileUtils.cp(File.dirname(__FILE__) + '/../lib/woro/templates/woro.rake', config.rake_task_dir)
|
87
|
+
create_required_files
|
67
88
|
end
|
68
89
|
end
|
69
90
|
|
70
91
|
command :new do |c|
|
71
|
-
c.syntax = 'woro
|
92
|
+
c.syntax = 'woro new <task> [options]'
|
72
93
|
c.summary = 'Create new tasks'
|
73
94
|
c.description = 'Creates one or more new templated Rake tasks'
|
74
95
|
c.example 'Create task called "cleanup"', 'woro new cleanup'
|
75
96
|
c.example 'Creates tasks called "cleanup", "fix1" and "fix2"', 'woro new cleanup fix1 fix2'
|
76
97
|
c.option '--[no-]force', 'force overwrite of existing task file'
|
77
98
|
c.action do |args, options|
|
99
|
+
abort 'Woro environment is not set up. Call `woro init` to do so.' unless woro_environment_setup?
|
100
|
+
|
78
101
|
config = Woro::Configuration.load
|
79
102
|
force_overwrite = options.force
|
80
103
|
args.each do |task_name|
|
@@ -93,6 +116,8 @@ command :push do |c|
|
|
93
116
|
c.description = 'Pushes one or more local tasks to the remote collection. Existing tasks by this name in the remote connection will be updated.'
|
94
117
|
c.example 'Pushes the task "cleanup" to the remote collection', 'woro push cleanup'
|
95
118
|
c.action do |args, options|
|
119
|
+
abort 'Woro environment is not set up. Call `woro init` to do so.' unless woro_environment_setup?
|
120
|
+
|
96
121
|
config = Woro::Configuration.load
|
97
122
|
args.each do |arg|
|
98
123
|
unless arg.include?(':')
|
@@ -120,6 +145,8 @@ command :pull do |c|
|
|
120
145
|
c.example 'Pulls the task "cleanup" from the remote collection', 'woro pull gist:cleanup'
|
121
146
|
c.option '--[no-]force', 'force overwrite of existing task file'
|
122
147
|
c.action do |args, options|
|
148
|
+
abort 'Woro environment is not set up. Call `woro init` to do so.' unless woro_environment_setup?
|
149
|
+
|
123
150
|
config = Woro::Configuration.load
|
124
151
|
args.each do |arg|
|
125
152
|
unless arg.include?(':')
|
@@ -145,6 +172,7 @@ command :list do |c|
|
|
145
172
|
c.example 'List all tasks', 'woro list --all'
|
146
173
|
c.option '-a', '--all', 'List all tasks'
|
147
174
|
c.action do |args, options|
|
175
|
+
abort 'Woro environment is not set up. Call `woro init` to do so.' unless woro_environment_setup?
|
148
176
|
abort "invalid command. See 'woro help' for more information" unless args.empty?
|
149
177
|
config = Woro::Configuration.load
|
150
178
|
config.adapters.each do |adapter_config|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Feature: Configure woro
|
2
|
+
In order to use woro
|
3
|
+
As a user
|
4
|
+
I want a sane default configuration for my system
|
5
|
+
and a data file to store my tasks
|
6
|
+
|
7
|
+
# TODO Scenario: Initialize configuration with Rails environment
|
8
|
+
|
9
|
+
Scenario: Initialize configuration without Rails environment
|
10
|
+
When I run `woro init` interactively
|
11
|
+
And I type "n\n"
|
12
|
+
And I type "Rails-project\n"
|
13
|
+
Then the output should contain "Initialized config file in `config/woro.yml`"
|
14
|
+
And the following files should exist:
|
15
|
+
| config/woro.yml |
|
16
|
+
|
17
|
+
Scenario: Initialize configuration (no clobber)
|
18
|
+
Given a file named "config/woro.yml" with:
|
19
|
+
"""
|
20
|
+
hello world
|
21
|
+
"""
|
22
|
+
When I run `woro init` interactively
|
23
|
+
And I type "n\n"
|
24
|
+
And I type "Rails-project\n"
|
25
|
+
Then the output should contain "Not overwriting existing config file"
|
26
|
+
|
27
|
+
Scenario: Force initialize configuration (clobber)
|
28
|
+
Given a file named "config/woro.yml" with:
|
29
|
+
"""
|
30
|
+
hello world
|
31
|
+
"""
|
32
|
+
When I run `woro init --force` interactively
|
33
|
+
And I type "n\n"
|
34
|
+
And I type "Rails-project\n"
|
35
|
+
Then the file "config/woro.yml" should not contain "hello world"
|
@@ -0,0 +1,53 @@
|
|
1
|
+
Feature: Manage Woro task
|
2
|
+
In order to manage tasks
|
3
|
+
As a user
|
4
|
+
I want to create, push and list tasks
|
5
|
+
|
6
|
+
Scenario: Execute woro without parameters without environment
|
7
|
+
When I run `woro`
|
8
|
+
Then the output should contain "Woro environment is not set up. Call `woro init` to do so."
|
9
|
+
|
10
|
+
Scenario: Execute woro without parameters
|
11
|
+
Given the Woro environment is set up
|
12
|
+
And I run `woro`
|
13
|
+
Then the output should contain exactly:
|
14
|
+
"""
|
15
|
+
local ---
|
16
|
+
|
17
|
+
"""
|
18
|
+
|
19
|
+
|
20
|
+
Scenario: List tasks without environment setup
|
21
|
+
Given I run `woro list`
|
22
|
+
Then the output should contain "Woro environment is not set up. Call `woro init` to do so."
|
23
|
+
|
24
|
+
Scenario: List tasks
|
25
|
+
Given the Woro environment is set up
|
26
|
+
And a file named "config/woro.yml" with:
|
27
|
+
"""
|
28
|
+
adapters:
|
29
|
+
|
30
|
+
"""
|
31
|
+
And I run `woro list`
|
32
|
+
Then the output should contain exactly:
|
33
|
+
"""
|
34
|
+
local ---
|
35
|
+
|
36
|
+
"""
|
37
|
+
|
38
|
+
Scenario: Create local task without environment
|
39
|
+
When I run `woro new cleanup`
|
40
|
+
Then the output should contain "Woro environment is not set up. Call `woro init` to do so."
|
41
|
+
|
42
|
+
Scenario: Create local task
|
43
|
+
Given the Woro environment is set up
|
44
|
+
When I run `woro new cleanup`
|
45
|
+
And the output should contain "Created lib/woro_tasks/cleanup.rake"
|
46
|
+
|
47
|
+
Scenario: Push local task to remote without environment
|
48
|
+
When I run `woro push stub:cleanup`
|
49
|
+
Then the output should contain "Woro environment is not set up. Call `woro init` to do so."
|
50
|
+
|
51
|
+
Scenario: Pull local task to remote without environment
|
52
|
+
When I run `woro pull stub:cleanup`
|
53
|
+
Then the output should contain "Woro environment is not set up. Call `woro init` to do so."
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'woro'
|
2
|
+
|
3
|
+
Given /^the following tasks:$/ do |table|
|
4
|
+
data = table.raw
|
5
|
+
table.raw.each do |task|
|
6
|
+
steps %Q{
|
7
|
+
When I run `pomo add '#{task.first}'`
|
8
|
+
}
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Given /^the Woro environment is set up$/ do
|
13
|
+
create_dir Woro::Configuration.woro_task_dir
|
14
|
+
create_dir Woro::Configuration.rake_task_dir
|
15
|
+
|
16
|
+
write_file(File.join(Woro::Configuration.rake_task_dir, 'woro.rake'),
|
17
|
+
File.read(File.dirname(__FILE__) + '/../../lib/woro/templates/woro.rake') )
|
18
|
+
write_file(File.join('config', 'woro.yml'),
|
19
|
+
{ adapters: {} }.to_yaml)
|
20
|
+
end
|
data/lib/woro/configuration.rb
CHANGED
@@ -9,7 +9,7 @@ module Woro
|
|
9
9
|
# Initialize configuration.
|
10
10
|
def initialize(options = {})
|
11
11
|
@woro_task_dir = Configuration.woro_task_dir
|
12
|
-
@adapters = options[:adapters]
|
12
|
+
@adapters = options[:adapters] || {}
|
13
13
|
@app_name = options[:app_name]
|
14
14
|
end
|
15
15
|
|
@@ -19,7 +19,7 @@ module Woro
|
|
19
19
|
|
20
20
|
if !(File.exists? config_file)
|
21
21
|
File.open(config_file, 'w') { |file| YAML.dump(default_options, file) }
|
22
|
-
say "Initialized default config file in
|
22
|
+
say "Initialized default config file in `#{config_file}`. See 'woro help init' for options."
|
23
23
|
end
|
24
24
|
|
25
25
|
config_file_options = YAML.load_file(config_file)
|
@@ -32,10 +32,12 @@ module Woro
|
|
32
32
|
force_save = options.delete :force
|
33
33
|
|
34
34
|
if !(File.exists? config_file) || force_save
|
35
|
-
File.open(config_file, 'w')
|
36
|
-
|
35
|
+
File.open(config_file, 'w') do |file|
|
36
|
+
YAML.dump(default_options.merge(user_options), file)
|
37
|
+
end
|
38
|
+
say "Initialized config file in `#{config_file}`"
|
37
39
|
else
|
38
|
-
say_error "Not overwriting existing config file
|
40
|
+
say_error "Not overwriting existing config file `#{config_file}`, use --force to override. See 'woro help init'."
|
39
41
|
end
|
40
42
|
self
|
41
43
|
end
|
data/lib/woro/task.rb
CHANGED
@@ -39,21 +39,16 @@ module Woro
|
|
39
39
|
File.exist? file_path
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
def create_from_task_template
|
42
|
+
def build_task_template
|
44
43
|
b = binding
|
45
44
|
template = ERB.new(Woro::TaskHelper.read_template_file).result(b)
|
46
|
-
File.open(file_path, 'w') do |f|
|
47
|
-
f.puts template
|
48
|
-
end
|
49
45
|
end
|
50
46
|
|
51
|
-
#
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
response.body
|
47
|
+
# Creates a new rake task file at the file path (see #file_path).
|
48
|
+
def create_from_task_template
|
49
|
+
File.open(file_path, 'w') do |f|
|
50
|
+
f.puts build_task_template
|
51
|
+
end
|
57
52
|
end
|
58
53
|
|
59
54
|
# Read the content of the local rake task file on #file_path.
|
data/lib/woro/task_helper.rb
CHANGED
@@ -32,7 +32,7 @@ module Woro
|
|
32
32
|
# Read the rake task template
|
33
33
|
# @return [String]
|
34
34
|
def read_template_file
|
35
|
-
File.read(File.join(File.dirname(__FILE__), 'templates','task.rake') )
|
35
|
+
File.read(File.join(File.dirname(__FILE__), 'templates','task.rake.erb') )
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
File without changes
|
data/lib/woro/version.rb
CHANGED
@@ -18,7 +18,7 @@ describe Woro::Configuration do
|
|
18
18
|
context 'not given a configuration file' do
|
19
19
|
it 'returns Configuration object with default options' do
|
20
20
|
config = Woro::Configuration.load
|
21
|
-
expect(config.adapters).to
|
21
|
+
expect(config.adapters).to eq({})
|
22
22
|
expect(config.app_name).to be_falsy
|
23
23
|
end
|
24
24
|
|
data/spec/lib/woro/task_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Woro::Task do
|
4
|
-
|
5
4
|
subject { Woro::Task.new('cleanup_task') }
|
6
5
|
|
7
6
|
describe '#create_from_task_template' do
|
8
7
|
it 'creates new file' do
|
9
8
|
FakeFS.deactivate!
|
10
|
-
example_path = File.join('spec', 'fixtures','
|
9
|
+
example_path = File.join('spec', 'fixtures', 'cleanup.rake')
|
11
10
|
fresh_template_body = File.read example_path
|
11
|
+
allow(Woro::TaskHelper).to receive(:read_template_file).and_return fresh_template_body
|
12
12
|
FakeFS.activate!
|
13
13
|
subject.create_from_task_template
|
14
|
-
expect(File.read(
|
14
|
+
expect(File.read(subject.file_path)).to eq fresh_template_body
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: woro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Senff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gist
|
@@ -164,6 +164,10 @@ files:
|
|
164
164
|
- README.md
|
165
165
|
- Rakefile
|
166
166
|
- bin/woro
|
167
|
+
- features/configuration.feature
|
168
|
+
- features/manage_tasks.feature
|
169
|
+
- features/step_definitions/woro_steps.rb
|
170
|
+
- features/support/env.rb
|
167
171
|
- lib/capistrano/woro.rb
|
168
172
|
- lib/mina/woro.rb
|
169
173
|
- lib/woro.rb
|
@@ -173,10 +177,10 @@ files:
|
|
173
177
|
- lib/woro/task_helper.rb
|
174
178
|
- lib/woro/tasks/capistrano.rake
|
175
179
|
- lib/woro/tasks/mina.rake
|
176
|
-
- lib/woro/templates/task.rake
|
180
|
+
- lib/woro/templates/task.rake.erb
|
177
181
|
- lib/woro/templates/woro.rake
|
178
182
|
- lib/woro/version.rb
|
179
|
-
- spec/fixtures/
|
183
|
+
- spec/fixtures/cleanup.rake
|
180
184
|
- spec/fixtures/gist.json
|
181
185
|
- spec/lib/woro/adapters/gist_spec.rb
|
182
186
|
- spec/lib/woro/configuration_spec.rb
|
@@ -209,7 +213,11 @@ specification_version: 4
|
|
209
213
|
summary: Write once, run once. One-time migration task management on remote servers
|
210
214
|
through mina.
|
211
215
|
test_files:
|
212
|
-
-
|
216
|
+
- features/configuration.feature
|
217
|
+
- features/manage_tasks.feature
|
218
|
+
- features/step_definitions/woro_steps.rb
|
219
|
+
- features/support/env.rb
|
220
|
+
- spec/fixtures/cleanup.rake
|
213
221
|
- spec/fixtures/gist.json
|
214
222
|
- spec/lib/woro/adapters/gist_spec.rb
|
215
223
|
- spec/lib/woro/configuration_spec.rb
|