woro 0.0.2 → 0.1.0

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: 39fa870f26707dbc1bdccabb493c211b526027b1
4
- data.tar.gz: 97122ef9728188ced1c2ae8b5f7af175c6527b92
3
+ metadata.gz: 5a7d57892a65138472c52bcf5c91ead031cd022f
4
+ data.tar.gz: 5fc6dbd1d5e0ab491f9e06a1d17b87ccc69e86bd
5
5
  SHA512:
6
- metadata.gz: e35e602e70f2c9b06d003633a4e820e164b36e79c17af6394285e1b15702e1ffd976cbb40252ca5bed8a59373f5c3120bf71682d7af4b334ea8fafa2443707ee
7
- data.tar.gz: 0d2f2e650b2891e807e5b8766c240b607fa1dfc5d4c63a8fc2a0fc555dcf227b178a34b89490ab368864fc253784587e81fcac31a86a40f262102c60b8658a1b
6
+ metadata.gz: f0dda43342aab660543a9b115438ab7322ef00242a767518818ec7f81701f25efac7935b3973f2cbe2431819530d929906a489e1e0ead0fda3fc98ecf75fe7b8
7
+ data.tar.gz: 0a7e6eff1e8467046c18dfdf13eb3111865737438bbdac1f49f76d503ee95585a0c0441e8d630bb8e621099493b5c93ce84f85406a7aeffd2575b93295c8fece
data/README.md CHANGED
@@ -3,14 +3,14 @@
3
3
  Write once, run once.
4
4
 
5
5
  Manage one-time remote tasks in your Rails project.
6
- Plugins with Mina that adds support for rake tasks hosted as gists.
6
+ Plugins with Mina to add support for rake tasks hosted in remote collection, such as Gist.
7
7
 
8
- Say you have a data migration to perform on a remote server. The procedure is too complex to just do it in the remote console. Using database migration is evil. A rake task would be nice, but checking this in with the regular repository adds clutter, as you know you will only run this once.
9
- Woro offers a quick way of pushing rake tasks on the remote server, execute them and delete them instantly. Using Github's gist, you keep version control of the tasks and can share them with colleagues.
8
+ Say you have a data migration to perform on a remote server. The procedure is too complex to just do it in the remote console and using database migrations would be evil. A rake task would be nice, but checking this in with the source code repository adds clutter, as you know you will only run this once.
9
+ Woro offers a quick way of pushing rake tasks onto the remote server, execute them and delete them instantly. Using Github's gist, you keep version control of the tasks and can share them with colleagues.
10
10
 
11
- Woro helps you create rake task, that you can develop and run locally.
12
- Once you are ready, woro let's you push them online as a gist.
13
- Using a mina deployment setup, you these tasks are downloaded on the remote system, executing using rake and cleaned up afterwards.
11
+ Woro helps you create rake tasks, that you can develop and run locally.
12
+ Once you are ready, woro let's you push them online to a remote collection like Gist.
13
+ Using a mina deployment setup, these tasks are downloaded on the remote system, executed by rake and cleaned up afterwards.
14
14
 
15
15
  ## Installation
16
16
 
@@ -55,7 +55,7 @@ end
55
55
  Then run:
56
56
 
57
57
  ```shell
58
- $ mina woro:init
58
+ $ woro init
59
59
  ```
60
60
 
61
61
  This will create `lib/woro_tasks/` folder and `lib/tasks/woro.rake`.
@@ -64,7 +64,7 @@ Here the Woro task files are stored and edited locally.
64
64
  ## Usage
65
65
 
66
66
  ```shell
67
- $ mina woro:new task=cleanup_users
67
+ $ woro new cleanup_users
68
68
  ```
69
69
 
70
70
  Can be used to create the template for a new task in `lib/tasks/`.
@@ -79,7 +79,7 @@ Once you are done writing the task and you want to execute it on the remote syst
79
79
  First you have to push them online.
80
80
 
81
81
  ```shell
82
- $ mina woro:push task=cleanup_users
82
+ $ woro push cleanup_users
83
83
  ```
84
84
 
85
85
  _Attention, depending on whether you set up a Gist/Github login on
