zwr 0.1.1 → 0.1.2

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: 332a0129734efb42cbb5a1e0a7f585b39cb6b554
4
- data.tar.gz: d2d83a56c689f8459698dacb9ab50ca4c6f5a660
3
+ metadata.gz: bd8b8260623b9781b10b84b27234a20d94dcd487
4
+ data.tar.gz: 3da65509bd7b4444b7fa150a355bc4ce8b8c9ce4
5
5
  SHA512:
6
- metadata.gz: a3aa135df0bc04d4901ccb0c1a2b9ce42b28983c4788c1e4611ca9f6666b71deac29218982d8569b36cab50db67befc8d77edadbb9f93d7576fd99cab10db837
7
- data.tar.gz: 11c355f2f1743ef50100dacd09063fa583b532f7fdd743f0e1bcb050a9608ac56d222bec7a912b359c62f8744c7ce2c7e33063ed3ac76cd2ad6e32e89e8214fd
6
+ metadata.gz: 767a6522e1d4b35f58b7dcfae83b359652321bf5c484028e580e634530f3de200ad112bd49b73ebfcad396c7578b55249fc90c0f50b6ff7a4d1c769f75869519
7
+ data.tar.gz: 25018df64c4c11cc6eae8614f98a69d5c97f148705888a085bbaf69169546a436dd705363dec11a3931c934f52a14f85c0a002003987d2f44cab129929a5dee9
@@ -12,5 +12,5 @@
12
12
  }
13
13
 
14
14
  body {
15
- background: #F6F6F6 url(/assets/bg.png) repeat-x;
15
+ background: #F6F6F6 url(<%= asset_path 'bg.png' %>) repeat-x;
16
16
  }
data/bin/zwr CHANGED
@@ -8,6 +8,8 @@ require 'rake'
8
8
  @options = {}
9
9
  OptionParser.new do |opts|
10
10
  opts.banner = "Usage: zwr new PROJECT_NAME [options]"
11
+ opts.separator ""
12
+ opts.separator "Specific options:"
11
13
 
12
14
  opts.on("-v", "--[no-]verbose", "Run verbosely, will print really a lot of output") do |v|
13
15
  @options[:verbose] = v
@@ -18,6 +20,25 @@ OptionParser.new do |opts|
18
20
  install missing gems. Useful only for debugging templates.)) do |v|
19
21
  @options[:bundle] = not(v)
20
22
  end
23
+
24
+ @options[:activerecord] = true
25
+ opts.on("--skip-active-record", %(Skip activerecord. Use this if you will use Mongo.)) do |v|
26
+ @options[:activerecord] = not(v)
27
+ end
28
+
29
+ opts.on("-r", "--ruby RUBY_VER",
30
+ "Set ruby version in .rvmrc") do |ruby_ver|
31
+ @options[:ruby_ver] = ruby_ver
32
+ end
33
+
34
+ @options[:mongoid] = false
35
+ opts.on("--mongoid",
36
+ "Use MongoDB with Mongoid gem") do |v|
37
+ @options[:mongoid] = v
38
+ if @options[:mongoid]
39
+ @options[:activerecord] = false
40
+ end
41
+ end
21
42
  end.parse!
22
43
 
23
44
  def putsv txt
@@ -43,7 +64,7 @@ when 'new'
43
64
  puts "You are in a git repo, and that is not good!"
44
65
  else
45
66
  puts "creating and initializing new app #{ARGV[1]}"
46
- `rails new #{ARGV[1]} --skip-bundle`
67
+ putsv `rails new #{ARGV[1]} --skip-bundle --skip-spring #{"--skip-active-record" if not @options[:activerecord]}`
47
68
 
48
69
  Dir.chdir ARGV[1]
49
70
  putsv "Gemfile as we like it!"
@@ -68,8 +89,10 @@ when 'new'
68
89
  `echo "gem 'html2haml'" >> Gemfile`
69
90
 
70
91
  # Following are for Mongo only, will add it later
71
- #gem 'mongoid', '~> 4.0.0.beta1',github: 'mongoid/mongoid'
72
- #gem 'bson_ext'
92
+ if @options[:mongoid]
93
+ `echo "gem 'mongoid', '~> 4.0.0',github: 'mongoid/mongoid'" >> Gemfile`
94
+ `echo "gem 'bson_ext'" >> Gemfile`
95
+ end
73
96
 
74
97
  `echo "gem 'factory_girl_rails', '~> 4.0'" >> Gemfile`
75
98
 
@@ -77,28 +100,37 @@ when 'new'
77
100
  `echo "gem 'tzinfo', platforms: [:mingw, :mswin, :x64_mingw]" >> Gemfile`
78
101
 
79
102
  putsv "README as we like it!"
