cf_script 0.0.1.beta.1 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +18 -0
  3. data/README.md +182 -34
  4. data/Rakefile +0 -13
  5. data/lib/cf_script/command/base.rb +1 -1
  6. data/lib/cf_script/command/cf/apps/app.rb +1 -1
  7. data/lib/cf_script/command/cf/apps/apps.rb +5 -3
  8. data/lib/cf_script/command/cf/apps/delete.rb +25 -0
  9. data/lib/cf_script/command/cf/apps/env.rb +4 -2
  10. data/lib/cf_script/command/cf/apps/push.rb +7 -2
  11. data/lib/cf_script/command/cf/apps/rename.rb +20 -0
  12. data/lib/cf_script/command/cf/apps/restage.rb +1 -1
  13. data/lib/cf_script/command/cf/apps/restart.rb +1 -1
  14. data/lib/cf_script/command/cf/apps/set_env.rb +1 -1
  15. data/lib/cf_script/command/cf/apps/start.rb +1 -1
  16. data/lib/cf_script/command/cf/apps/stop.rb +3 -2
  17. data/lib/cf_script/command/cf/apps/unset_env.rb +1 -1
  18. data/lib/cf_script/command/cf/apps.rb +5 -1
  19. data/lib/cf_script/command/cf/general/api.rb +1 -1
  20. data/lib/cf_script/command/cf/general/auth.rb +1 -1
  21. data/lib/cf_script/command/cf/general/login.rb +1 -1
  22. data/lib/cf_script/command/cf/general/logout.rb +1 -1
  23. data/lib/cf_script/command/cf/general/target.rb +1 -1
  24. data/lib/cf_script/command/cf/routes/check_route.rb +1 -1
  25. data/lib/cf_script/command/cf/routes/create_route.rb +1 -1
  26. data/lib/cf_script/command/cf/routes/delete_route.rb +5 -2
  27. data/lib/cf_script/command/cf/routes/map_route.rb +1 -1
  28. data/lib/cf_script/command/cf/routes/routes.rb +1 -1
  29. data/lib/cf_script/command/cf/routes/unmap_route.rb +1 -1
  30. data/lib/cf_script/command/cf/spaces/space.rb +1 -1
  31. data/lib/cf_script/command/cf/spaces/spaces.rb +1 -1
  32. data/lib/cf_script/command/runner.rb +1 -15
  33. data/lib/cf_script/config.rb +3 -1
  34. data/lib/cf_script/executor/recorder.rb +3 -1
  35. data/lib/cf_script/executor/simple.rb +22 -9
  36. data/lib/cf_script/executor.rb +0 -1
  37. data/lib/cf_script/object/api_endpoint.rb +1 -1
  38. data/lib/cf_script/object/app_info.rb +1 -1
  39. data/lib/cf_script/object/app_list.rb +21 -5
  40. data/lib/cf_script/object/attribute.rb +1 -1
  41. data/lib/cf_script/object/attribute_list.rb +1 -1
  42. data/lib/cf_script/object/instance_status.rb +1 -1
  43. data/lib/cf_script/object/route_info.rb +1 -1
  44. data/lib/cf_script/object/space.rb +1 -1
  45. data/lib/cf_script/object/target.rb +1 -1
  46. data/lib/cf_script/object.rb +0 -11
  47. data/lib/cf_script/output/buffer.rb +1 -1
  48. data/lib/cf_script/scope/app/routes.rb +1 -1
  49. data/lib/cf_script/scope/app.rb +0 -26
  50. data/lib/cf_script/scope/target.rb +7 -1
  51. data/lib/cf_script/ui.rb +2 -6
  52. data/lib/cf_script/version.rb +1 -1
  53. data/lib/cf_script.rb +0 -2
  54. data/test/fixtures/commands/apps/delete/good.yml +8 -0
  55. data/test/fixtures/commands/apps/delete/not_exist.yml +9 -0
  56. data/test/fixtures/commands/apps/env/{empty.yml → empty_vars.yml} +0 -0
  57. data/test/fixtures/commands/apps/rename/good.yml +8 -0
  58. data/test/fixtures/commands/apps/rename/not_found.yml +8 -0
  59. data/test/fixtures/commands/{apps/set_env → common}/empty.yml +0 -0
  60. data/test/lib/cf_script/command/cf/apps/app_test.rb +8 -0
  61. data/test/lib/cf_script/command/cf/apps/apps_test.rb +12 -3
  62. data/test/lib/cf_script/command/cf/apps/delete_test.rb +51 -0
  63. data/test/lib/cf_script/command/cf/apps/env_test.rb +12 -2
  64. data/test/lib/cf_script/command/cf/apps/push_test.rb +14 -0
  65. data/test/lib/cf_script/command/cf/apps/rename_test.rb +35 -0
  66. data/test/lib/cf_script/command/cf/apps/restage_test.rb +8 -0
  67. data/test/lib/cf_script/command/cf/apps/restart_test.rb +8 -0
  68. data/test/lib/cf_script/command/cf/apps/start_test.rb +8 -0
  69. data/test/lib/cf_script/command/cf/apps/stop_test.rb +2 -2
  70. data/test/lib/cf_script/command/cf/general/login_test.rb +9 -10
  71. data/test/lib/cf_script/command/cf/routes/create_route_test.rb +12 -0
  72. data/test/lib/cf_script/command/cf/routes/delete_route_test.rb +18 -0
  73. data/test/lib/cf_script/command/cf/routes/map_route_test.rb +12 -0
  74. data/test/lib/cf_script/command/cf/routes/routes_test.rb +8 -0
  75. data/test/lib/cf_script/command/cf/routes/unmap_route_test.rb +12 -0
  76. data/test/lib/cf_script/object/app_info_test.rb +4 -4
  77. data/test/lib/cf_script/object/app_list_test.rb +68 -2
  78. data/test/lib/cf_script/output/buffer_test.rb +9 -9
  79. data/test/lib/cf_script/output/parser/section_test.rb +4 -2
  80. data/test/lib/cf_script/output/tests_test.rb +24 -24
  81. data/test/lib/cf_script/output_test.rb +23 -18
  82. data/test/lib/cf_script/scope/app/env_test.rb +58 -0
  83. data/test/lib/cf_script/scope/app/routes_test.rb +56 -0
  84. data/test/lib/cf_script/scope/app/state_test.rb +30 -0
  85. data/test/lib/cf_script/scope/script_test.rb +3 -2
  86. data/test/lib/cf_script/scope/target_test.rb +38 -23
  87. data/test/lib/cf_script/scope_test.rb +10 -6
  88. data/test/lib/cf_script/ui_test.rb +133 -0
  89. data/test/lib/cf_script_test.rb +14 -8
  90. data/test/support/assertions.rb +25 -0
  91. data/test/support/helpers/fixture_executor.rb +1 -1
  92. data/test/support/helpers/mock_execution.rb +29 -7
  93. metadata +23 -14
  94. data/lib/cf_script/callbacks.rb +0 -43
  95. data/lib/cf_script/executor/non_blocking.rb +0 -107
  96. data/lib/cf_script/object/app_spec.rb +0 -55
  97. data/test/fixtures/commands/apps/unset_env/empty.yml +0 -5
  98. data/test/fixtures/commands/general/auth/empty.yml +0 -5
  99. data/test/fixtures/commands/general/target/empty.yml +0 -5
  100. data/test/fixtures/commands/spaces/space/empty.yml +0 -5
  101. data/test/fixtures/commands/spaces/spaces/empty.yml +0 -5