@@ -87,29 +87,22 @@ initialization. These tasks are online anonymous, but public, or
87
87
  private under the specified Github account._
88
88
 
89
89
 
90
- Now, to run a task remotely, specify the task:
90
+ Now, to run a task remotely using mina, specify the task:
91
91
 
92
92
  ```shell
93
93
  $ mina woro:run task=cleanup_users
94
94
  ```
95
95
 
96
-
97
- Or do pushing and running in one step:
98
-
99
- ```shell
100
- $ mina woro:execute task=cleanup_users
101
- ```
102
-
103
96
  To show a list of all uploaded tasks do:
104
97
 
105
98
  ```shell
106
- $ mina woro:list
99
+ $ woro list
107
100
  ```
108
101
 
109
102
  And finally you can download an existing task:
110
103
 
111
104
  ```shell
112
- $ mina woro:pull task=cleanup_users
105
+ $ woro pull cleanup_users
113
106
  ```
114
107
 
115
108
  ## Contributing
data/bin/woro ADDED
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require 'commander/import'
5
+ require 'woro'
6
+
7
+ program :name, 'woro'
8
+ program :version, Woro::VERSION
9
+ program :description, 'Write once, run once - Management of one-time remote tasks
10
+ Plugins with Mina to add support for rake tasks hosted in remote collection, such as Gist.
11
+
12
+ Say you have a data migration to perform on a remote server. The procedure is too complex
13
+ to just do it in the remote console and using database migrations would be evil.
14
+ A rake task would be nice, but checking this in with the source code repository
15
+ adds clutter, as you know you will only run this once.
16
+ Woro offers a quick way of pushing rake tasks onto the remote server, execute them
17
+ and delete them instantly. Using Github\'s gist, you keep version control of the tasks
18
+ and can share them with colleagues.
19
+
20
+ Woro helps you create rake tasks, that you can develop and run locally.
21
+ Once you are ready, woro let\'s you push them online to a remote collection like Gist.
22
+ Using a mina deployment setup, these tasks are downloaded on the remote system,
23
+ executed by rake and cleaned up afterwards.'
24
+
25
+ default_command :list
26
+
27
+ command :init do |c|
28
+ c.syntax = 'woro init [options]'
29
+ c.description = 'Initialize Woro in the current Rails directory and setup Gist collection'
30
+ c.option '--[no-]force', 'force overwrite of existing config file'
31
+ c.action do |args, options|
32
+
33
+ if agree 'Login to Gist/Github for private Woro tasks (Yes/No)? '
34
+ Gist.login!
35
+ #else
36
+ #gen_access_token = agree "Secure gists via random access token?"
37
+ end
38
+
39
+
40
+ # create Gist with welcome file
41
+ # additional tasks will be added to this first gist
42
+ app_name = ask 'Application name: '
43
+ result = Woro::Gister.create_initial_gist(app_name)
44
+
45
+ # configure adapters
46
+ gist_adapter = {
47
+ gist_id: result['id'],
48
+ public: false
49
+ }
50
+ # TODO generate access token
51
+ #gist_adapter[:access_token] = 'access_token' if gen_access_token
52
+ adapters = { gist: gist_adapter }
53
+
54
+ unless File.exists? File.dirname(Woro::Configuration.config_file)
55
+ FileUtils.mkdir_p File.dirname(Woro::Configuration.config_file)
56
+ end
57
+ config = Woro::Configuration.save(adapters: adapters)
58
+ say 'Initialized at `./config/woro.yml`'
59
+
60
+ unless File.exists? config.woro_task_dir
61
+ FileUtils.mkdir_p
62
+ say "Create #{config.woro_task_dir}"
63
+ end
64
+
65
+ say "Create woro.rake in #{config.rake_task_dir}"
66
+ FileUtils.mkdir_p config.rake_task_dir if !File.exists? config.rake_task_dir
67
+ FileUtils.cp(File.dirname(__FILE__) + '/../lib/woro/templates/woro.rake', config.rake_task_dir)
68
+ end
69
+ end
70
+
71
+ command :new do |c|
72
+ c.syntax = 'woro create <task> [options]'
73
+ c.summary = 'Create new tasks'
74
+ c.description = 'Creates one or more new templated Rake tasks'
75
+ c.example 'Create task called "cleanup"', 'woro new cleanup'
76
+ c.example 'Creates tasks called "cleanup", "fix1" and "fix2"', 'woro new cleanup fix1 fix2'
77
+ c.option '--[no-]force', 'force overwrite of existing task file'
78
+ c.action do |args, options|
79
+ args.each do |arg|
80
+ config = Woro::Configuration.load
81
+ task = Woro::Task.new(config.adapters[:gist][:gist_id], arg)
82
+ force_overwrite = options.force
83
+ if !task.exists? || force_overwrite || agree("Overwrite existing #{task.file_path}?")
84
+ task.create_from_task_template
85
+ say "Created #{task.file_path}"
86
+ end
87
+ end
88
+ end
89
+ end
90
+
91
+ command :push do |c|
92
+ c.syntax = 'woro push <task> [options]'
93
+ c.summary = 'Push tasks to remote collection, updates existing tasks'
94
+ c.description = 'Pushes one or more local tasks to the remote collection. Existing tasks by this name in the remote connection will be updated.'
95
+ c.example 'Pushes the task "cleanup" to the remote collection', 'woro push cleanup'
96
+ c.action do |args, options|
97
+ args.each do |arg|
98
+ config = Woro::Configuration.load
99
+ # Pushes a new woro task by given name to gist, this can be done multiple time.
100
+ task = Woro::Task.new(config.adapters[:gist][:gist_id], arg)
101
+ if task.exists?
102
+ result = task.push
103
+ say "Uploaded #{task.file_path} to #{result['url']}"
104
+ else
105
+ say "Task #{task.task_name} not found at #{task.file_path}"
106
+ end
107
+ end
108
+ end
109
+ end
110
+
111
+ command :pull do |c|
112
+ c.syntax = 'woro pull <task> [options]'
113
+ c.summary = 'Pull Woro task from remote repository'
114
+ c.description = 'Pulls one task from the remote collection. Existing local tasks can be overwritten.'
115
+ c.example 'Pulls the task "cleanup" from the remote collection', 'woro pull cleanup'
116
+ c.option '--[no-]force', 'force overwrite of existing task file'
117
+ c.action do |args, options|
118
+ config = Woro::Configuration.load
119
+ # Pulls the woro task by given name to gist, this can be done multiple time.
120
+ task = Woro::Task.new(config.adapters[:gist][:gist_id], args.first)
121
+ force_save = options.force
122
+ if !task.exists? || force_overwrite || agree("Overwrite existing #{task.file_path}?")
123
+ system "cd '#{config.woro_task_dir}' && curl -O -# #{task.raw_url}"
124
+ say "Downloaded #{task.task_name} to #{task.file_path}"
125
+ end
126
+ end
127
+ end
128
+
129
+ command :list do |c|
130
+ c.syntax = 'woro [list|ls] [options]'
131
+ c.description = 'List tasks'
132
+ c.example 'List remote tasks', 'woro list'
133
+ c.example 'List all tasks', 'woro list --all'
134
+ c.option '-a', '--all', 'List all tasks'
135
+ c.action do |args, options|
136
+ abort "invalid command. See 'woro help' for more information" unless args.empty?
137
+ config = Woro::Configuration.load
138
+ files = Woro::Gister.get_list_of_files config.adapters[:gist][:gist_id]
139
+ tasks = files.map { |file_name, data| OpenStruct.new(name_with_args: file_name.split('.rake').first, comment: Woro::Gister.extract_description(data)) if file_name.include? '.rake' }
140
+ tasks.compact!
141
+ width ||= tasks.map { |t| t.name_with_args.length }.max || 10
142
+ tasks.each do |t|
143
+ puts " %-#{width}s # %s" % [ t.name_with_args, t.comment ]
144
+ end
145
+ end
146
+ end
147
+ alias_command :ls, :list
148
+
@@ -0,0 +1,61 @@
1
+ require 'yaml'
2
+ require 'commander'
3
+ include Commander::UI
4
+
5
+ module Woro
6
+ class Configuration
7
+ attr_reader :adapters, :woro_task_dir
8
+
9
+ # Initialize configuration.
10
+ def initialize(options = {})
11
+ @woro_task_dir = Configuration.woro_task_dir
12
+ @adapters = options[:adapters]
13
+ end
14
+
15
+ # Load configuration file or default_options. Passed options take precedence.
16
+ def self.load(options = {})
17
+ user_options = options.reject{|k,v| ![:adapters, :app_name].include? k}
18
+
19
+ if !(File.exists? config_file)
20
+ File.open(config_file, 'w') { |file| YAML::dump(default_options, file) }
21
+ say "Initialized default config file in #{config_file}. See 'woro help init' for options."
22
+ end
23
+
24
+ config_file_options = YAML.load_file(config_file)
25
+ new(config_file_options.merge(user_options))
26
+ end
27
+
28
+ # Save configuration. Passed options take precendence over default_options.
29
+ def self.save(options = {})
30
+ user_options = options.reject{|k,v| ![:adapters, :app_name].include? k}
31
+ force_save = options.delete :force
32
+
33
+ if !(File.exists? config_file) || force_save
34
+ File.open(config_file, 'w') { |file| YAML::dump(default_options.merge(user_options), file) }
35
+ say "Initialized config file in #{config_file}"
36
+ else
37
+ say_error "Not overwriting existing config file #{config_file}, use --force to override. See 'woro help init'."
38
+ end
39
+ self
40
+ end
41
+
42
+ # Helpers
43
+
44
+ def self.config_file
45
+ File.join('config', 'woro.yml')
46
+ end
47
+
48
+ def self.woro_task_dir
49
+ File.join('lib', 'woro_tasks')
50
+ end
51
+
52
+ def self.rake_task_dir
53
+ File.join('lib', 'tasks')
54
+ end
55
+
56
+ def self.default_options
57
+ {
58
+ }
59
+ end
60
+ end
61
+ end
data/lib/woro/gister.rb CHANGED
@@ -1,22 +1,45 @@
1
1
  require 'gist'
