woro 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75b1dc32f7678a48ddcf20ed57e8bca9a45720cd
4
- data.tar.gz: 05f70abe96bb421cd6f7ff3475ee0330be4cc705
3
+ metadata.gz: b95b362f677b55672cbf3f6fd70ee7b1d66551af
4
+ data.tar.gz: 2be0c9ad7365d1c755d1d2b24dbfab13c2b88f50
5
5
  SHA512:
6
- metadata.gz: cbd306d0f3705f4178739df38caccf4f0c534c6043c84662a6444d0ecbda0cb4a6e7d7f8897119bccaccbe3ba9a6cce5425fa77d53ef1178ad698120a875611e
7
- data.tar.gz: dcad5e23785352f4fcf5a57a25e8b9ec2ef240fa940cda8fe26c5d47716b6908ddbb2e88bb18b32242f001cfa27d15cdb6b40f2b8fa7d1372b1cd6d1dd9eda9b
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 will create `lib/woro_tasks/` folder and `lib/tasks/woro.rake`.
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
- app_name = ask 'Application name: '
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 create <task> [options]'
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
@@ -0,0 +1,10 @@
1
+ require "aruba/cucumber"
2
+ require 'cucumber/rspec/doubles'
3
+
4
+ Before do
5
+ allow(Gist).to receive(:multi_gist).and_return({ 'id' => '1234'})
6
+ end
7
+
8
+ After do
9
+ restore_env
10
+ end
@@ -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 #{config_file}. See 'woro help init' for options."
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') { |file| YAML.dump(default_options.merge(user_options), file) }
36
- say "Initialized config file in #{config_file}"
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 #{config_file}, use --force to override. See 'woro help init'."
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
@@ -39,21 +39,16 @@ module Woro
39
39
  File.exist? file_path
40
40
  end
41
41
 
42
- # Creates a new rake task file at the file path (see #file_path).
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
- # Requests the content of the task file within the Gist collection
52
- # from the server.
53
- # @return [String]
54
- def retrieve_raw_file
55
- response = Net::HTTP.get_response(raw_url)
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.
@@ -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
@@ -1,4 +1,4 @@
1
1
  module Woro
2
2
  # Look shiny!
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
@@ -1,6 +1,6 @@
1
1
  namespace :woro do
2
2
  desc 'Write your description here'
3
- task <%= task_name %>: :environment do
3
+ task cleanup: :environment do
4
4
  # your code
5
5
  end
6
6
  end
@@ -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 be_falsy
21
+ expect(config.adapters).to eq({})
22
22
  expect(config.app_name).to be_falsy
23
23
  end
24
24
 
@@ -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','fresh_template.yml')
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(Woro::Task.file_path)).to eq fresh_template_body
14
+ expect(File.read(subject.file_path)).to eq fresh_template_body
15
15
  end
16
16
  end
17
17
 
@@ -1,7 +1,6 @@
1
1
  require 'pry'
2
2
  require 'woro'
3
3
  require 'fakefs/safe'
4
- require 'aws-sdk-v1'
5
4
 
6
5
  Dir[('./spec/support/**/*.rb')].each {|f| require f}
7
6
 
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.1
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-24 00:00:00.000000000 Z
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/fresh_template.yml
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
- - spec/fixtures/fresh_template.yml
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