@@ -1,107 +0,0 @@
1
- require 'open3'
2
-
3
- class CfScript::Executor::NonBlocking
4
- include CfScript::UI
5
-
6
- READ_SIZE = 1024
7
-
8
- PROGRESS_CHARS = ['|', '/', '-', '\\']
9
-
10
- def initialize
11
- @executions = 0
12
- @spin_count = 0
13
- end
14
-
15
- def execute(env, command_line)
16
- @spin_count = 0
17
- @executions += 1
18
-
19
- print " ... "
20
- stdout, stderr, status = execute_internal(env, command_line)
21
-
22
- report_exit(status.exitstatus == 0 ? :success : :error)
23
-
24
- [stdout, stderr, status]
25
- end
26
-
27
- def spin
28
- char = PROGRESS_CHARS[(@spin_count += 1) % PROGRESS_CHARS.length]
29
-
30
- print "\b#{char}".colorize(with_color_of(:step))
31
- end
32
-
33
- def got(c = '@')
34
- print "\b#{c}".colorize(with_color_of(:info))
35
- end
36
-
37
- def report_exit(type)
38
- icon = "#{emoji_for(type)} "
39
- text = case type
40
- when :success
41
- CfScript.config.ui.emoji ? icon : 'DONE '
42
- else
43
- CfScript.config.ui.emoji ? icon : 'ERROR'
44
- end
45
-
46
- puts "\b\b\b\b\b#{text}".colorize(with_color_of(type))
47
- end
48
-
49
- def execute_internal(env, command_line)
50
- out_stdout = ''
51
- out_stderr = ''
52
- out_status = nil
53
-
54
- Open3.popen3(env, command_line.to_s) do |stdin, stdout, stderr, wait|
55
- stdin.close_write
56
-
57
- begin
58
- streams = [stdout, stderr]
59
-
60
- #until streams.empty? do
61
- loop do
62
- ready = IO.select(streams, [], [], 0.1)
63
- spin
64
-
65
- if ready
66
- readable = ready[0]
67
-
68
- readable.each do |stream|
69
- fileno = stream.fileno
70
-
71
- begin
72
- data = stream.read_nonblock(READ_SIZE)
73
-
74
- if fileno == stdout.fileno
75
- got ; out_stdout << data
76
- elsif fileno == stderr.fileno
77
- got ; out_stderr << data
78
- else
79
- fileno_error(fileno, stdin, stdout, stderr)
80
- end
81
- rescue EOFError => e
82
- # puts "EOF-ERROR".colorize(with_color_of(:error))
83
- # streams.delete(stream)
84
- end
85
- end
86
- end
87
-
88
- break if stdout.eof? && stderr.eof?
89
- end
90
-
91
- out_status = wait.value
92
- rescue IOError => e
93
- puts "IOError: #{e}"
94
- end
95
- end
96
-
97
- [out_stdout, out_stderr, out_status]
98
- end
99
-
100
- def fileno_error(fileno, stdin, stdout, stderr)
101
- puts "ERROR: unexpected fileno: #{fileno} [" +
102
- "stdin: #{stdin.fileno}, " +
103
- "stdout: #{stdout.fileno}, " +
104
- "stderr: #{stderr.fileno}" +
105
- "]"
106
- end
107
- end
@@ -1,55 +0,0 @@
1
- class CfScript::AppSpec < CfScript::Object
2
- include CfScript::Callbacks
3
- include CfScript::UI
4
-
5
- def initialize(spec)
6
- @org = spec[:org]
7
- @env = spec[:env]
8
- @domain = spec[:domain]
9
- @name = spec[:name]
10
- @type = spec[:type]
11
- @phase = spec[:phase]
12
- @memory = spec[:memory] || '2GB'
13
- @instances = spec[:instances] || 1
14
- end
15
-
16
- def push_options
17
- {
18
- #domain: @domain,
19
- #hostname: hostname,
20
- memory: @memory,
21
- instances: @instances,
22
- health_check_type: @health_check,
23
- flags: [
24
- :no_route,
25
- :no_start,
26
- :no_manifest,
27
- ]
28
- }
29
- end
30
-
31
- def method_missing(m, *args, &block)
32
- if args.empty? && block.nil?
33
- instance_variable_get("@#{m}")
34
- elsif !args.empty? && block.nil?
35
- instance_variable_set("@#{m}", args.first)
36
- elsif args.empty? && !block.nil?
37
- instance_variable_set("@#{m}", yield)
38
- else
39
- raise "Can not accept arguments and a block. " +
40
- "Pass arguments or a block, not both."
41
- end
42
- end
43
-
44
- def full_name
45
- [name, type, phase].compact.join('-')
46
- end
47
-
48
- def hostname
49
- [org, env, name, type, phase].compact.join('-')
50
- end
51
-
52
- def fqdn
53
- [hostname, domain].compact.join('.')
54
- end
55
- end
@@ -1,5 +0,0 @@
1
- ---
2
- stdout: ''
3
- stderr: ''
4
- status:
5
- exitstatus: 0
@@ -1,5 +0,0 @@
1
- ---
2
- stdout: ''
3
- stderr: ''
4
- status:
5
- exitstatus: 0
@@ -1,5 +0,0 @@
1
- ---
2
- stdout: ''
3
- stderr: ''
4
- status:
5
- exitstatus: 0
@@ -1,5 +0,0 @@
1
- ---
2
- stdout: ''
3
- stderr: ''
4
- status:
5
- exitstatus: 0
@@ -1,5 +0,0 @@
1
- ---
2
- stdout: ''
3
- stderr: ''
4
- status:
5
- exitstatus: 0