80
- `rm README.rdoc`
103
+ putsv `rm README.rdoc`
81
104
  `echo "Application #{ARGV[1]} generated bu the zwr generator." > README.markdown`
82
105
 
83
106
  if @options[:bundle]
84
107
  putsv "bundling up... This may take a few minutes..."
85
- `bundle install`
108
+ putsv `bundle install`
86
109
  end
87
110
  putsv "zwring..."
88
- puts `rake zwr:install`
89
- putsv "git it up"
90
- `git init`
91
- `git add -A`
92
- `git commit -sm "initial commit - zwr new #{ARGV[1]}"`
93
- `git remote add origin git@github.com:zmilojko/#{ARGV[1]}.git`
111
+ putsv `rake zwr:install`
112
+ if @options[:ruby_ver]
113
+ putsv "creating .ruby-version"
114
+ `rvm --ruby-version use #{@options[:ruby_ver]} >> .ruby-version`
115
+ end
116
+ if @options[:mongoid]
117
+ putsv "configuration for mongoid"
118
+ `rails g mongoid:config`
119
+ end
94
120
  putsv "database generation"
95
- `rake db:migrate`
121
+ putsv `rake db:migrate`
96
122
  putsv "praxing"
97
- `prax link`
98
- `prax start`
123
+ putsv `prax link`
124
+ putsv `prax start`
125
+ putsv "git it up"
126
+ putsv `git init`
127
+ putsv `git add -A`
128
+ putsv `git commit -sm "initial commit - zwr new #{ARGV[1]}"`
129
+ putsv `git remote add origin git@github.com:zmilojko/#{ARGV[1]}.git`
99
130
  puts "Completed. If there was no errors above, you should be good to go!"
100
131
  puts "In your browser, open http://#{ARGV[1]}.dev"
101
132
  end
133
+
102
134
  when 'deploy'
103
135
  if ARGV.length < 2
104
136
  puts "Not enough parameters"
@@ -1,6 +1,47 @@
1
1
  require 'active_support'
2
2
  require 'active_support/core_ext'
3
3
  require 'rake'
4
+ #require 'rails/generators'
5
+
6
+ class Pathname
7
+ def remove_line(line)
8
+ insert(text: "", instead_of: line)
9
+ end
10
+
11
+ # Will insert LINES after or instead of the LINE that matches given argument
12
+ def insert(text: nil, after: nil, instead_of: nil, before: nil, for_each_line: false)
13
+ raise "You must specify text: argument or give a block that will preform the writing" unless text or block_given?
14
+ raise "You cannot specify both after: and instead_of: arguments. Pick one." if after and instead_of
15
+ raise "You cannot specify both after: and before: arguments. Pick one." if after and before
16
+ raise "You cannot specify both instead_of: and before: arguments. Pick one." if instead_of and before
17
+ if after || instead_of || before
18
+ content = File.read(self)
19
+ File.open(self, "w") do |file|
20
+ content.lines.each do |line|
21
+ if line.match(after || instead_of || before)
22
+ file.puts line if after
23
+ if text
24
+ file.puts text if text != ""
25
+ else
26
+ yield file, line
27
+ end
28
+ file.puts line if before
29
+ else
30
+ file.puts line
31
+ end
32
+ end
33
+ end
34
+ else
35
+ File.open(self, "a") do |file|
36
+ if text
37
+ file.puts text
38
+ else
39
+ yield file
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
4
45
 
5
46
  namespace :zwr do
6
47
  desc "installs zwr gem and features into a new app"
@@ -93,6 +134,10 @@ namespace :zwr do
93
134
  %a(href="#") Right 1
94
135
  %li
95
136
  %a(href="#") Right 2
137
+ .alert.alert-success(role="alert")=success_notice
138
+ .alert.alert-info(role="alert")=notice
139
+ .alert.alert-warning(role="alert")=alert_warning
140
+ .alert.alert-danger(role="alert")=alert
96
141
  = yield
97
142
  FILE_CONTENT
98
143
  File.delete Rails.root.join('app/assets/javascripts/application.js')
@@ -121,7 +166,7 @@ namespace :zwr do
121
166
  */
122
167
  @import "bootstrap-sprockets";
123
168
  @import "bootstrap";
124
- @import "zwr"
169
+ @import "zwr";
125
170
  FILE_CONTENT
126
171
  File.write(Rails.root.join('db/seeds.rb'),<<-FILE_CONTENT.strip_heredoc)
127
172
  Dir[Rails.root.join('db/seeds/*.rb')].each { |file| load file }
@@ -165,4 +210,55 @@ namespace :zwr do
165
210
  `git push -uf origin production`
166
211
  end
167
212
  end
