orats 0.7.3 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +1 -1
  4. data/{LICENSE.txt → LICENSE} +21 -21
  5. data/README.md +51 -346
  6. data/Rakefile +1 -1
  7. data/bin/orats +5 -2
  8. data/lib/orats/argv_adjust.rb +61 -0
  9. data/lib/orats/cli.rb +53 -141
  10. data/lib/orats/cli_help/new +27 -0
  11. data/lib/orats/cli_help/nuke +19 -0
  12. data/lib/orats/commands/new/exec.rb +59 -0
  13. data/lib/orats/commands/new/rails.rb +197 -0
  14. data/lib/orats/commands/new/server.rb +67 -0
  15. data/lib/orats/commands/nuke.rb +66 -44
  16. data/lib/orats/common.rb +76 -0
  17. data/lib/orats/postgres.rb +90 -0
  18. data/lib/orats/process.rb +35 -0
  19. data/lib/orats/redis.rb +25 -0
  20. data/lib/orats/shell.rb +12 -0
  21. data/lib/orats/templates/auth.rb +96 -82
  22. data/lib/orats/templates/base.rb +115 -110
  23. data/lib/orats/templates/includes/new/rails/.env +28 -28
  24. data/lib/orats/templates/includes/new/rails/Gemfile +4 -4
  25. data/lib/orats/templates/includes/new/rails/config/{whenever.rb → schedule.rb} +0 -0
  26. data/lib/orats/ui.rb +33 -0
  27. data/lib/orats/version.rb +3 -2
  28. data/lib/orats.rb +2 -1
  29. data/orats.gemspec +7 -5
  30. data/test/integration/cli_test.rb +28 -177
  31. data/test/test_helper.rb +24 -9
  32. metadata +17 -29
  33. data/lib/orats/commands/common.rb +0 -146
  34. data/lib/orats/commands/diff/compare.rb +0 -106
  35. data/lib/orats/commands/diff/exec.rb +0 -60
  36. data/lib/orats/commands/diff/parse.rb +0 -66
  37. data/lib/orats/commands/inventory.rb +0 -100
  38. data/lib/orats/commands/playbook.rb +0 -60
  39. data/lib/orats/commands/project/exec.rb +0 -74
  40. data/lib/orats/commands/project/rails.rb +0 -162
  41. data/lib/orats/commands/project/server.rb +0 -57
  42. data/lib/orats/commands/role.rb +0 -70
  43. data/lib/orats/commands/ui.rb +0 -47
  44. data/lib/orats/templates/includes/inventory/group_vars/all.yml +0 -202
  45. data/lib/orats/templates/includes/inventory/hosts +0 -8
  46. data/lib/orats/templates/includes/playbook/Galaxyfile +0 -15
  47. data/lib/orats/templates/includes/playbook/common.yml +0 -23
  48. data/lib/orats/templates/includes/playbook/site.yml +0 -36
  49. data/lib/orats/templates/includes/role/.travis.yml +0 -19
  50. data/lib/orats/templates/includes/role/README.md +0 -62
  51. data/lib/orats/templates/includes/role/meta/main.yml +0 -123
  52. data/lib/orats/templates/includes/role/tests/inventory +0 -1
  53. data/lib/orats/templates/includes/role/tests/main.yml +0 -7
  54. data/lib/orats/templates/playbook.rb +0 -119
  55. data/lib/orats/templates/role.rb +0 -144
