script_core 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +131 -36
  3. data/Gemfile +2 -2
  4. data/lib/script_core/executable.rb +1 -1
  5. data/lib/script_core/message_processor.rb +48 -48
  6. data/lib/script_core/version.rb +1 -1
  7. data/lib/tasks/script_core.rake +47 -31
  8. data/spec/dummy/app/controllers/application_controller.rb +11 -11
  9. data/spec/dummy/app/controllers/fields/application_controller.rb +14 -14
  10. data/spec/dummy/app/controllers/fields/choices_controller.rb +8 -10
  11. data/spec/dummy/app/controllers/fields/options_controller.rb +6 -6
  12. data/spec/dummy/app/controllers/fields/validations_controller.rb +6 -6
  13. data/spec/dummy/app/controllers/forms/application_controller.rb +4 -4
  14. data/spec/dummy/app/controllers/forms/fields_controller.rb +8 -8
  15. data/spec/dummy/app/controllers/forms/formulas/application_controller.rb +7 -7
  16. data/spec/dummy/app/controllers/forms/formulas/playgrounds_controller.rb +6 -6
  17. data/spec/dummy/app/controllers/forms/formulas_controller.rb +8 -8
  18. data/spec/dummy/app/controllers/forms_controller.rb +8 -8
  19. data/spec/dummy/app/controllers/nested_forms/application_controller.rb +4 -4
  20. data/spec/dummy/app/controllers/nested_forms/fields_controller.rb +8 -8
  21. data/spec/dummy/app/controllers/playgrounds_controller.rb +3 -3
  22. data/spec/dummy/app/controllers/time_zones_controller.rb +1 -3
  23. data/spec/dummy/app/lib/script_engine.rb +1 -1
  24. data/spec/dummy/app/models/concerns/fields/validations/exclusion.rb +1 -1
  25. data/spec/dummy/app/models/concerns/fields/validations/format.rb +1 -1
  26. data/spec/dummy/app/models/concerns/fields/validations/inclusion.rb +1 -1
  27. data/spec/dummy/app/models/concerns/fields/validations/length.rb +1 -1
  28. data/spec/dummy/app/models/field.rb +25 -25
  29. data/spec/dummy/app/models/field_options.rb +55 -61
  30. data/spec/dummy/app/models/fields/date_field.rb +5 -5
  31. data/spec/dummy/app/models/fields/datetime_field.rb +5 -5
  32. data/spec/dummy/app/models/fields/integer_field.rb +4 -4
  33. data/spec/dummy/app/models/fields/multiple_nested_form_field.rb +2 -4
  34. data/spec/dummy/app/models/fields/multiple_select_field.rb +6 -8
  35. data/spec/dummy/app/models/fields/nested_form_field.rb +2 -4
  36. data/spec/dummy/app/models/fields/options/date_field.rb +5 -5
  37. data/spec/dummy/app/models/fields/options/datetime_field.rb +5 -5
  38. data/spec/dummy/app/models/fields/select_field.rb +5 -5
  39. data/spec/dummy/app/{decorators → overrides}/.keep +0 -0
  40. data/spec/dummy/app/presenters/concerns/fields/presenter_for_number_field.rb +1 -1
  41. data/spec/dummy/app/views/_form_core/fields/_multiple_nested_form_field.html.erb +2 -2
  42. data/spec/dummy/app/views/_form_core/fields/_multiple_select_field.html.erb +10 -2
  43. data/spec/dummy/app/views/_form_core/fields/_nested_form.html.erb +3 -1
  44. data/spec/dummy/app/views/_form_core/fields/_nested_form_field.html.erb +2 -2
  45. data/spec/dummy/app/views/_form_core/fields/_select_field.html.erb +9 -2
  46. data/spec/dummy/config/application.rb +8 -1
  47. data/spec/dummy/db/migrate/20180916202025_create_forms.form_core.rb +1 -1
  48. data/spec/dummy/lib/monkey_patches/big_decimal.rb +4 -4
  49. data/spec/dummy/lib/monkey_patches/date.rb +4 -4
  50. data/spec/dummy/lib/monkey_patches/time.rb +4 -4
  51. data/spec/dummy/test/application_system_test_case.rb +7 -0
  52. data/spec/script_core/message_processor_spec.rb +4 -4
  53. data/spec/script_core/service_process_spec.rb +4 -4
  54. data/spec/script_core/stat_spec.rb +2 -2
  55. data/spec/script_core_spec.rb +10 -10
  56. metadata +4 -3
