voidtools 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Readme.md +10 -14
- data/lib/voidtools/cap/deploy.rb +152 -0
- data/lib/voidtools/dm/form_helpers.rb +5 -3
- data/lib/voidtools/dm/paginable.rb +6 -5
- data/lib/voidtools/sinatra/view_helpers.rb +21 -0
- data/lib/voidtools/version.rb +1 -1
- metadata +5 -12
data/Readme.md
CHANGED
@@ -1,22 +1,18 @@
|
|
1
1
|
# Voidtools
|
2
|
-
#### growing toolset for Rails 3
|
3
|
-
|
4
|
-
|
5
|
-
### building the gem locally and installing it in one line (for trying things and stuff):
|
6
|
-
|
7
|
-
gem build voidtools.gemspec; gem install voidtools-0.2.1.gem
|
8
|
-
|
2
|
+
#### growing toolset for Rails 3 and Sinatra with DataMapper and HAML class and helper modules
|
9
3
|
|
10
4
|
---
|
11
5
|
|
12
6
|
### DataMapper
|
13
|
-
-
|
14
|
-
|
15
|
-
|
16
|
-
- soon...
|
7
|
+
- form helpers: error_messages_for
|
8
|
+
- name url
|
9
|
+
- pagination
|
17
10
|
|
18
|
-
###
|
19
|
-
-
|
11
|
+
### Sinatra
|
12
|
+
- view helpers
|
13
|
+
- link_to
|
14
|
+
- image tag
|
15
|
+
- include_assets (include_js, include_css)
|
20
16
|
|
21
17
|
note: ruby 1.9 required
|
22
18
|
|
@@ -33,4 +29,4 @@ or
|
|
33
29
|
|
34
30
|
### Build & install
|
35
31
|
|
36
|
-
gem build voidtools.gemspec; gem install voidtools-0.
|
32
|
+
gem build voidtools.gemspec; gem install voidtools-0.2.3.gem
|
@@ -0,0 +1,152 @@
|
|
1
|
+
|
2
|
+
set :application, "thorrents"
|
3
|
+
|
4
|
+
#set :domain, "krikri.makevoid.com"
|
5
|
+
set :domain, "ovh.makevoid.com"
|
6
|
+
|
7
|
+
# git
|
8
|
+
|
9
|
+
# #set :repository, "svn://#{domain}/svn/#{application}"
|
10
|
+
# #default_run_options[:pty] = true # Must be set for the password prompt from git to work
|
11
|
+
set :repository, "git://github.com/makevoid/thorrents.git" # public
|
12
|
+
|
13
|
+
set :scm, "git"
|
14
|
+
set :branch, "master"
|
15
|
+
set :deploy_via, :remote_cache
|
16
|
+
|
17
|
+
set :password, File.read("/Users/makevoid/.password").strip.gsub(/33/, '')
|
18
|
+
|
19
|
+
|
20
|
+
set :user, "www-data"
|
21
|
+
|
22
|
+
set :use_sudo, false
|
23
|
+
set :deploy_to, "/www/#{application}"
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
# set :scm_username, "makevoid"
|
28
|
+
# set :scm_password, File.read("/home/www-data/.password").strip
|
29
|
+
|
30
|
+
role :app, domain
|
31
|
+
role :web, domain
|
32
|
+
role :db, domain, :primary => true
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
after :deploy, "deploy:cleanup"
|
38
|
+
#after :deploy, "db:seeds"
|
39
|
+
|
40
|
+
namespace :deploy do
|
41
|
+
|
42
|
+
desc "Restart Application"
|
43
|
+
task :restart, :roles => :app do
|
44
|
+
run "touch #{current_path}/tmp/restart.txt"
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
namespace :bundle do
|
50
|
+
desc "Install gems with bundler"
|
51
|
+
task :install do
|
52
|
+
run "cd #{current_path}; bundle install --relock"
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Commit, deploy and install"
|
56
|
+
task :installscom do
|
57
|
+
`svn commit -m ''`
|
58
|
+
`cap deploy`
|
59
|
+
`cap bundle:install`
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# ...
|
64
|
+
|
65
|
+
namespace :bundler do
|
66
|
+
task :create_symlink, :roles => :app do
|
67
|
+
shared_dir = File.join(shared_path, 'bundle')
|
68
|
+
release_dir = File.join(current_release, '.bundle')
|
69
|
+
run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
|
70
|
+
end
|
71
|
+
|
72
|
+
task :bundle_new_release, :roles => :app do
|
73
|
+
bundler.create_symlink
|
74
|
+
run "cd #{release_path} && bundle install --without test"
|
75
|
+
end
|
76
|
+
|
77
|
+
task :lock, :roles => :app do
|
78
|
+
run "cd #{current_release} && bundle lock;"
|
79
|
+
end
|
80
|
+
|
81
|
+
task :unlock, :roles => :app do
|
82
|
+
run "cd #{current_release} && bundle unlock;"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# HOOKS
|
87
|
+
after "deploy:update_code" do
|
88
|
+
bundler.bundle_new_release
|
89
|
+
# ...
|
90
|
+
end
|
91
|
+
|
92
|
+
R_ENV = "RACK_ENV"
|
93
|
+
|
94
|
+
namespace :scraper do
|
95
|
+
desc "Run the scraper"
|
96
|
+
task :scrape do
|
97
|
+
run "cd #{current_path}; #{R_ENV}=production bundle exec rake scraper:scrape --trace"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
102
|
+
namespace :db do
|
103
|
+
desc "Create database"
|
104
|
+
task :create do
|
105
|
+
run "mysql -u root --password=#{password} -e 'CREATE DATABASE IF NOT EXISTS #{application}_production;'"
|
106
|
+
end
|
107
|
+
|
108
|
+
desc "Seed database"
|
109
|
+
task :seeds do
|
110
|
+
run "cd #{current_path}; #{R_ENV}=production rake db:seeds"
|
111
|
+
end
|
112
|
+
|
113
|
+
desc "Migrate database"
|
114
|
+
task :automigrate do
|
115
|
+
run "cd #{current_path}; #{R_ENV}=production rake db:automigrate --trace"
|
116
|
+
end
|
117
|
+
|
118
|
+
desc "Send the local db to production server"
|
119
|
+
task :toprod do
|
120
|
+
# `rake db:seeds`
|
121
|
+
`mysqldump -u root #{application}_development > db/#{application}_development.sql`
|
122
|
+
upload "db/#{application}_development.sql", "#{current_path}/db", :via => :scp
|
123
|
+
run "mysql -u root --password=#{password} #{application}_production < #{current_path}/db/#{application}_development.sql"
|
124
|
+
end
|
125
|
+
|
126
|
+
desc "Get the remote copy of production db"
|
127
|
+
task :todev do
|
128
|
+
run "mysqldump -u root --password=#{password} #{application}_production > #{current_path}/db/#{application}_production.sql"
|
129
|
+
download "#{current_path}/db/#{application}_production.sql", "db/#{application}_production.sql"
|
130
|
+
local_path = `pwd`.strip
|
131
|
+
`mysql -u root #{application}_development < #{local_path}/db/#{application}_production.sql`
|
132
|
+
|
133
|
+
|
134
|
+
desc "Get the remote copy of production db [option: BACKUP]"
|
135
|
+
task :todev do
|
136
|
+
run "mysqldump -u root --password=#{password} #{application}_production > #{current_path}/db/#{application}_production.sql"
|
137
|
+
download "#{current_path}/db/#{application}_production.sql", "db/#{application}_production.sql"
|
138
|
+
local_path = `pwd`.strip
|
139
|
+
`mysql -u root #{application}_development < #{local_path}/db/#{application}_production.sql`
|
140
|
+
|
141
|
+
t = Time.now
|
142
|
+
file = "#{application}_production_#{t.strftime("%Y_%m_%d")}.sql"
|
143
|
+
`mv db/#{application}_production.sql db/#{file}`
|
144
|
+
|
145
|
+
if ENV["BACKUP"] != "" || ENV["BACKUP"].nil?
|
146
|
+
`cp db/#{file} ~/db_backups/`
|
147
|
+
puts "Backup saved on ~/db_backups/#{file}"
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
@@ -8,9 +8,11 @@ module Voidtools
|
|
8
8
|
entity
|
9
9
|
end
|
10
10
|
return nil if obj.errors.map{ |e| e } == []
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
haml_tag :ul, { class: "error_messages" } do
|
12
|
+
obj.errors.map do |err|
|
13
|
+
haml_tag(:li){ haml_concat err[0].to_s }
|
14
|
+
end
|
15
|
+
end
|
14
16
|
end
|
15
17
|
|
16
18
|
end
|
@@ -2,23 +2,24 @@ module Voidtools
|
|
2
2
|
|
3
3
|
module Paginable
|
4
4
|
|
5
|
-
PER_PAGE = 70
|
6
|
-
|
7
5
|
def self.included(base)
|
8
6
|
base.send :extend, ClassMethods
|
9
7
|
end
|
10
8
|
|
11
9
|
module ClassMethods
|
10
|
+
def x_page
|
11
|
+
defined?(per_page) ? per_page : 10
|
12
|
+
end
|
13
|
+
|
12
14
|
def paginate(options)
|
13
15
|
page = options[:page].to_i
|
14
16
|
options.delete :page
|
15
|
-
all( options.merge(limit:
|
17
|
+
all( options.merge(limit: x_page, offset: x_page*page) )
|
16
18
|
end
|
17
19
|
|
18
20
|
def pages
|
19
|
-
all.count/
|
21
|
+
all.count/x_page
|
20
22
|
end
|
21
|
-
|
22
23
|
end
|
23
24
|
|
24
25
|
end
|
@@ -14,6 +14,27 @@ module Voidtools
|
|
14
14
|
def image_tag(url, options={})
|
15
15
|
haml_tag :img, options.merge(src: url)
|
16
16
|
end
|
17
|
+
|
18
|
+
def include_assets(type, assets)
|
19
|
+
type_js = type == "js"
|
20
|
+
tag = type_js ? "script" : "link"
|
21
|
+
[assets].flatten.each do |asset|
|
22
|
+
options = if type_js
|
23
|
+
{ type: "text/javascript", src: "/js/#{asset}.js" }
|
24
|
+
else
|
25
|
+
{ rel: "stylesheet", href: "/css/#{asset}.css" }
|
26
|
+
end
|
27
|
+
haml_tag tag, options
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def include_js(assets)
|
32
|
+
include_assets "js", assets
|
33
|
+
end
|
34
|
+
|
35
|
+
def include_css(assets)
|
36
|
+
include_assets "css", assets
|
37
|
+
end
|
17
38
|
end
|
18
39
|
end
|
19
40
|
end
|
data/lib/voidtools/version.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: voidtools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 2
|
9
|
-
version: 0.2.2
|
4
|
+
prerelease:
|
5
|
+
version: 0.2.3
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Francesco 'makevoid' Canessa
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-06-07 00:00:00 +02:00
|
18
14
|
default_executable:
|
19
15
|
dependencies: []
|
20
16
|
|
@@ -28,6 +24,7 @@ extra_rdoc_files: []
|
|
28
24
|
|
29
25
|
files:
|
30
26
|
- Readme.md
|
27
|
+
- lib/voidtools/cap/deploy.rb
|
31
28
|
- lib/voidtools/dm/form_helpers.rb
|
32
29
|
- lib/voidtools/dm/name_url.rb
|
33
30
|
- lib/voidtools/dm/paginable.rb
|
@@ -50,21 +47,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
47
|
requirements:
|
51
48
|
- - ">="
|
52
49
|
- !ruby/object:Gem::Version
|
53
|
-
segments:
|
54
|
-
- 0
|
55
50
|
version: "0"
|
56
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
52
|
none: false
|
58
53
|
requirements:
|
59
54
|
- - ">="
|
60
55
|
- !ruby/object:Gem::Version
|
61
|
-
segments:
|
62
|
-
- 0
|
63
56
|
version: "0"
|
64
57
|
requirements: []
|
65
58
|
|
66
59
|
rubyforge_project: voidtools
|
67
|
-
rubygems_version: 1.
|
60
|
+
rubygems_version: 1.6.2
|
68
61
|
signing_key:
|
69
62
|
specification_version: 3
|
70
63
|
summary: custom rails3 toolset - for dm+jquery+haml+warden setup
|