@@ -1,144 +0,0 @@
1
- # =============================================================================
2
- # template for generating an orats ansible role for ansible 1.6.x
3
- # =============================================================================
4
- # view the task list at the bottom of the file
5
- # -----------------------------------------------------------------------------
6
-
7
- # -----------------------------------------------------------------------------
8
- # private functions
9
- # -----------------------------------------------------------------------------
10
- def method_to_sentence(method)
11
- method.tr!('_', ' ')
12
- method[0] = method[0].upcase
13
- method
14
- end
15
-
16
- def log_task(message)
17
- puts
18
- say_status 'task', "#{method_to_sentence(message.to_s)}:", :yellow
19
- puts '-'*80, ''; sleep 0.25
20
- end
21
-
22
- def git_commit(message)
23
- git add: '-A'
24
- git commit: "-m '#{message}'"
25
- end
26
-
27
- def git_config(field)
28
- command = "git config --global user.#{field}"
29
- git_field_value = run(command, capture: true).gsub("\n", '')
30
- default_value = "YOUR_#{field.upcase}"
31
-
32
- git_field_value.to_s.empty? ? default_value : git_field_value
33
- end
34
-
35
- def copy_from_local_gem(source, dest = '')
36
- dest = source if dest.empty?
37
-
38
- base_path = "#{File.expand_path File.dirname(__FILE__)}/includes/role"
39
-
40
- run "mkdir -p #{File.dirname(dest)}" unless Dir.exist?(File.dirname(dest))
41
- run "cp -f #{base_path}/#{source} #{dest}"
42
- end
43
-
44
- # ---
45
-
46
- def delete_generated_rails_code
47
- log_task __method__
48
-
49
- run 'rm -rf * .git .gitignore'
50
- end
51
-
52
- def add_role_directory
53
- log_task __method__
54
-
55
- run "mkdir -p #{app_name}"
56
- run "mv #{app_name}/* ."
57
- run "rm -rf #{app_name}"
58
- git :init
59
- git_commit 'Initial commit'
60
- end
61
-
62
- def add_gitignore
63
- log_task __method__
64
-
65
- copy_from_local_gem '../common/.gitignore', '.gitignore'
66
- git_commit 'Add .gitignore'
67
- end
68
-
69
- def add_main_role
70
- log_task __method__
71
-
72
- folders = %w(defaults files handlers tasks templates)
73
-
74
- run "mkdir #{folders.join(' ')}"
75
-
76
- folders.delete_if { |folder| folder == 'files' || folder == 'templates' }
77
- folders.each do |folder|
78
- run "echo '---\n# #{folder} go here' > #{folder}/main.yml"
79
- end
80
- end
81
-
82
- def add_license
83
- log_task __method__
84
-
85
- author_name = git_config 'name'
86
- author_email = git_config 'email'
87
-
88
- copy_from_local_gem '../common/LICENSE', 'LICENSE'
89
- gsub_file 'LICENSE', 'Time.now.year', Time.now.year.to_s
90
- gsub_file 'LICENSE', 'author_name', author_name
91
- gsub_file 'LICENSE', 'author_email', author_email
92
- git_commit 'Add MIT license'
93
- end
94
-
95
- def add_readme
96
- log_task __method__
97
-
98
- role_info = File.basename(app_name).split('_')
99
- github_user = role_info[0]
100
- role_name = role_info[1]
101
-
102
- copy_from_local_gem 'README.md'
103
- gsub_file 'README.md', 'github_user', github_user
104
- gsub_file 'README.md', 'role_name', role_name
105
- git_commit 'Add readme'
106
- end
107
-
108
- def add_meta_information
109
- log_task __method__
110
-
111
- author_name = git_config 'name'
112
-
113
- copy_from_local_gem 'meta/main.yml'
114
- gsub_file 'meta/main.yml', 'author_name', author_name
115
- git_commit 'Add meta information'
116
- end
117
-
118
- def add_tests_and_travis
119
- log_task __method__
120
-
121
- copy_from_local_gem '.travis.yml'
122
- copy_from_local_gem 'tests/main.yml'
123
- copy_from_local_gem 'tests/inventory'
124
- git_commit 'Add tests and travis-ci'
125
- end
126
-
127
- def remove_unused_files_from_git
128
- log_task __method__
129
-
130
- git add: '-u'
131
- git_commit 'Remove unused files'
132
- end
133
-
134
- # ---
135
-
136
- delete_generated_rails_code
137
- add_role_directory
138
- add_gitignore
139
- add_main_role
140
- add_license
141
- add_readme
142
- add_meta_information
143
- add_tests_and_travis
144
- remove_unused_files_from_git