zwr 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +33 -0
- data/assets/Z-ware_logo_C_big.png +0 -0
- data/assets/favicon.ico +0 -0
- data/assets/icon.png +0 -0
- data/assets/logo.png +0 -0
- data/assets/logo_transparent.png +0 -0
- data/bin/zwr +127 -0
- data/lib/tasks/zwr.rake +86 -0
- data/lib/zwr/railtie.rb +1 -1
- data/zwr.gemspec +13 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4db45ca0152a10967865039034c25b3502891935
|
4
|
+
data.tar.gz: 43dfb319bfdd2ac1913935617f7d83b7e072a9a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 244d9266e8eb226cbdfe5ab44731d5f86979ae4ae09268efe672ad1311ec32bf6d0b7637fe98b7a05b17e55cec0d0985c3bf0b051a8d7874cb00eb06eefdfad0
|
7
|
+
data.tar.gz: a1043874175c5ac08b2347ecc280ce384ca9954c854eb2b3daad39cdd35d691aca9ddc88332cc205d980e3e6f89b59a3106f02444c019dd24ff74508b244adb2
|
data/README.markdown
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# ZWR gem
|
2
|
+
|
3
|
+
This gem is a collection of jammed thingies that I want to reuse accross products.
|
4
|
+
|
5
|
+
This gem is licensed under MIT license.
|
6
|
+
|
7
|
+
# Internationalization and Localization
|
8
|
+
|
9
|
+
## I18n helpers in asset pipeline
|
10
|
+
|
11
|
+
If you have included this gem, and you are using HAML and any kind of HAML templates
|
12
|
+
such as angular-rails-templates gem, you can use the following in the template:
|
13
|
+
|
14
|
+
%span=t :'zeljko'
|
15
|
+
|
16
|
+
This will be (pre)compiled to the default language. I am planning to add some support
|
17
|
+
for resources that would be precompiled to all existing languages and served in a desired
|
18
|
+
language, but that would happen later.
|
19
|
+
|
20
|
+
## rake loc:extract
|
21
|
+
|
22
|
+
This task generates scanns all HAML files (wherever under Rails.root) for all occurances
|
23
|
+
of something of the following:
|
24
|
+
|
25
|
+
=t :'zeljko'
|
26
|
+
=t :'symbol and fallback' # Default translation
|
27
|
+
|
28
|
+
and outputs a following table:
|
29
|
+
|
30
|
+
"zeljko": "zeljko"
|
31
|
+
"symbol and fallback": "Default translation"
|
32
|
+
|
33
|
+
You should asure this table gets into your localization files.
|
Binary file
|
data/assets/favicon.ico
ADDED
Binary file
|
data/assets/icon.png
ADDED
Binary file
|
data/assets/logo.png
ADDED
Binary file
|
Binary file
|
data/bin/zwr
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
@options = {}
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = "Usage: zwr new PROJECT_NAME [options]"
|
8
|
+
|
9
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely, will print really a lot of output") do |v|
|
10
|
+
@options[:verbose] = v
|
11
|
+
end
|
12
|
+
|
13
|
+
@options[:bundle] = true
|
14
|
+
opts.on("--skip-bundle", %(Skip bundle install. This will speed up execution, but wil not
|
15
|
+
install missing gems. Useful only for debugging templates.)) do |v|
|
16
|
+
@options[:bundle] = not(v)
|
17
|
+
end
|
18
|
+
end.parse!
|
19
|
+
|
20
|
+
def putsv txt
|
21
|
+
puts txt.to_s if @options[:verbose]
|
22
|
+
end
|
23
|
+
|
24
|
+
putsv "Using options: #{@options}"
|
25
|
+
putsv "Executing command: #{ARGV}"
|
26
|
+
|
27
|
+
def show_usage
|
28
|
+
puts "Usage:"
|
29
|
+
puts ""
|
30
|
+
puts " zwr [new|deploy] app_name [options]"
|
31
|
+
end
|
32
|
+
|
33
|
+
case ARGV[0]
|
34
|
+
when 'new'
|
35
|
+
if ARGV.length < 2
|
36
|
+
puts "Not enough parameters"
|
37
|
+
puts ""
|
38
|
+
show_usage
|
39
|
+
elsif `git status 2>&1` != "fatal: Not a git repository (or any of the parent directories): .git\n"
|
40
|
+
puts "You are in a git repo, and that is not good!"
|
41
|
+
else
|
42
|
+
puts "creating and initializing new app #{ARGV[1]}"
|
43
|
+
`rails new #{ARGV[1]} --skip-bundle`
|
44
|
+
|
45
|
+
Dir.chdir ARGV[1]
|
46
|
+
putsv "Gemfile as we like it!"
|
47
|
+
|
48
|
+
`echo "gem 'zwr'" >> Gemfile`
|
49
|
+
`sed '/turbolinks/d' -i Gemfile`
|
50
|
+
`sed "s/# gem 'theruby/gem 'theruby/" -i Gemfile`
|
51
|
+
|
52
|
+
`echo "gem 'bootstrap-sass', '~> 3.2.0'" >> Gemfile`
|
53
|
+
#`echo "gem 'autoprefixer-rails', '~> 3.2.0'" >> Gemfile`
|
54
|
+
|
55
|
+
`echo "gem 'puma', platforms: :ruby" >> Gemfile`
|
56
|
+
`echo "gem 'haml-rails'" >> Gemfile`
|
57
|
+
`echo "gem 'angularjs-rails'" >> Gemfile`
|
58
|
+
`echo "gem 'angular-rails-templates'" >> Gemfile`
|
59
|
+
`echo "gem 'angular-ui-bootstrap-rails'" >> Gemfile`
|
60
|
+
`echo "# following should solve the CSRF token with angular" >> Gemfile`
|
61
|
+
`echo "gem 'angular_rails_csrf'" >> Gemfile`
|
62
|
+
`echo "gem 'devise', '~> 3.3.0'" >> Gemfile`
|
63
|
+
`echo "gem 'redcarpet'" >> Gemfile`
|
64
|
+
`echo "gem 'paperclip', '~> 4.2'" >> Gemfile`
|
65
|
+
`echo "gem 'html2haml'" >> Gemfile`
|
66
|
+
|
67
|
+
# Following are for Mongo only, will add it later
|
68
|
+
#gem 'mongoid', '~> 4.0.0.beta1',github: 'mongoid/mongoid'
|
69
|
+
#gem 'bson_ext'
|
70
|
+
|
71
|
+
`echo "gem 'factory_girl_rails', '~> 4.0'" >> Gemfile`
|
72
|
+
|
73
|
+
`echo "gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]" >> Gemfile`
|
74
|
+
`echo "gem 'tzinfo', platforms: [:mingw, :mswin, :x64_mingw]" >> Gemfile`
|
75
|
+
|
76
|
+
putsv "README as we like it!"
|
77
|
+
`rm README.rdoc`
|
78
|
+
`echo "Application #{ARGV[1]} generated bu the zwr generator." > README.markdown`
|
79
|
+
|
80
|
+
if @options[:bundle]
|
81
|
+
putsv "bundling up... This may take a few minutes..."
|
82
|
+
`bundle install`
|
83
|
+
end
|
84
|
+
putsv "zwring..."
|
85
|
+
`rake zwr:install`
|
86
|
+
putsv "git it up"
|
87
|
+
`git init`
|
88
|
+
`git add -A`
|
89
|
+
`git commit -sm "initial commit - zwr new #{ARGV[1]}"`
|
90
|
+
`git remote add origin git@github.com:zmilojko/#{ARGV[1]}.git`
|
91
|
+
putsv "database generation"
|
92
|
+
`rake db:migrate`
|
93
|
+
|
94
|
+
puts "Completed. If there was no errors above, you should be good to go!"
|
95
|
+
end
|
96
|
+
when 'deploy'
|
97
|
+
if ARGV.length < 2
|
98
|
+
puts "Not enough parameters"
|
99
|
+
puts ""
|
100
|
+
show_usage
|
101
|
+
elsif ENV['USER'] != "root"
|
102
|
+
puts "This script must be run as super user. Use sudo zwr deploy #{ARGV[2]}"
|
103
|
+
else
|
104
|
+
if File.directory? "/var/rails_apps/#{ARGV[2]}"
|
105
|
+
putsv "Updating existing #{ARGV[2]}"
|
106
|
+
Dir.chdir "/var/rails_apps/#{ARGV[1]}"
|
107
|
+
`git fetch`
|
108
|
+
`git checkout production`
|
109
|
+
`git reset --hard origin/production`
|
110
|
+
else
|
111
|
+
Dir.chdir "/var/rails_apps"
|
112
|
+
putsv "Deploying new project #{ARGV[2]}"
|
113
|
+
`git clone git@github.com:zmilojko/tst.git`
|
114
|
+
Dir.chdir "/var/rails_apps/#{ARGV[1]}"
|
115
|
+
`RAILS_ENV=production rake db:migrate`
|
116
|
+
`RAILS_ENV=production rake db:seed`
|
117
|
+
`RAILS_ENV=production rake db:seed`
|
118
|
+
`chmod 777 tmp -R`
|
119
|
+
`chmod 777 log`
|
120
|
+
`chmod 777 db`
|
121
|
+
`chmod 777 db/production.sqlite3`
|
122
|
+
end
|
123
|
+
`touch tmp/restart.txt`
|
124
|
+
end
|
125
|
+
else
|
126
|
+
show_usage
|
127
|
+
end
|
data/lib/tasks/zwr.rake
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'active_support'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
|
4
|
+
namespace :zwr do
|
5
|
+
ASSETS_FOLDER = File.realpath( File.dirname( __FILE__ ) + '/../../assets')
|
6
|
+
|
7
|
+
desc "installs zwr gem and features into a new app"
|
8
|
+
task :install do
|
9
|
+
puts "placing default favicon"
|
10
|
+
FileUtils.cp "#{ASSETS_FOLDER}/favicon.ico", Rails.root.join('public')
|
11
|
+
|
12
|
+
puts "removing turbolinks"
|
13
|
+
`sed "s|, 'data-turbolinks-track' => true||" -i #{Rails.root.join('app/views/layouts/application.html.erb')}`
|
14
|
+
`html2haml app/views/layouts/application.html.erb > app/views/layouts/application.html.haml`
|
15
|
+
File.delete Rails.root.join('app/views/layouts/application.html.erb')
|
16
|
+
File.delete Rails.root.join('app/assets/javascripts/application.js')
|
17
|
+
File.write(Rails.root.join('app/assets/javascripts/app.js.coffee'), <<-FILE_CONTENT.strip_heredoc)
|
18
|
+
#= require angular
|
19
|
+
#= require angular-route
|
20
|
+
#= require angular-resource
|
21
|
+
#= require angular-rails-templates
|
22
|
+
#= require_tree ./templates
|
23
|
+
#= require main
|
24
|
+
#= require_tree ./includes
|
25
|
+
#= require_tree ./directives
|
26
|
+
#= require_tree ./services
|
27
|
+
#= require_tree ./controllers
|
28
|
+
#= require angular-ui-bootstrap
|
29
|
+
FILE_CONTENT
|
30
|
+
File.write(Rails.root.join('app/assets/javascripts/application.js.coffee'),<<-FILE_CONTENT.strip_heredoc)
|
31
|
+
#= require jquery
|
32
|
+
#= require jquery_ujs
|
33
|
+
#= require bootstrap-sprockets
|
34
|
+
FILE_CONTENT
|
35
|
+
File.delete Rails.root.join('app/assets/stylesheets/application.css')
|
36
|
+
File.write(Rails.root.join('app/assets/stylesheets/application.css.scss'),<<-FILE_CONTENT.strip_heredoc)
|
37
|
+
/*
|
38
|
+
*= require_tree .
|
39
|
+
*= require_self
|
40
|
+
*/
|
41
|
+
@import "bootstrap-sprockets";
|
42
|
+
@import "bootstrap";
|
43
|
+
FILE_CONTENT
|
44
|
+
File.write(Rails.root.join('db/seeds.rb'),<<-FILE_CONTENT.strip_heredoc)
|
45
|
+
Dir[Rails.root.join('db/seeds/*.rb')].each { |file| load file }
|
46
|
+
FILE_CONTENT
|
47
|
+
Dir.mkdir Rails.root.join('db/seeds')
|
48
|
+
File.write(Rails.root.join('config/initializers/markdown.rb'),<<-FILE_CONTENT.strip_heredoc)
|
49
|
+
# Initializes a Markdown parser
|
50
|
+
Markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, tables: true)
|
51
|
+
FILE_CONTENT
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "prepares production branch ready to roll"
|
55
|
+
task :prepare do
|
56
|
+
Dir.chdir Rails.root
|
57
|
+
git_status = `git status`
|
58
|
+
unless git_status.downcase.include?("on branch master") &&
|
59
|
+
git_status.downcase.include?("nothing to commit, working directory clean")
|
60
|
+
puts "Commit all changes and make sure you are on the master branch."
|
61
|
+
else
|
62
|
+
branches = `git branch`
|
63
|
+
unless branches.include?("production")
|
64
|
+
`sed "s|serve_static_assets = false|serve_static_assets = true|" -i #{Rails.root.join('config/environments/production.rb')}`
|
65
|
+
`sed "s/.*# config.secret_key.*/ config.secret_key = '#{SecureRandom.hex(64)}'/" -i #{Rails.root.join('config/initializers/devise.rb')}`
|
66
|
+
`sed 's|... ENV..SECRET_KEY_BASE.. ..|#{SecureRandom.hex(64)}|' -i #{Rails.root.join('config/secrets.yml')}`
|
67
|
+
`git commit -asm "zwr deployment modifications"`
|
68
|
+
`chmod 777 tmp -R`
|
69
|
+
`chmod 777 log`
|
70
|
+
`chmod 777 db`
|
71
|
+
`git branch production`
|
72
|
+
`git checkout production`
|
73
|
+
else
|
74
|
+
`git checkout production`
|
75
|
+
`git reset --hard master`
|
76
|
+
end
|
77
|
+
Rails.env = "production"
|
78
|
+
Rake::Task["assets:precompile"].reenable
|
79
|
+
Rake::Task["assets:precompile"].invoke
|
80
|
+
`git add -A`
|
81
|
+
`git commit -asm "precompiled resources"`
|
82
|
+
`git push -u origin master`
|
83
|
+
`git push -uf origin production`
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/lib/zwr/railtie.rb
CHANGED
data/zwr.gemspec
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'zwr'
|
3
|
+
s.version = '0.0.4'
|
4
|
+
s.date = '2014-10-26'
|
5
|
+
s.summary = "All the Zwr needs"
|
6
|
+
s.description = "A gem in which I jam what I commonly use."
|
7
|
+
s.authors = ["Zeljko"]
|
8
|
+
s.email = 'zeljko@zwr.fi'
|
9
|
+
s.files = `git ls-files`.split("\n") - %w(.rvmrc .gitignore)
|
10
|
+
s.executables = ["zwr"]
|
11
|
+
s.homepage = 'http://rubygems.org/gems/zwr'
|
12
|
+
s.license = 'MIT'
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zwr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zeljko
|
@@ -12,13 +12,23 @@ date: 2014-10-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
13
13
|
description: A gem in which I jam what I commonly use.
|
14
14
|
email: zeljko@zwr.fi
|
15
|
-
executables:
|
15
|
+
executables:
|
16
|
+
- zwr
|
16
17
|
extensions: []
|
17
18
|
extra_rdoc_files: []
|
18
19
|
files:
|
20
|
+
- README.markdown
|
21
|
+
- assets/Z-ware_logo_C_big.png
|
22
|
+
- assets/favicon.ico
|
23
|
+
- assets/icon.png
|
24
|
+
- assets/logo.png
|
25
|
+
- assets/logo_transparent.png
|
26
|
+
- bin/zwr
|
19
27
|
- lib/tasks/loc.rake
|
28
|
+
- lib/tasks/zwr.rake
|
20
29
|
- lib/zwr.rb
|
21
30
|
- lib/zwr/railtie.rb
|
31
|
+
- zwr.gemspec
|
22
32
|
homepage: http://rubygems.org/gems/zwr
|
23
33
|
licenses:
|
24
34
|
- MIT
|