213
+ desc "creates user scaffod and devise object"
214
+ task :user do
215
+ #Rails::Generators.invoke("devise:install")
216
+ puts `rails g devise:install`
217
+ #Rails::Generators.invoke("scaffold",["User", "name:string","email:string",
218
+ # "password:string","password_confirmation:string",
219
+ # "admin:boolean"])
220
+ puts `rails g scaffold User name:string email:string password:string password_confirmation:string admin:boolean`
221
+ puts "Removing app/models/user.rb"
222
+ File.delete Rails.root.join('app/models/user.rb')
223
+ puts "Renaming test/models/user_test.rb to test/models/user_test_orig.rb"
224
+ File.rename Rails.root.join('test/models/user_test.rb'), Rails.root.join('test/models/user_test_orig.rb')
225
+ puts "Removing test/factories/users.rb"
226
+ File.delete Rails.root.join('test/factories/users.rb')
227
+ #Rails::Generators.invoke("devise", ["User"])
228
+ puts `rails g devise User`
229
+ Rails.root.join("Gemfile").insert text: "gem 'bootstrap_form'"
230
+ Rails.root.join("app/assets/stylesheets/application.css.scss").insert text: '@import "rails_bootstrap_forms";'
231
+ Rails.root.join("app/models/user.rb").insert after: "field :encrypted_password" do |file|
232
+ file.puts ' field :name, type: String, default: ""'
233
+ file.puts ' field :admin, type: Boolean, default: ""'
234
+ end
235
+ Rails.root.join("app/views/layouts/application.html.haml").insert before: "= yield" do |file|
236
+ file.puts ' - if notice'
237
+ file.puts ' .alert.alert-info(role="alert")=notice'
238
+ file.puts ' - if alert'
239
+ file.puts ' .alert.alert-danger(role="alert")=alert'
240
+ end
241
+ Rails.root.join("app/views/users/_form.html.haml").insert text: "= bootstrap_form_for @user do |f|",
242
+ instead_of: "form_for @user do"
243
+ Rails.root.join("app/views/users/_form.html.haml").insert text: " #error_explanation.alert.alert-danger",
244
+ instead_of: "error_explanation"
245
+ Rails.root.join("app/views/users/_form.html.haml").insert text: " = f.password_field :password_confirmation",
246
+ instead_of: "f.text_field :password_confirmation"
247
+ Rails.root.join("app/views/users/_form.html.haml").insert text: " = f.password_field :password",
248
+ instead_of: "f.text_field :password"
249
+ Rails.root.join("app/views/users/_form.html.haml").remove_line "f.label :name"
250
+ Rails.root.join("app/views/users/_form.html.haml").remove_line "f.label :email"
251
+ Rails.root.join("app/views/users/_form.html.haml").remove_line "f.label :password"
252
+ Rails.root.join("app/views/users/_form.html.haml").remove_line "f.label :password_confirmation"
253
+ Rails.root.join("app/views/users/_form.html.haml").remove_line "f.label :admin"
254
+ Rails.root.join("config/routes.rb").insert instead_of: "resources :users" do |file|
255
+ file.puts " scope '/admin' do"
256
+ file.puts " resources :users, as: 'users'"
257
+ file.puts " end"
258
+ end
259
+ puts `bundle install`
260
+ puts `git add -A`
261
+ puts `git commit -sm "rake zwr:user"`
262
+ puts `prax restart`
263
+ end
168
264
  end
@@ -4,9 +4,9 @@ module Zwr
4
4
  class Railtie < Rails::Railtie
5
5
  railtie_name :zwr
6
6
 
7
- rake_tasks do
8
- Dir[File.join(File.dirname(__FILE__),'../tasks/*.rake')].each { |f| load f }
9
- end
7
+ #rake_tasks do
8
+ # Dir[File.join(File.dirname(__FILE__),'../tasks/*.rake')].each { |f| load f }
9
+ #end
10
10
 
11
11
  # Following will allow us to use something like the following
12
12
  # also in the javascript HAML templates:
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'zwr'
3
- s.version = '0.1.1'
3
+ s.version = '0.1.2'
4
4
  s.date = '2014-10-26'
5
5
  s.summary = "All the Zwr needs"
6
6
  s.description = "A gem in which I jam what I commonly use."
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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zeljko
@@ -46,7 +46,7 @@ files:
46
46
  - app/assets/images/logo.png
47
47
  - app/assets/images/logo.xcf
48
48
  - app/assets/images/logo_transparent.png
49
- - app/assets/stylesheets/zwr.css.scss
49
+ - app/assets/stylesheets/zwr.css.scss.erb
50
50
  - bin/zwr
51
51
  - lib/tasks/loc.rake
52
52
  - lib/tasks/zwr.rake