@@ -2,7 +2,7 @@
2
2
 
3
3
  RSpec.describe(ScriptCore::ServiceProcess) do
4
4
  let(:pid) { rand(1 << 16) }
5
- let(:environment_variables) { {"TZ" => "US/Pacific"} }
5
+ let(:environment_variables) { { "TZ" => "US/Pacific" } }
6
6
  let(:service_path) { "bin/my-subprocess" }
7
7
  let(:pipe_pairs) { [] }
8
8
 
@@ -52,7 +52,7 @@
52
52
  expect(spawner)
53
53
  .to receive(:wait).once.with(pid, Process::WNOHANG).and_return(0)
54
54
  expect(spawner).to receive(:wait).never
55
- expect(service_process.open {}).to eq(0)
55
+ expect(service_process.open { }).to eq(0)
56
56
  end
57
57
 
58
58
  it "optimistically tries to wait on the child without killing when raising" do
@@ -68,7 +68,7 @@
68
68
  expect(spawner).to receive(:kill).once.with(9, pid)
69
69
  expect(spawner)
70
70
  .to receive(:wait).once.with(pid).and_return(0)
71
- expect(service_process.open {}).to eq(0)
71
+ expect(service_process.open { }).to eq(0)
72
72
  end
73
73
 
74
74
  it "kills the child process if it has not terminated when raising" do
@@ -84,6 +84,6 @@
84
84
  expect(spawner)
85
85
  .to receive(:wait).once.with(pid, Process::WNOHANG).and_return(nil)
86
86
  expect(spawner).to receive(:kill).once.with(9, pid).and_raise(Errno::ESRCH)
87
- expect(service_process.open {}).to eq(-1)
87
+ expect(service_process.open { }).to eq(-1)
88
88
  end
89
89
  end
@@ -4,13 +4,13 @@
4
4
  let(:null_stat) { ScriptCore::Stat::Null }
5
5
 
6
6
  it "supports all stats" do
7
- options = {instructions: 1, memory: 2, bytes_in: 3, time: 4, total_instructions: 5}
7
+ options = { instructions: 1, memory: 2, bytes_in: 3, time: 4, total_instructions: 5 }
8
8
  stat = ScriptCore::Stat.new(options)
9
9
  expect(stat).to have_attributes(options)
10
10
  end
11
11
 
12
12
  it "nullStats are all zero" do
13
- default_values = {instructions: 0, memory: 0, bytes_in: 0, time: 0, total_instructions: 0}
13
+ default_values = { instructions: 0, memory: 0, bytes_in: 0, time: 0, total_instructions: 0 }
14
14
  expect(null_stat).to have_attributes(default_values)
15
15
  end
16
16
  end
@@ -6,7 +6,7 @@
6
6
  RSpec.describe(ScriptCore) do
7
7
  it "evaluates a simple script" do