2
2
  require 'net/https'
3
3
 
4
+ # All classes and modules specific to Woro.
4
5
  module Woro
6
+ # Various shared static helpers
5
7
  class Gister
6
8
  class << self
7
- def create_initial_gist(app_name)
8
- Gist.gist("Welcome to the Woro Task Repository for #{app_name}", filename: app_name)
9
+ # Creates an initial welcome gist on project setup
10
+ # @param app_name [String] Name of the app is displayed in the initial welcome message
11
+ def create_initial_gist(app_name, access_token=nil)
12
+ Gist.gist("Welcome to the Woro Task Repository for #{app_name}", filename: app_name, access_token: access_token)
9
13
  end
10
14
 
15
+ # Retrieves metadata of the specified gist
16
+ # @param gist_id [String] id of the gist
17
+ # @return [Hash] parsed JSON hash
11
18
  def retrieve_gist(gist_id)
12
19
  service_url = "https://api.github.com/gists/#{gist_id}"
13
20
  response = Net::HTTP.get_response(URI.parse(service_url))
14
21
  JSON.parse(response.body)
15
22
  end
16
23
 
24
+ # Extract description from gist's data content string.
25
+ # @param data [Hash] gist data hash
26
+ # [String] description string
27
+ def extract_description(data)
28
+ data['content'].match(/desc ['"]([a-zA-Z0-9\s]*)['"]/)[1]
29
+ end
30
+
31
+ # Returns the list of files included in the specified gist
32
+ # @param gist_id [String] id of the gist
33
+ # @return [Hash] List of files in the format { filename: { data }}
17
34
  def get_list_of_files(gist_id)
18
35
  retrieve_gist(gist_id)['files']
19
36
  end
37
+
38
+ # Read the rake task template
39
+ # @return [String]
40
+ def read_template_file
41
+ File.read(File.dirname(__FILE__) + '/templates/task.rake')
42
+ end
20
43
  end
21
44
  end
22
45
  end
data/lib/woro/task.rb CHANGED
@@ -2,43 +2,71 @@ require 'net/https'
2
2
  require 'erb'
3
3
 
4
4
  module Woro
5
+ # Task object, helps in the creation and management of gists.
5
6
  class Task
6
7
  attr_reader :task_name, :gist_id, :gist
7
8
 
8
9
  def initialize(gist_id, task_name)
9
- @task_name = task_name
10
+ @task_name = Woro::Task.sanitize_task_name task_name
10
11
  @gist_id = gist_id
11
12
  end
12
13
 
14
+ # Create a new task based on a template rake-task.
15
+ # @param gist_id [String] gist to which the task is added
16
+ # @param task_name [String] sanitized name of the task, used throughout the further processing
17
+ # @return [Task] the created task
13
18
  def self.create(gist_id, task_name)
14
19
  task = Woro::Task.new(gist_id, task_name)
15
- task.create_empty_task
20
+ task.create_from_task_template
21
+ task
16
22
  end
17
23
 
24
+ def self.sanitize_task_name(task_name)
25
+ task_name.strip.split(' ').first
26
+ end
27
+
28
+ # File name based on the task's name.
29
+ # @return [String]
18
30
  def file_name
19
31
  "#{task_name}.rake"
20
32
  end
21
33
 
34
+ # File name based on the task's filename (see #file_name).
35
+ # @return [String]
22
36
  def file_path
23
- "lib/woro_tasks/#{file_name}"
37
+ File.join('lib','woro_tasks', file_name)
38
+ end
39
+
40
+ # Returns true if a task of this name exists locally
41
+ def exists?
42
+ File.exists? file_path
24
43
  end
25
44
 
26
- def create_empty_task
45
+ # Creates a new rake task file at the file path (see #file_path).
46
+ def create_from_task_template
27
47
  b = binding
28
- template = ERB.new(read_template_file).result(b)
48
+ template = ERB.new(Gister.read_template_file).result(b)
29
49
  File.open(file_path, 'w') do |f|
30
50
  f.puts template
31
51
  end
32
52
  end
33
53
 
34
- def read_template_file
35
- File.read(File.dirname(__FILE__) +"/templates/task.rake")
54
+ # Requests the content of the task file within the Gist collection
55
+ # from the server.
56
+ # @return [String]
57
+ def retrieve_raw_file
58
+ response = Net::HTTP.get_response(raw_url)
59
+ response.body
36
60
  end
37
61
 
62
+ # Read the content of the local rake task file on #file_path.
38
63
  def read_task_file
39
64
  File.read(file_path)
40
65
  end
41
66
 
67
+ # Push this task's file content to the Gist collection on the server.
68
+ # Existing contents by the same #file_name will be overriden, but
69
+ # can be accessed via Github or Gist's API.
42
70
  def push
43
71
  Gist.multi_gist({ file_name => read_task_file },
44
72
  public: false,
@@ -46,21 +74,23 @@ module Woro
46
74
  output: :all)
47
75
  end
48
76
 
77
+ # The Gist contains a collection of files.
78
+ # These are stored and accessed on Github.
79
+ # @return [Hash] parsed JSON hash of the gist's metadata
49
80
  def gist
50
81
  @gist ||= Gister.retrieve_gist(gist_id)
51
82
  end
52
83
 
84
+ # Retrieves the data hash included in the gist under the #file_name.
85
+ # @return [Hash] parsed JSON hash
53
86
  def retrieve_file_data
54
87
  gist['files'][file_name]
55
88
  end
56
89
 
90
+ # The raw url is a permalink for downloading the content rake task within
91
+ # the Gist as a file.
57
92
  def raw_url
58
93
  retrieve_file_data['raw_url']
59
94
  end
60
-
61
- def retrieve_raw_file
62
- response = Net::HTTP.get_response(raw_url)
63
- response.body
64
- end
65
95
  end
66
96
  end
@@ -0,0 +1,58 @@
1
+ require 'ostruct'
2
+ require 'woro/gister'
3
+ require 'woro/task'
4
+
5
+ # Capistrano Recipes for managing woro tasks
6
+ #
7
+ # Add these callbacks to have the delayed_job process restart when the server
8
+ # is restarted:
9
+ #
10
+ # after "deploy:stop", "delayed_job:stop"
11
+ # after "deploy:start", "delayed_job:start"
12
+ # after "deploy:restart", "delayed_job:restart"
13
+ #
14
+ # If you want to use command line options, for example to start multiple workers,
15
+ # define a Capistrano variable delayed_job_args:
16
+ #
17
+ # set :delayed_job_args, "-n 2"
18
+ #
19
+ # If you've got delayed_job workers running on a servers, you can also specify
20
+ # which servers have delayed_job running and should be restarted after deploy.
21
+ #
22
+ # set :delayed_job_server_role, :worker
23
+ #
24
+
25
+ Capistrano::Configuration.instance.load do
26
+ namespace :delayed_job do
27
+ def rails_env
28
+ fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
29
+ end
30
+
31
+ def args
32
+ fetch(:delayed_job_args, '')
33
+ end
34
+
35
+ def roles
36
+ fetch(:delayed_job_server_role, :app)
37
+ end
38
+
39
+ def delayed_job_command
40
+ fetch(:delayed_job_command, 'script/delayed_job')
41
+ end
42
+
43
+ desc 'Stop the delayed_job process'
44
+ task :stop, :roles => lambda { roles } do
45
+ run "cd #{current_path} && #{rails_env} #{delayed_job_command} stop #{args}"
46
+ end
47
+
48
+ desc 'Start the delayed_job process'
49
+ task :start, :roles => lambda { roles } do
50
+ run "cd #{current_path} && #{rails_env} #{delayed_job_command} start #{args}"
51
+ end
52
+
53
+ desc 'Restart the delayed_job process'
54
+ task :restart, :roles => lambda { roles } do
55
+ run "cd #{current_path} && #{rails_env} #{delayed_job_command} restart #{args}"
56
+ end
57
+ end
58
+ end
@@ -1,113 +1,17 @@
1
1
  require 'ostruct'
2
- require 'woro/gister'
3
- require 'woro/task'
4
-
5
- def _tasks_dir
6
- fetch(:tasks_dir, 'lib/woro_tasks')
7
- end
8
-
9
- def prompt(*args)
10
- print(*args)
11
- STDIN.gets.chomp
12
- end
13
-
14
- def sanitized_task_name
15
- ENV['task'].strip.split(' ').first
16
- end
17
-
18
- def check_presence_of_task_name
19
- if ENV['task'].nil?
20
- print_error('No taskname given.')
21
- raise 'No taskname given'
22
- end
23
- end
24
-
25
- def extract_description(data)
26
- data['content'].match(/desc ['"]([a-zA-Z0-9\s]*)['"]/)[1]
27
- end
2
+ require 'woro'
28
3
 
29
4
  # tasks available to mina to run remotely
30
5
  namespace :woro do
31
-
32
- desc 'Initialize new Woro repository'
33
- task :init do
34
- print status 'Configure Gist/Github access'
35
-
36
- login_gist = prompt "Login to Gist/Github for private Woro tasks (Yes/No):"
37
- if %w(yes y).include? login_gist
38
- Gist.login!
39
- #else
40
- # access_token = prompt "Secure gists via Access Token:"
41
- end
42
-
43
- # create Gist with welcome file
44
- # additional tasks will be added to this first gist
45
- app_name = fetch(:app_name, 'TestApp') #Rails.application.class.parent_name
46
- result = Woro::Gister.create_initial_gist(app_name)
47
-
48
- print status 'Setup in your project'
49
- print_stdout "add this to your deploy.rb:"
50
- print_stdout "set :woro_token, '#{result['id']}"
51
-
52
- print status 'Create woro_tasks in lib/'
53
- FileUtils.mkdir_p _tasks_dir if !File.exists? _tasks_dir
54
-
55
- print status 'Create woro.rake in lib/tasks/'
56
- FileUtils.cp(File.dirname(__FILE__) +"/templates/woro.rake", 'lib/tasks/')
57
- end
58
-
59
- desc 'Create new Woro task'
60
- task :new do
61
- check_presence_of_task_name
62
- print_status "Create lib/woro_tasks/#{sanitized_task_name}.rake"
63
- Woro::Task.create(fetch(:woro_token), sanitized_task_name)
64
- end
65
-
66
- desc 'Push and run Woro task remotely'
67
- task execute: environment do
68
- invoke :'woro:push'
69
- invoke :'woro:run'
70
- end
71
-
72
- desc 'Push Woro task to remote repository, updates existing'
73
- task :push do
74
- check_presence_of_task_name
75
- # Pushes a new woro task by given name to gist, this can be done multiple time.
76
- task = Woro::Task.new(fetch(:woro_token), sanitized_task_name)
77
- print_status "Upload lib/woro_tasks/#{sanitized_task_name}.rake"
78
- task.push
79
- end
80
-
81
- desc 'Pull Woro task from remote repository'
82
- task :pull do
83
- check_presence_of_task_name
84
- # Pulls the woro task by given name to gist, this can be done multiple time.
85
- task = Woro::Task.new(fetch(:woro_token), sanitized_task_name)
86
- print_status "Download #{sanitized_task_name} to lib/woro_tasks/#{sanitized_task_name}.rake"
87
- system "cd 'lib/tasks' && curl -O -# #{task.raw_url}"
88
- end
89
-
90
6
  desc 'Run Woro task remotely'
91
7
  task run: :environment do
92
- check_presence_of_task_name
93
- task = Woro::Task.new(fetch(:woro_token), sanitized_task_name)
94
-
95
- print_status "Execute #{sanitized_task_name} remotely"
8
+ config = Woro::Configuration.load
9
+ task = Woro::Task.new(config.adapter[:gist][:gist_id], ENV['task'])
10
+ print_status "Execute #{task.task_name} remotely"
96
11
  in_directory "#{app_path}" do
97
12
  queue! "cd 'lib/tasks' && curl -O #{task.raw_url}"
98
- queue! "#{bundle_prefix} rake woro:#{sanitized_task_name}"
13
+ queue! "#{bundle_prefix} rake woro:#{task.task_name}"
99
14
  queue! "rm lib/tasks/#{task.file_name}"
100
15
  end
101
16
  end
102
-
103
- desc 'List all remote Woro tasks'
104
- task :list do
105
- files = Woro::Gister.get_list_of_files(fetch(:woro_token))
106
- tasks = files.map { |file_name, data| OpenStruct.new(name_with_args: file_name.split('.rake').first, comment: extract_description(data)) if file_name.include? '.rake' }
107
- tasks.compact!
108
- width ||= tasks.map { |t| t.name_with_args.length }.max || 10
109
- tasks.each do |t|
110
- puts " #{name} %-#{width}s # %s" % [ t.name_with_args, t.comment ]
111
- end
112
- end
113
17
  end
data/lib/woro/version.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module Woro
2
- VERSION = "0.0.2"
2
+ # Look shiny!
3
+ VERSION = "0.1.0"
3
4
  end
data/lib/woro.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'woro/version'
2
+ require 'woro/task'
3
+ require 'woro/gister'
4
+ require 'woro/configuration'
data/woro.gemspec CHANGED
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "mina", ">= 0.2.1"
22
21
  spec.add_dependency "gist"
22
+ spec.add_dependency "commander"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
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-04-19 00:00:00.000000000 Z
11
+ date: 2015-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: mina
14
+ name: gist
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.1
19
+ version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.1
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: gist
28
+ name: commander
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -181,7 +181,8 @@ dependencies:
181
181
  description: One-time migration task management on remote servers through mina.
182
182
  email:
183
183
  - mail@danielsenff.de
184
- executables: []
184
+ executables:
185
+ - woro
185
186
  extensions: []
186
187
  extra_rdoc_files: []
187
188
  files:
@@ -190,9 +191,13 @@ files:
190
191
  - LICENSE
191
192
  - README.md
192
193
  - Rakefile
194
+ - bin/woro
193
195
  - lib/mina/woro.rb
196
+ - lib/woro.rb
197
+ - lib/woro/configuration.rb
194
198
  - lib/woro/gister.rb
195
199
  - lib/woro/task.rb
200
+ - lib/woro/tasks/capistrano.rake
196
201
  - lib/woro/tasks/mina.rake
197
202
  - lib/woro/templates/task.rake
198
203
  - lib/woro/templates/woro.rake