orats 0.6.4 → 0.6.5

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: d4bc22e389f267cb7c91d4081a11145f69d59297
4
- data.tar.gz: 0454520ee8678acdf340bdcbc634177341fef0e3
3
+ metadata.gz: 66a58907a4dafd0eb57bc65c7f12e02524679c39
4
+ data.tar.gz: df5a93aa96dc07b40fa3ebf212e4a1c96b9af7f5
5
5
  SHA512:
6
- metadata.gz: cb75ed8fe941ddda50d5ef7672c33e6a23057e5cb72deb5fe52214e6a6edb83630debd7890de2c53ee1a866d58b1f70611121519a9e9e8f049546ea034519fae
7
- data.tar.gz: ac83b57976aef1165be7fefc093d6995b47fec97ac16db99987e3fe1675fda6f4720c542a3e96c1f1e51feb528acc6d78c5bb4ee491760e0c3de4b221db027e3
6
+ metadata.gz: c30c65f3f67960fad4bd4b3d6e84e494234e672067cc77bb9c198210d0178a82bd359b012fe358af4c62813738df3b74a91134f76a770752a2bd3ac63bdf6980
7
+ data.tar.gz: b85fe941237de1008c6b72fa388b42946fd444ab14be0cca0d03af2f06c38e6ce7836eb2919895773caa8d17a1302f4e8b2de8e4c9d9d72f3c76d93add1f785e
data/README.md CHANGED
@@ -2,16 +2,13 @@
2
2
 
3
3
  ## What is orats and what problem does it solve?
4
4
 
5
- It stands for opinionated rails application templates. The templates include solving tedious tasks that you would do for most
6
- projects. It handles creating a rails application with a bunch of opinions and optionally an ansible inventory/playbook so you can
7
- and provision your servers and deploy your apps effortlessly.
5
+ It stands for opinionated rails application templates. The templates include solving tedious tasks that you would do for most projects. It handles creating a rails application with a bunch of opinions and optionally an ansible inventory/playbook so you can and provision your servers and deploy your apps effortlessly.
8
6
 
9
7
  ## What version of Rails and Ruby are you targeting?
10
8
 
11
9
  #### Rails 4.1.x and Ruby 2.1.x
12
10
 
13
- Gems will also be updated once they are proven to work on the target rails/ruby versions. The gems are locked using the
14
- pessimistic operator `~>` to ensure your installation works over time as long as rubygems.org's API is working.
11
+ Gems will also be updated once they are proven to work on the target rails/ruby versions. The gems are locked using the pessimistic operator `~>` to ensure your installation works over time as long as rubygems.org's API is working.
15
12
 
16
13
  ## Contents
