Skip to content
Browse files

Merge branch 'feature/cli' into develop

  • Loading branch information...
2 parents f7e34bf + c8d12cf commit 79b990e890aa23a12d19448363323825bc8b2270 @towerhe committed Sep 19, 2012
Showing with 92 additions and 45 deletions.
  1. +0 −14 Gemfile
  2. +9 −10 Gemfile.lock
  3. +31 −7 README.md
  4. +29 −0 bin/rda
  5. +1 −0 lib/rda.rb
  6. +2 −5 lib/rda/nginx.rb
  7. +1 −1 lib/rda/version.rb
  8. +5 −5 lib/tasks/rda_tasks.rake
  9. +12 −1 rda.gemspec
  10. +2 −2 spec/lib/rda/nginx_spec.rb
View
14 Gemfile
@@ -15,17 +15,3 @@ gem 'jquery-rails'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'
-
-group :test do
- gem 'pry'
- gem 'rspec'
- gem 'guard'
- gem 'guard-bundler'
- gem 'guard-rspec'
- gem 'fivemat'
- if RUBY_PLATFORM =~ /darwin/
- gem 'ruby_gntp'
- elsif RUBY_PLATFORM =~ /linux/
- gem 'libnotify'
- end
-end
View
19 Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- rda (0.0.6)
+ rda (0.1.0)
confstruct
rails (>= 3.1)
thor
@@ -59,8 +59,6 @@ GEM
railties (>= 3.2.0, < 5.0)
thor (~> 0.14)
json (1.7.3)
- libnotify (0.7.4)
- ffi (~> 1.0.11)
listen (0.4.7)
rb-fchange (~> 0.0.5)
rb-fsevent (~> 0.9.1)
@@ -115,6 +113,7 @@ GEM
rspec-expectations (2.10.0)
diff-lcs (~> 1.1.3)
rspec-mocks (2.10.1)
+ ruby_gntp (0.3.4)
slop (2.4.4)
sprockets (2.1.3)
hike (~> 1.2)
@@ -131,12 +130,12 @@ PLATFORMS
ruby
DEPENDENCIES
- fivemat
- guard
- guard-bundler
- guard-rspec
+ fivemat (~> 1.0)
+ guard (~> 1.2)
+ guard-bundler (~> 1.0)
+ guard-rspec (~> 1.1)
jquery-rails
- libnotify
- pry
+ pry (~> 0.9.9)
rda!
- rspec
+ rspec (~> 2.10)
+ ruby_gntp (~> 0.3)
View
38 README.md
@@ -2,13 +2,13 @@
### Description
-Rda(Rails Development Assist) is combined with lots of useful rake tasks which can help you to setup your development enviroments and tools more quickly.
+Rda(Rails Development Assist) is combined with lots of useful rake tasks which can help you to setup your development enviroments and tools more quickly. It is also provide a CLI to set up the enviroments.
### Features
-* Setup RVM for your rails application
+* Set up RVM for your rails application
* Deploy your rails application to Nginx (rails_env is set to development by default)
-* Release your rails application
+* Release your rails application (not yet)
### Usage
@@ -37,9 +37,12 @@ if Rails.env == 'development'
end
```
-#### Setup RVM
+#### Set up RVM
```bash
+rda rvm setup
+
+# Or
rake rda:rvm:setup
```
@@ -53,19 +56,22 @@ else
fi
```
-After RVM setup, you need to trust the rvmrc by:
+After setting up RVM, you need to trust the rvmrc by:
```bash
rvm rvmrc trust
```
Or you can set `rvm_trust_rvmrcs_flag=1` in ~/.rvmrc or /etc/rvmrc.
-If RVM is not installed this task will do nothing but exit.
+If RVM is not installed, this task will do nothing but exit.
#### Discard RVM settings
```bash
+rda rvm:discard
+
+# Or
rake rda:rvm:discard
```
@@ -74,10 +80,13 @@ This task removes the .rvmrc from your rails application.
#### Setup Nginx
```bash
+rda nginx setup
+
+# Or
rake rda:nginx:setup
```
-First this task will try to find the config files of Nginx which you have installed from the following paths:
+First this task will try to find the config files of Nginx, which you have installed, from the following paths:
* /etc/nginx
* /usr/local/nginx/conf
@@ -92,6 +101,9 @@ Rda.configure { nginx_conf_paths ['/path/to/nginx/conf'] }
Please make sure that you have the write permission of the directory you choosed, or you can run:
```bash
+rvmsudo rda nginx setup
+
+# Or
rvmsudo rake rda:nginx:setup
```
@@ -108,10 +120,16 @@ Finally, You need to start Nginx `/path/to/nginx/sbin/nginx` and then visit http
#### Discard Nginx settings
```bash
+rda nginx discard # Or
+
rake rda:nginx:discard # Or
+sudo rda nginx discard # Or
+
sudo rake rda:nginx:discard # Or
+rvmsudo rda nginx discard # Using RVM
+
rvmsudo rake rda:nginx:discard # Using RVM
```
@@ -120,6 +138,9 @@ This task will clean up all the things created or configured by rda:nginx:setup.
#### Restart application
```bash
+rda app restart
+
+# Or
rake rda:app:restart
```
@@ -128,6 +149,9 @@ This task touches tmp/restart.txt to restart your rails application, For detail,
#### Release your rails application(not yet)
```bash
+rda app release
+
+# Or
rake rda:app:release
```
View
29 bin/rda
@@ -0,0 +1,29 @@
+#!/usr/bin/env ruby
+# -*- mode: ruby -*-
+
+require 'rda'
+
+begin
+ require File.expand_path("#{Dir.pwd}/config/application", __FILE__)
+rescue LoadError
+ $stderr.puts "ERROR: You should run rda under rails applications"
+end
+
+class RdaCommand < Thor
+ desc 'rvm ACTION', 'Set up RVM. Available actions: setup, discard.'
+ def rvm(action)
+ Rda::Rvm.new.send(action.to_sym)
+ end
+
+ desc 'nginx ACTION', 'Manage settings of nginx. Available actions: setup, discard.'
+ def nginx(action)
+ Rda::Nginx.new.send(action.to_sym)
+ end
+
+ desc 'app ACTION', 'Manage the lifecycle of the application. Available actions: restart.'
+ def app(action)
+ Rda::App.new.send(action.to_sym)
+ end
+end
+
+RdaCommand.start
View
1 lib/rda.rb
@@ -1,6 +1,7 @@
require 'rails'
require 'thor'
require 'confstruct'
+require 'confstruct/configuration'
require 'rda/railtie'
require 'rda/rails'
View
7 lib/rda/nginx.rb
@@ -2,13 +2,11 @@ module Rda
class Nginx < Thor
include Thor::Actions
- DEFAULT_CONF_PATHS = ['/etc/nginx', '/usr/local/nginx/conf', '/opt/nginx/conf']
-
def self.source_root
File.dirname(__FILE__)
end
- desc "Setup", "Deploy rails application to Nginx"
+ desc "setup", "Set up your rails application"
def setup
return unless installed?
@@ -25,7 +23,7 @@ def setup
end
end
- desc "Discard", "Remove the Nginx setting of rails application"
+ desc "discard", "Remove the settings of your rails application from nginx"
def discard
return unless installed?
@@ -68,7 +66,6 @@ def hostname
def available_paths
search_paths = Rda.config.nginx_conf_paths || []
- search_paths = DEFAULT_CONF_PATHS if search_paths.empty?
@paths ||= search_paths.select { |p| Dir.exists? p if p } unless search_paths.empty?
end
View
2 lib/rda/version.rb
@@ -1,3 +1,3 @@
module Rda
- VERSION = "0.0.6"
+ VERSION = "0.1.0"
end
View
10 lib/tasks/rda_tasks.rake
@@ -2,12 +2,12 @@ namespace :rda do
namespace :rvm do
rvm = Rda::Rvm.new
- desc "Setup RVM for rails application"
+ desc "Set up RVM for your rails application"
task :setup do
rvm.setup
end
- desc "Discard RVM settings of rails application"
+ desc "Discard RVM settings of your rails application"
task :discard do
rvm.discard
end
@@ -16,12 +16,12 @@ namespace :rda do
namespace :nginx do
nginx = Rda::Nginx.new
- desc "Setup Nginx for rails application"
+ desc "Set up Nginx for your rails application"
task :setup => :environment do
nginx.setup
end
- desc "Discard Nginx settings of rails application"
+ desc "Discard Nginx settings of your rails application"
task :discard => :environment do
nginx.discard
end
@@ -30,7 +30,7 @@ namespace :rda do
namespace :app do
app = Rda::App.new
- desc "Restart rails application"
+ desc "Restart your rails application"
task :restart do
app.restart
end
View
13 rda.gemspec
@@ -13,9 +13,20 @@ Gem::Specification.new do |s|
s.summary = 'Rails Development Assist'
s.description = 'Rda(Rails Development Assist) is combined with lots of useful rake tasks which can help you to setup your development enviroments and tools more quickly.'
+ s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
- s.require_paths = ['lib']
+ s.require_paths = ['lib']
+
+ s.add_development_dependency 'pry', '~> 0.9.9'
+ s.add_development_dependency 'rspec', '~> 2.10'
+ s.add_development_dependency 'guard', '~> 1.2'
+ s.add_development_dependency 'guard-bundler', '~> 1.0'
+ s.add_development_dependency 'guard-rspec', '~> 1.1'
+ s.add_development_dependency 'fivemat', '~> 1.0'
+ if RUBY_PLATFORM =~ /darwin/
+ s.add_development_dependency 'ruby_gntp', '~> 0.3'
+ end
s.add_dependency 'rails', '>= 3.1'
s.add_dependency 'thor'
View
4 spec/lib/rda/nginx_spec.rb
@@ -4,7 +4,7 @@
subject { Rda::Nginx.new }
before do
- Rda.configure { nginx_conf_paths Rda::Nginx::DEFAULT_CONF_PATHS }
+ Rda.configure { nginx_conf_paths ['/etc/nginx', '/usr/local/nginx/conf', '/opt/nginx/conf'] }
end
describe '#setup' do
@@ -66,7 +66,7 @@
conf = Rda.config.nginx_conf_paths.first
FileUtils.rm_r conf if Dir.exists?(conf)
- Rda.configure { nginx_conf_paths [Rda::Nginx::DEFAULT_CONF_PATHS] }
+ Rda.configure { nginx_conf_paths ['/etc/nginx', '/usr/local/nginx/conf', '/opt/nginx/conf'] }
end
it 'discards the settings' do

0 comments on commit 79b990e

Please sign in to comment.
Something went wrong with that request. Please try again.