8
8
  result = ScriptCore.run(
9
- input: {result: [26_803_196_617, 0.475]},
9
+ input: { result: [26_803_196_617, 0.475] },
10
10
  sources: [
11
11
  ["stdout", "@stdout_buffer = 'hello'"],
12
12
  ["foo", "@output = @input[:result]"]
@@ -32,7 +32,7 @@
32
32
 
33
33
  it "exposes metrics" do
34
34
  result = ScriptCore.run(
35
- input: {result: [26_803_196_617, 0.475]},
35
+ input: { result: [26_803_196_617, 0.475] },
36
36
  sources: [
37
37
  ["stdout", "@stdout_buffer = 'hello'"],
38
38
  ["foo", "@output = @input[:result]"]
@@ -49,7 +49,7 @@
49
49
 
50
50
  it "exposes stat" do
51
51
  result = ScriptCore.run(
52
- input: {result: [26_803_196_617, 0.475]},
52
+ input: { result: [26_803_196_617, 0.475] },
53
53
  sources: [
54
54
  ["stdout", "@stdout_buffer = 'hello'"],
55
55
  ["foo", "@output = @input[:result]"]
@@ -74,7 +74,7 @@ def max_loops(instruction_quota)
74
74
  loops = max_loops(100_000)
75
75
 
76
76
  result = ScriptCore.run(
77
- input: {result: [26_803_196_617, 0.475]},
77
+ input: { result: [26_803_196_617, 0.475] },
78
78
  sources: [
79
79
  ["stdout", "#{loops}.times {}"]
80
80
  ],
@@ -85,7 +85,7 @@ def max_loops(instruction_quota)
85
85
  expect(result.stat.instructions).to eq(expected_instructions(loops))
86
86
 
87
87
  result_with_error = ScriptCore.run(
88
- input: {result: [26_803_196_617, 0.475]},
88
+ input: { result: [26_803_196_617, 0.475] },
89
89
  sources: [
90
90
  ["stdout", "#{loops + 1}.times {}"]
91
91
  ],
@@ -102,7 +102,7 @@ def max_loops(instruction_quota)
102
102
  loops = max_loops(given_quota)
103
103
 
104
104
  result = ScriptCore.run(
105
- input: {result: [26_803_196_617, 0.475]},
105
+ input: { result: [26_803_196_617, 0.475] },
106
106
  sources: [
107
107
  ["stdout", "#{loops}.times {}"]
108
108
  ],
@@ -114,7 +114,7 @@ def max_loops(instruction_quota)
114
114
  expect(result.stat.instructions).to eq(expected_instructions(loops))
115
115
 
116
116
  result_with_error = ScriptCore.run(
117
- input: {result: [26_803_196_617, 0.475]},
117
+ input: { result: [26_803_196_617, 0.475] },
118
118
  sources: [
119
119
  ["stdout", "#{loops + 1}.times {}"]
120
120
  ],
@@ -130,7 +130,7 @@ def max_loops(instruction_quota)
130
130
  it "checks that a given instruction quota is respected from a given source index" do
131
131
  quota = 15_000
132
132
  result = ScriptCore.run(
133
- input: {result: [26_803_196_617, 0.475]},
133
+ input: { result: [26_803_196_617, 0.475] },
134
134
  sources: [
135
135
  ["ignore", "1000.times {}"], # if we count this one, we'd blow the 15k quota
136
136
  ["count", "1000.times {}"]
@@ -146,7 +146,7 @@ def max_loops(instruction_quota)
146
146
 
147
147
  it "supports symbols stat" do
148
148
  result = ScriptCore.run(
149
- input: {result: {value: 0.475}},
149
+ input: { result: { value: 0.475 } },
150
150
  sources: [
151
151
  ["stdout", "@stdout_buffer = 'hello'"],
152
152
  ["foo", "@output = @input[:result]"]
@@ -245,7 +245,7 @@ def foo
245
245
 
246
246
  it "includes the stdout_buffer if it raises" do
247
247
  result = ScriptCore.run(
248
- input: {result: [26_803_196_617, 0.475]},
248
+ input: { result: [26_803_196_617, 0.475] },
249
249
  sources: [
250
250
  ["stdout", "@stdout_buffer = 'hello'"],
251
251
  ["foo", "raise \"Ouch!\""]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: script_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jasl
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-14 00:00:00.000000000 Z
11
+ date: 2019-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack
@@ -2985,7 +2985,6 @@ files:
2985
2985
  - spec/dummy/app/controllers/nested_forms/fields_controller.rb
2986
2986
  - spec/dummy/app/controllers/playgrounds_controller.rb
2987
2987
  - spec/dummy/app/controllers/time_zones_controller.rb
2988
- - spec/dummy/app/decorators/.keep
2989
2988
  - spec/dummy/app/helpers/application_helper.rb
2990
2989
  - spec/dummy/app/helpers/fields_helper.rb
2991
2990
  - spec/dummy/app/helpers/forms_helper.rb
@@ -3042,6 +3041,7 @@ files:
3042
3041
  - spec/dummy/app/models/nested_form.rb
3043
3042
  - spec/dummy/app/models/non_configurable.rb
3044
3043
  - spec/dummy/app/models/virtual_model.rb
3044
+ - spec/dummy/app/overrides/.keep
3045
3045
  - spec/dummy/app/presenters/application_presenter.rb
3046
3046
  - spec/dummy/app/presenters/concerns/fields/presenter_for_number_field.rb
3047
3047
  - spec/dummy/app/presenters/fields/boolean_field_presenter.rb
@@ -3184,6 +3184,7 @@ files:
3184
3184
  - spec/dummy/public/apple-touch-icon.png
3185
3185
  - spec/dummy/public/favicon.ico
3186
3186
  - spec/dummy/storage/.keep
3187
+ - spec/dummy/test/application_system_test_case.rb
3187
3188
  - spec/dummy/test/controllers/.keep
3188
3189
  - spec/dummy/test/fixtures/.keep
3189
3190
  - spec/dummy/test/models/.keep