17
14
  - [System dependencies](#system-dependencies)
@@ -34,7 +31,7 @@ pessimistic operator `~>` to ensure your installation works over time as long as
34
31
  - [Ansible roles](#ansible-roles-used)
35
32
  - [Wiki](https://github.com/nickjj/orats/wiki)
36
33
  - [What to look at after making a new project](https://github.com/nickjj/orats/wiki/What-to-look-at-after-making-a-new-project)
37
- - [Create a project and provision a server](https://github.com/nickjj/orats/wiki/Create-a-project-and-provision-a-server)
34
+ - [Get your application on a server](https://github.com/nickjj/orats/wiki/Get-your-application-on-a-server)
38
35
 
39
36
  ## System dependencies
40
37
 
@@ -68,8 +65,7 @@ Or if you already have orats then run `gem update orats` to upgrade to the lates
68
65
 
69
66
  ## Commands
70
67
 
71
- Here is an overview of the available commands. You can find out more information about each command and flag by running
72
- `orats help <command name>` from your terminal. You can also type `orats` on its own to see a list of all commands.
68
+ Here is an overview of the available commands. You can find out more information about each command and flag by running `orats help <command name>` from your terminal. You can also type `orats` on its own to see a list of all commands.
73
69
 
74
70
  - **Create a new orats project**:
75
71
  - `orats new <TARGET_PATH> --pg-password=foo`
@@ -106,13 +102,11 @@ Here is an overview of the available commands. You can find out more information
106
102
 
107
103
  ### Base
108
104
 
109
- This is the starter template that every other template will append to. I feel like when I make a new project, 95% of the time
110
- it includes these features and when I do not want a specific thing it is much quicker to remove it than add it.
105
+ This is the starter template that every other template will append to. I feel like when I make a new project, 95% of the time it includes these features and when I do not want a specific thing it is much quicker to remove it than add it.
111
106
 
112
107
  #### Changes vs the standard rails project
113
108
 
114
- All of the changes have git commits to go with them. After generating a project you can type `git reflog` to get a
115
- list of changes.
109
+ All of the changes have git commits to go with them. After generating a project you can type `git reflog` to get a list of changes.
116
110
 
117
111
  - **Core changes**:
118
112
  - Use `postgres` as the primary SQL database
@@ -163,27 +157,21 @@ list of changes.
163
157
 
164
158
  `orats new myapp --pg-password=foo --skip-galaxy`
165
159
 
160
+ #### Base FAQ
161
+
166
162
  ##### What is `--pg-password`?
167
163
 
168
- Orats will automatically start your server (you can turn this off with a flag) and also run database migrations or
169
- generators depending on what you're doing.
164
+ Orats will automatically start your server (you can turn this off with a flag) and also run database migrations or generators depending on what you're doing.
170
165
 
171
- In order to do this it must know your postgres location, username and password. By default it will use localhost for the
172
- *location* and *postgres* as the username but if you need to supply those values because yours are different you can use
173
- `--pg-location=foo` and `--pg-username=bar`.
166
+ In order to do this it must know your postgres location, username and password. By default it will use localhost for the *location* and *postgres* as the username but if you need to supply those values because yours are different you can use `--pg-location=foo` and `--pg-username=bar`.
174
167
 
175
168
  ##### What is `--skip-galaxy`?
176
169
 
177
- By default the new command will generate ansible related files for you so that you can manage this app's "inventory". It
178
- also automatically downloads the ansible roles from the [ansible galaxy](https://galaxy.ansible.com/).
170
+ By default the new command will generate ansible related files for you so that you can manage this app's "inventory". It also automatically downloads the ansible roles from the [ansible galaxy](https://galaxy.ansible.com/).
179
171
 
180
- This was done to ensure each app you create has the correct ansible role version to go with it. However, if you installed
181
- ansible through apt or somewhere outside of your home directory then you will get permissions errors when it tries to
182
- download the roles.
172
+ This was done to ensure each app you create has the correct ansible role version to go with it. However, if you installed ansible through apt or somewhere outside of your home directory then you will get permissions errors when it tries to download the roles.
183
173
 
184
- You can fix this by supplying `--sudo-password=foo` to the above command if you know ansible is installed outside of your
185
- home directory or you can just wait while the command runs and it will prompt you for your sudo password when it gets
186
- to that point because orats will attempt to use sudo only after it fails trying to install the roles without sudo.
174
+ You can fix this by supplying `--sudo-password=foo` to the above command if you know ansible is installed outside of your home directory or you can just wait while the command runs and it will prompt you for your sudo password when it gets to that point because orats will attempt to use sudo only after it fails trying to install the roles without sudo.
187
175
 
188
176
  If you don't care about the ansible at all you could add `--skip-extras` to not generate any ansible files.
189
177
 
@@ -191,8 +179,6 @@ If you don't care about the ansible at all you could add `--skip-extras` to not
191
179
 
192
180
  If your redis server is configured to use a password then you must also pass in `--redis-password=foo`.
193
181
 
194
- #### Base FAQ
195
-
196
182
  ##### What's with the directory structure?
197
183
 
198
184
  Let's say you were to generate a new project at *~/tmp/myapp*, then you would get the following paths:
@@ -203,38 +189,29 @@ Let's say you were to generate a new project at *~/tmp/myapp*, then you would ge
203
189
  ~/tmp/myapp/services
204
190
  ```
205
191
 
206
- The **inventory** path contains the ansible inventory files for this project. This would be where your host addresses go
207
- along with configuration settings for this project.
192
+ The **inventory** path contains the ansible inventory files for this project. This would be where your host addresses go along with configuration settings for this project.
208
193
 
209
- The **secrets** path contains the passwords for various things as well as ssh keypairs and ssl certificates. This path
210
- should be kept out of version control. You could also go 1 extra step and encrypt this directory locally.
194
+ The **secrets** path contains the passwords for various things as well as ssh keypairs and ssl certificates. This path should be kept out of version control. You could also go 1 extra step and encrypt this directory locally.
211
195
 
212
- The **services** path contains your rails application. I like to call it services because you might have multiple services
213
- in 1 project.
196
+ The **services** path contains your rails application. I like to call it services because you might have multiple services in 1 project.
214
197
 
215
- If you run the command with `--skip-extras` you will not get the inventory, secrets or services directory. It will just
216
- generate `myapp` at the path you specify.
198
+ If you run the command with `--skip-extras` you will not get the inventory, secrets or services directory. It will just generate `myapp` at the path you specify.
217
199
 
218
200
  <a name="base-what-do-i-need-to-configure-for-development"></a>
219
201
  ##### What do I need to configure for development?
220
202
 
221
- Pretty much everything is contained within environment variables. They are stored in the `.env` file located in the root
222
- directory of the rails application. It should be self explanatory. This file is also added to `.gitignore`.
203
+ Pretty much everything is contained within environment variables. They are stored in the `.env` file located in the root directory of the rails application. It should be self explanatory. This file is also added to `.gitignore`.
223
204
 
224
205
  <a name="base-what-do-i-need-to-configure-for-production"></a>
225
206
  ##### What do I need to configure for production?
226
207
 
227
- If you are using ansible then you should open `inventory/group_vars/all.yml` and take a peek. Everything there has
228
- comments. Assuming you have everything hosted on 1 server then at minimum you will only need to change
229
- `rails_deploy_git_url` to get going.
208
+ If you are using ansible then you should open `inventory/group_vars/all.yml` and take a peek. Everything there has comments. Assuming you have everything hosted on 1 server then at minimum you will only need to change `rails_deploy_git_url` to get going.
230
209
 
231
210
  The above variable is the repo where your code is contained. Ansible will clone that repo in an idempotent way.
232
211
 
233
- You will also need to put the correct server IP(s) in `inventory/hosts`. At this point that's all you need to change to
234
- successfully provision a server.
212
+ You will also need to put the correct server IP(s) in `inventory/hosts`. At this point that's all you need to change to successfully provision a server.
235
213
 
236
- There are many other variables that you would likely change too such as adding your google analytics UA, S3 keys and
237
- all of the mail settings.
214
+ There are many other variables that you would likely change too such as adding your google analytics UA, S3 keys and all of the mail settings.
238
215
 
239
216
  You may also want to tinker with the following values for performance reasons based on your server(s).
240
217
 
@@ -252,13 +229,11 @@ You may also want to tinker with the following values for performance reasons ba
252
229
 
253
230
  ### Auth
254
231
 
255
- This is the auth template which gets merged into the base template. It contains a basic authentication setup using
256
- devise and pundit.
232
+ This is the auth template which gets merged into the base template. It contains a basic authentication setup using devise and pundit.
257
233
 
258
234
  #### Changes vs the base template
259
235
 
260
- All of the changes have git commits to go with them. After generating a project you can type `git reflog` to get a
261
- list of changes.
236
+ All of the changes have git commits to go with them. After generating a project you can type `git reflog` to get a list of changes.
262
237
 
263
238
  - **Core**:
264
239
  - Handle authentication with `devise`
@@ -300,12 +275,12 @@ list of changes.
300
275
 
301
276
  `orats new myauthapp --auth --pg-password=foo --skip-galaxy`
302
277
 
278
+ #### Auth FAQ
279
+
303
280
  ##### What do those flags do?
304
281
 
305
282
  You should read the [try the base template](#try-the-base-template) section to get an idea of what they do.
306
283
 
307
- #### Auth FAQ
308
-
309
284
  <a name="auth-what-do-i-need-to-configure-for-development"></a>
310
285
  ##### What do I need to configure for development?
311
286
 
@@ -318,17 +293,13 @@ You will want to change `ACTION_MAILER_DEVISE_DEFAULT_FROM` in `inventory/group_
318
293
 
319
294
  ### Play
320
295
 
321
- Building your application is only one piece of the puzzle. If you want to ship your application you have to host it somewhere.
322
- You have a few options when it comes to managed hosts like Heroku but they tend to be very expensive if you fall out of
323
- their free tier.
296
+ Building your application is only one piece of the puzzle. If you want to ship your application you have to host it somewhere. You have a few options when it comes to managed hosts like Heroku but they tend to be very expensive if you fall out of their free tier.
324
297
 
325
- The playbook template creates an ansible playbook that will provision a **ubuntu 12.04 LTS server**. It can be hosted anywhere
326
- as there are no hard requirements on any specific host.
298
+ The playbook template creates an ansible playbook that will provision a **ubuntu 12.04 LTS server**. It can be hosted anywhere as there are no hard requirements on any specific host.
327
299
 
328
300
  #### Server breakdown
329
301
 
330
- Everything is broken up into ansible roles so you can quickly scale out horizontally or by splitting up your server groups
331
- such that your database is on a separate server than your application.
302
+ Everything is broken up into ansible roles so you can quickly scale out horizontally or by splitting up your server groups such that your database is on a separate server than your application.
332
303
 
333
304
  - **Security**:
334
305
  - Logging into the server is only possible with an ssh key
data/lib/orats/cli.rb CHANGED
@@ -53,6 +53,7 @@ module Orats
53
53
 
54
54
  `--skip-galaxy` skip automatically installing roles from the galaxy [false]
55
55
  D
56
+
56
57
  def new(target_path)
57
58
  Commands::New::Exec.new(target_path, options).init
58
59
  end
@@ -66,6 +67,7 @@ module Orats
66
67
 
67
68
  `--template` will let you supply a custom template, a url or file is ok but urls must start with http or https []
68
69
  D
70
+
69
71
  def play(target_path)
70
72
  Commands::Play.new(target_path, options).init
71
73
  end
@@ -82,6 +84,7 @@ module Orats
82
84
 
83
85
  `--redis-password` to supply your development redis password []
84
86
  D
87
+
85
88
  def nuke(target_path)
86
89
  Commands::Nuke.new(target_path, options).init
87
90
  end
@@ -104,6 +107,7 @@ module Orats
104
107
 
105
108
  `--inventory` to supply an inventory file for comparison []
106
109
  D
110
+
107
111
  def outdated
108
112
  Commands::Outdated::Exec.new(nil, options).init
109
113
  end
@@ -112,15 +116,17 @@ module Orats
112
116
  long_desc <<-D
113
117
  `orats version` will print the current version.
114
118
  D
119
+
115
120
  def version
116
121
  puts "Orats version #{VERSION}"
117
122
  end
123
+
118
124
  map %w(-v --version) => :version
119
125
 
120
126
  private
121
127
 
122
- def invoked?
123
- caller_locations(0).any? { |backtrace| backtrace.label == 'invoke' }
124
- end
128
+ def invoked?
129
+ caller_locations(0).any? { |backtrace| backtrace.label == 'invoke' }
130
+ end
125
131
  end
126
132
  end
@@ -12,26 +12,26 @@ module Orats
12
12
 
13
13
  RELATIVE_PATHS = {
14
14
  galaxyfile: 'templates/includes/Galaxyfile',
15
- hosts: 'templates/includes/inventory/hosts',
16
- inventory: 'templates/includes/inventory/group_vars/all.yml',
17
- playbook: 'templates/play.rb',
18
- version: 'version.rb'
15
+ hosts: 'templates/includes/inventory/hosts',
16
+ inventory: 'templates/includes/inventory/group_vars/all.yml',
17
+ playbook: 'templates/play.rb',
18
+ version: 'version.rb'
19
19
  }
20
20
 
21
21
  attr_accessor :remote_gem_version, :remote_paths, :local_paths
22
22
 
23
23
  def initialize(target_path = '', options = {})
24
24
  @target_path = target_path
25
- @options = options
25
+ @options = options
26
26
  @active_path = @target_path
27
27
 
28
- @local_paths = {}
28
+ @local_paths = {}
29
29
  @remote_paths = {}
30
30
 
31
31
  build_common_paths
32
32
 
33
33
  self.destination_root = Dir.pwd
34
- @behavior = :invoke
34
+ @behavior = :invoke
35
35
  end
36
36
 
37
37
  private
@@ -50,10 +50,10 @@ module Orats
50
50
 
51
51
  def build_common_paths
52
52
  @remote_paths[:version] = select_branch 'master', RELATIVE_PATHS[:version]
53
- @remote_gem_version = gem_version
53
+ @remote_gem_version = gem_version
54
54
 
55
55
  RELATIVE_PATHS.each_pair do |key, value|
56
- @local_paths[key] = "#{base_path}/#{value}"
56
+ @local_paths[key] = "#{base_path}/#{value}"
57
57
  @remote_paths[key] = select_branch @remote_gem_version, value
58
58
  end
59
59
  end
@@ -91,13 +91,13 @@ module Orats
91
91
  case check_for
92
92
  when :not_found
93
93
  command = 'which'
94
- phrase = 'on your system path'
94
+ phrase = 'on your system path'
95
95
  when :not_running
96
96
  command = 'ps cax | grep'
97
- phrase = 'running'
97
+ phrase = 'running'
98
98
  else
99
99
  command = ''
100
- phrase = ''
100
+ phrase = ''
101
101
  end
102
102
 
103
103
  processes.each do |process|
@@ -118,4 +118,4 @@ module Orats
118
118
  end
119
119
  end
120
120
  end
121
- end
121
+ end
@@ -24,6 +24,7 @@ module Orats
24
24
  gsub_postgres_info
25
25
  gsub_redis_info unless @options[:redis_password].empty?
26
26
  gsub_project_path
27
+ gsub_readme
27
28
 
28
29
  bundle_install
29
30
  bundle_binstubs
@@ -50,7 +51,8 @@ module Orats
50
51
  private
51
52
 
52
53
  def services_path
53
- @options[:skip_extras] ? @target_path : "#{@target_path}/services/#{File.basename @target_path}"
54
+ @options[:skip_extras] ? @target_path
55
+ : "#{@target_path}/services/#{File.basename @target_path}"
54
56
  end
55
57
  end
56
58
  end
@@ -19,7 +19,7 @@ module Orats
19
19
  log_task 'Run custom rails template'
20
20
 
21
21
  @options[:template].include?('://') ? url_to_string(@options[:template])
22
- : file_to_string(@options[:template])
22
+ : file_to_string(@options[:template])
23
23
 
24
24
  rails_template '', "--skip --template #{@options[:template]}"
25
25
  end
@@ -48,6 +48,13 @@ module Orats
48
48
  git_commit 'Update the project path'
49
49
  end
50
50
 
51
+ def gsub_readme
52
+ log_task 'Update the readme'
53
+ gsub_file "#{@active_path}/README.md", 'VERSION', VERSION
54
+
55
+ git_commit 'Update the version'
56
+ end
57
+
51
58
  def bundle_install
52
59
  log_task 'Run bundle install, this may take a while'
53
60
  run_from @active_path, 'bundle install'
@@ -79,16 +86,18 @@ module Orats
79
86
  log_task 'Add pages controller with static page'
80
87
  run_from @active_path, 'bundle exec rails g controller Pages home'
81
88
 
82
- gsub_file "#{@active_path}/config/routes.rb", " # root 'welcome#index'" do <<-S
89
+ gsub_file "#{@active_path}/config/routes.rb", " # root 'welcome#index'" do
90
+ <<-S
83
91
  root 'pages#home'
84
- S
92
+ S
85
93
  end
86
94
  gsub_file "#{@active_path}/config/routes.rb", " get 'pages/home'\n\n", ''
87
95
 
88
96
  gsub_file "#{@active_path}/test/controllers/pages_controller_test.rb",
89
97
  '"should get home"', "'expect home page'"
90
98
  gsub_file "#{@active_path}/app/views/pages/home.html.erb", /.*\n/, ''
91
- append_file "#{@active_path}/app/views/pages/home.html.erb" do <<-S
99
+ append_file "#{@active_path}/app/views/pages/home.html.erb" do
100
+ <<-S
92
101
  <%
93
102
  title 'Welcome to Ruby on Rails'
94
103
  meta_description '...'
@@ -160,7 +169,7 @@ module Orats
160
169
  <%= image_tag '/apple-touch-icon-228x228-precomposed.png', size: '228x228', alt: 'A ruby image I found on Google' %>
161
170
  </div>
162
171
  </div>
163
- S
172
+ S
164
173
  end
165
174
  git_commit 'Add pages controller with home page'
166
175
  end
@@ -8,11 +8,11 @@ module Orats
8
8
  def server_start
9
9
  @options[:skip_server_start] ? message = 'Start your' : message = 'Starting'
10
10
 
11
- puts '', '='*80
11
+ puts '', '='*80
12
12
  log_status_top 'action', "#{message} server with the following commands", :cyan
13
13
  log_status_bottom 'command', "cd #{@active_path}", :magenta, true
14
14
  log_status_bottom 'command', 'bundle exec foreman start', :magenta
15
- puts '='*80, ''
15
+ puts '='*80, ''
16
16
 
17
17
  attempt_to_start
18
18
  end
@@ -8,10 +8,10 @@ module Orats
8
8
  end
9
9
 
10
10
  def remote_to_local_galaxyfiles
11
- galaxyfile_diff = @remote_galaxyfile - @local_galaxyfile
11
+ galaxyfile_diff = @remote_galaxyfile - @local_galaxyfile
12
12
  local_galaxyfile_as_string = @local_galaxyfile.join
13
- local_galaxyfile_roles = @local_galaxyfile.size
14
- roles_diff_count = galaxyfile_diff.size
13
+ local_galaxyfile_roles = @local_galaxyfile.size
14
+ roles_diff_count = galaxyfile_diff.size
15
15
 
16
16
  log_status_top 'roles', "Compare this version of orats' roles to the latest version:", :green
17
17
 
@@ -21,13 +21,13 @@ module Orats
21
21
  log_status_bottom 'message', "There are #{roles_diff_count} differences", :yellow
22
22
 
23
23
  galaxyfile_diff.each do |line|
24
- name = line.split(',').first
24
+ name = line.split(',').first
25
25
  status = 'outdated'
26
- color = :yellow
26
+ color = :yellow
27
27
 
28
28
  unless local_galaxyfile_as_string.include?(name)
29
29
  status = 'missing'
30
- color = :red
30
+ color = :red
31
31
  end
32
32
 
33
33
  log_status_bottom status, name, color, true
@@ -38,7 +38,7 @@ module Orats
38
38
  end
39
39
 
40
40
  def remote_to_local(label, keyword, remote, local)
41
- item_diff = remote - local
41
+ item_diff = remote - local
42
42
  item_diff_count = item_diff.size
43
43
 
44
44
  log_remote_info label, "Compare this version of orats' #{label} to the latest version",
@@ -63,7 +63,7 @@ module Orats
63
63
  'path', flag_path
64
64
 
65
65
  missing_count = log_unmatched(local, user, 'missing', :red)
66
- extra_count = log_unmatched(user, local, 'extra', :yellow)
66
+ extra_count = log_unmatched(user, local, 'extra', :yellow)
67
67
 
68
68
  if missing_count > 0
69
69
  log_results "#{missing_count} #{keyword} are missing",