hw 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +49 -0
- data/bin/hw +4 -0
- data/lib/hw.rb +4 -0
- data/lib/hw/actions.rb +31 -0
- data/lib/hw/base.rb +10 -0
- data/lib/hw/cli.rb +74 -0
- data/lib/hw/core_ext/string.rb +6 -0
- data/lib/hw/packages/system.rb +42 -0
- data/lib/hw/utilities.rb +31 -0
- data/lib/hw/version.rb +3 -0
- metadata +203 -0
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Tom Milewski
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# HW
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'hw'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install hw
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
$ hw active_admin install
|
22
|
+
$ hw active_admin resource <model name>
|
23
|
+
$ hw airbrake install
|
24
|
+
$ hw devise install # TODO
|
25
|
+
$ hw devise strategy <facebook | twitter | instagram | github> # TODO
|
26
|
+
$ hw git commit # TODO
|
27
|
+
$ hw git gitignore
|
28
|
+
$ hw git init
|
29
|
+
$ hw git remote # TODO
|
30
|
+
$ hw haml convert
|
31
|
+
$ hw haml install
|
32
|
+
$ hw memcache install
|
33
|
+
$ hw memcache session_store
|
34
|
+
$ hw memcache start
|
35
|
+
$ hw new_relic install <license key>
|
36
|
+
$ hw rails new <project name>
|
37
|
+
$ hw redis install
|
38
|
+
$ hw resque install
|
39
|
+
$ hw resque scheduler
|
40
|
+
$ hw resque worker <name>
|
41
|
+
$ hw unicorn install
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
48
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
49
|
+
5. Create new Pull Request
|
data/bin/hw
ADDED
data/lib/hw.rb
ADDED
data/lib/hw/actions.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module HW
|
2
|
+
module Actions
|
3
|
+
def header msg
|
4
|
+
say_status ">>>", "\e[36m#{msg}\e[0m", :cyan
|
5
|
+
end
|
6
|
+
|
7
|
+
def info msg; say_status "info", msg, :white; end
|
8
|
+
def success msg; say_status "success", msg, :green; end
|
9
|
+
def error msg; say_status "error", msg, :red; end
|
10
|
+
def warn msg; say_status "warning", msg, :yellow; end
|
11
|
+
|
12
|
+
def replace_file(destination, data = nil, config = {}, &block)
|
13
|
+
remove_file(destination)
|
14
|
+
create_file(destination, data, config, block)
|
15
|
+
end
|
16
|
+
|
17
|
+
def bundle
|
18
|
+
header "Bundling gems"
|
19
|
+
run "bundle install --quiet"
|
20
|
+
end
|
21
|
+
|
22
|
+
def migrate env = :development
|
23
|
+
header "Migrating the database"
|
24
|
+
rake "db:migrate", :env => env
|
25
|
+
end
|
26
|
+
|
27
|
+
def worker filename, data=nil, &block
|
28
|
+
create_file("app/workers/#{filename}", data, :verbose => false, &block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/hw/base.rb
ADDED
data/lib/hw/cli.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'hw/base'
|
2
|
+
|
3
|
+
module HW
|
4
|
+
class Thor < ::Thor
|
5
|
+
include Thor::Actions
|
6
|
+
include Rails::Generators::Actions
|
7
|
+
include HW::Utilities
|
8
|
+
include HW::Actions
|
9
|
+
end
|
10
|
+
|
11
|
+
class CLI < HW::Thor
|
12
|
+
def self.start(given_args = ARGV, config = {})
|
13
|
+
packages = Hash.new
|
14
|
+
|
15
|
+
if ARGV.empty?
|
16
|
+
SOURCES.keys.each do |directory|
|
17
|
+
full_path = File.join(SOURCES_PATH, directory, "*.rb")
|
18
|
+
|
19
|
+
Dir[full_path].each do |file|
|
20
|
+
key = File.basename(file, '.rb')
|
21
|
+
packages[key] = file
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
packages.merge!({ 'system' => nil, 'help' => nil })
|
26
|
+
|
27
|
+
Thor::Shell::Basic.new.print_in_columns(packages.keys.sort)
|
28
|
+
else
|
29
|
+
name = ARGV.first
|
30
|
+
|
31
|
+
if name != 'settings'
|
32
|
+
if %w(system help).include?(name)
|
33
|
+
require 'hw/packages/system'
|
34
|
+
register(HW::Packages::System, "system", "system <command>", "Perform system commands")
|
35
|
+
else
|
36
|
+
SOURCES.keys.each do |directory|
|
37
|
+
full_path = File.join(SOURCES_PATH, directory, "#{name}.rb")
|
38
|
+
packages[name] = full_path if File.exists?(full_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
require packages[name]
|
43
|
+
rescue TypeError
|
44
|
+
puts "Package '#{name}' does not exist in any of the sources."
|
45
|
+
exit(1)
|
46
|
+
end
|
47
|
+
|
48
|
+
pkg_name = name.to_pkg
|
49
|
+
|
50
|
+
if RESERVED_WORDS.include?(pkg_name.downcase)
|
51
|
+
raise "#{pkg_name} is a reserved word and cannot be defined as a package"
|
52
|
+
end
|
53
|
+
|
54
|
+
klass = HW::Packages::const_get(pkg_name)
|
55
|
+
register(klass, name, "#{name} <command>", "")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
super(given_args, config)
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "settings", "Display cb settings information"
|
64
|
+
def settings
|
65
|
+
hidden = %w(ClassMethods)
|
66
|
+
constants = HW::Utilities.constants.reject { |c| hidden.include?(c) }
|
67
|
+
rows = Array.new
|
68
|
+
|
69
|
+
constants.each { |constant| rows << [constant, HW::Utilities::const_get(constant)] }
|
70
|
+
|
71
|
+
Thor::Shell::Basic.new.print_table(rows)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module HW
|
2
|
+
module Packages
|
3
|
+
class System < HW::Thor
|
4
|
+
desc "update", "Update installed packages"
|
5
|
+
def update
|
6
|
+
header "Updating hw"
|
7
|
+
|
8
|
+
# Setup File Structure
|
9
|
+
empty_directory DIRECTORY unless File.exists? DIRECTORY
|
10
|
+
empty_directory SOURCES_PATH unless File.exists? SOURCES_PATH
|
11
|
+
|
12
|
+
unless File.exists? CONFIG_PATH
|
13
|
+
header "Adding default source to #{CONFIG_PATH}"
|
14
|
+
|
15
|
+
create_file CONFIG_PATH
|
16
|
+
invoke :add_source, ["default", DEFAULT_SOURCE]
|
17
|
+
end
|
18
|
+
|
19
|
+
SOURCES.each do |name, url|
|
20
|
+
begin
|
21
|
+
repo_path = "#{SOURCES_PATH}/#{name}"
|
22
|
+
|
23
|
+
if File.exists?(repo_path)
|
24
|
+
Git.open(repo_path).pull
|
25
|
+
else
|
26
|
+
Git.clone(url, name, :path => SOURCES_PATH)
|
27
|
+
end
|
28
|
+
success "Successfully pulled updates from #{url} to #{SOURCES_PATH}#{name}"
|
29
|
+
rescue Git::GitExecuteError
|
30
|
+
warn "Nothing was pulled from #{url}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
desc "add_source <name> <source>", "Add a source to ~/.cbrc"
|
36
|
+
def add_source name, source
|
37
|
+
header "Appending #{name} to #{CONFIG_PATH}"
|
38
|
+
append_file CONFIG_PATH, "#{name}=#{source}\n"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/hw/utilities.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module HW
|
2
|
+
module Utilities
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
DEFAULT_SOURCE = "git@github.com:carrot/hw-packages.git"
|
7
|
+
DIRECTORY = File.expand_path("~/.hw/")
|
8
|
+
CONFIG_PATH = "#{DIRECTORY}/config"
|
9
|
+
SOURCES_PATH = "#{DIRECTORY}/sources/"
|
10
|
+
RESERVED_WORDS = %w(help system)
|
11
|
+
SOURCES = self.sources
|
12
|
+
end
|
13
|
+
|
14
|
+
module ClassMethods
|
15
|
+
def sources
|
16
|
+
if File.exists? CONFIG_PATH
|
17
|
+
sources = Hash.new
|
18
|
+
|
19
|
+
File.readlines(CONFIG_PATH).each do |line|
|
20
|
+
source = line.split("=")
|
21
|
+
sources[source[0]] = source[1].strip
|
22
|
+
end
|
23
|
+
|
24
|
+
sources
|
25
|
+
else
|
26
|
+
{}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/hw/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,203 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hw
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tom Milewski
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: &70278592665240 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70278592665240
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thor
|
27
|
+
requirement: &70278592653920 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.14.6
|
33
|
+
- - <
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '2.0'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *70278592653920
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: rails
|
41
|
+
requirement: &70278592651820 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *70278592651820
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rake
|
52
|
+
requirement: &70278592651140 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
type: :runtime
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: *70278592651140
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: httparty
|
63
|
+
requirement: &70278592650380 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
type: :runtime
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: *70278592650380
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: pg
|
74
|
+
requirement: &70278592649580 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
type: :runtime
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: *70278592649580
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: git
|
85
|
+
requirement: &70278592648940 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: *70278592648940
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec-rails
|
96
|
+
requirement: &70278592648280 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: *70278592648280
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: ruby-prof
|
107
|
+
requirement: &70278592647560 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: '0'
|
113
|
+
type: :development
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: *70278592647560
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: debugger
|
118
|
+
requirement: &70278592646380 !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: *70278592646380
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: ronn
|
129
|
+
requirement: &70278592645660 !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
type: :development
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: *70278592645660
|
138
|
+
- !ruby/object:Gem::Dependency
|
139
|
+
name: rspec
|
140
|
+
requirement: &70278592644060 !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ~>
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '2.11'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: *70278592644060
|
149
|
+
- !ruby/object:Gem::Dependency
|
150
|
+
name: sqlite3
|
151
|
+
requirement: &70278592638880 !ruby/object:Gem::Requirement
|
152
|
+
none: false
|
153
|
+
requirements:
|
154
|
+
- - ! '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
type: :development
|
158
|
+
prerelease: false
|
159
|
+
version_requirements: *70278592638880
|
160
|
+
description: Package manager for random tasks
|
161
|
+
email:
|
162
|
+
- tmilewski@gmail.com
|
163
|
+
executables:
|
164
|
+
- hw
|
165
|
+
extensions: []
|
166
|
+
extra_rdoc_files: []
|
167
|
+
files:
|
168
|
+
- lib/hw/actions.rb
|
169
|
+
- lib/hw/base.rb
|
170
|
+
- lib/hw/cli.rb
|
171
|
+
- lib/hw/core_ext/string.rb
|
172
|
+
- lib/hw/packages/system.rb
|
173
|
+
- lib/hw/utilities.rb
|
174
|
+
- lib/hw/version.rb
|
175
|
+
- lib/hw.rb
|
176
|
+
- bin/hw
|
177
|
+
- LICENSE
|
178
|
+
- README.md
|
179
|
+
homepage: http://carrotcreative.com
|
180
|
+
licenses: []
|
181
|
+
post_install_message:
|
182
|
+
rdoc_options: []
|
183
|
+
require_paths:
|
184
|
+
- lib
|
185
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
none: false
|
187
|
+
requirements:
|
188
|
+
- - ! '>='
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
192
|
+
none: false
|
193
|
+
requirements:
|
194
|
+
- - ! '>='
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '0'
|
197
|
+
requirements: []
|
198
|
+
rubyforge_project:
|
199
|
+
rubygems_version: 1.8.17
|
200
|
+
signing_key:
|
201
|
+
specification_version: 3
|
202
|
+
summary: ''
|
203
|
+
test_files: []
|