ree_lib 1.0.45 → 1.0.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1833caceb1fab8b06725a1a975b37176fe614d2977bec18a0bbcde694bc8c386
4
- data.tar.gz: d7a55eebaeabce9227d6d5c991bbd55ce2b70e3a2c1857bef588205320d8a911
3
+ metadata.gz: c74ce073851aa0f44a9d5ef2d7df9000bd595e1208300a257269cdec28de15e8
4
+ data.tar.gz: eb2cc59a1ae7da783c6950236288e7be4a5d6a1c42f5216fd0c7cac5728941bd
5
5
  SHA512:
6
- metadata.gz: ca8d804780cdaed54a20b120bc8054568af74ca303fc2cd4e237944f1d8db6a9f26dd89fcbe31f912f5a3f966d315839267cc76208fe8a76dfbe7834faf3ab3a
7
- data.tar.gz: 5840f846e9bf90ba3882454d21f9bf2df376319512a30766ba28ac41e72f70d70429dd0c4c69edc5bdf0bf4b45825c451861f46bb5b0cbbced98b58c7d625393
6
+ metadata.gz: 6ae3e653b7ee36a1ce7574cfe1ec091532420744b5b87e33aa121b4c01929ff989f5e5800414dc10a59e9752daf2e02bd6b51f656a6f449db2ee5c89a3242c72
7
+ data.tar.gz: 6a09a450be8d91aced2a457248e30b6c810ceb9857e391ccb73574e4ee546fc96345cc4dcc0ad3618c3304fe808b78ad45a1a8f69150d95625ce38bd86237151
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ree_lib (1.0.45)
4
+ ree_lib (1.0.47)
5
5
  binding_of_caller (~> 1.0.0)
6
6
  i18n (~> 1.12.0)
7
7
  loofah (~> 2.18.0)
@@ -36,7 +36,9 @@ GEM
36
36
  crass (~> 1.0.2)
37
37
  nokogiri (>= 1.5.9)
38
38
  msgpack (1.6.0)
39
- nokogiri (1.14.2-x86_64-linux)
39
+ nokogiri (1.14.3-x86_64-darwin)
40
+ racc (~> 1.4)
41
+ nokogiri (1.14.3-x86_64-linux)
40
42
  racc (~> 1.4)
41
43
  oj (3.13.23)
42
44
  pg (1.4.6)
@@ -4,10 +4,8 @@ class ReeHttp::BuildRequest
4
4
  include Ree::FnDSL
5
5
 
6
6
  fn :build_request do
7
- link :to_json, from: :ree_json
8
- link :slice, from: :ree_hash
9
7
  link :not_blank, from: :ree_object
10
-
8
+ link :to_json, from: :ree_json
11
9
  link 'ree_http/constants', -> {
12
10
  HTTPS & HTTP & HTTPS_PORT & HTTP_PORT & DEFAULT_FORCE_SSL
13
11
  }
@@ -84,8 +82,8 @@ class ReeHttp::BuildRequest
84
82
 
85
83
  unless opts[:body].nil?
86
84
  request.body =
87
- case request[:body]
88
- when Hash then to_json[opts[:body]]
85
+ case opts[:body]
86
+ when Hash then to_json(opts[:body])
89
87
  when File then opts[:body].read
90
88
  else
91
89
  opts[:body]
@@ -41,14 +41,6 @@
41
41
 
42
42
  ]
43
43
  },
44
- {
45
- "target": "slice",
46
- "package_name": "ree_hash",
47
- "as": "slice",
48
- "imports": [
49
-
50
- ]
51
- },
52
44
  {
53
45
  "target": "to_json",
54
46
  "package_name": "ree_json",
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require 'webmock/rspec'
3
+ require "tempfile"
3
4
 
4
5
  RSpec.describe :http_post do
5
6
  link :http_post, from: :ree_http
@@ -70,6 +71,26 @@ RSpec.describe :http_post do
70
71
  body: "abc"
71
72
  )
72
73
 
74
+ http_post(
75
+ host,
76
+ body: { foo: "bar" }
77
+ )
78
+ expect(WebMock).to have_requested(:post, host).with(body: "{\"foo\":\"bar\"}")
79
+
80
+ begin
81
+ tempfile = Tempfile.new
82
+ tempfile.write("hello world")
83
+ tempfile.rewind
84
+
85
+ http_post(
86
+ host,
87
+ body: File.open(tempfile.path)
88
+ )
89
+ expect(WebMock).to have_requested(:post, host).with(body: "hello world")
90
+ ensure
91
+ tempfile&.close!
92
+ end
93
+
73
94
  # works !
74
95
  # response = http_post(
75
96
  # 'http://127.0.0.1:8085/end',
@@ -52,7 +52,11 @@ class ReeRoda::BuildRouteErrors
52
52
  klass, :call, scope: :instance
53
53
  )
54
54
 
55
- method_decorator&.errors || []
55
+ original_method_decorator = Ree::Contracts.get_method_decorator(
56
+ klass, :__original_call, scope: :instance
57
+ )
58
+
59
+ method_decorator&.errors || original_method_decorator&.errors || []
56
60
  end
57
61
 
58
62
  def status_from_error(error)
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ package_require("ree_errors/validation_error")
4
+
5
+ RSpec.describe :build_swagger_from_routes do
6
+ link :add_load_path, from: :ree_i18n
7
+ link :build_swagger_from_routes, from: :ree_roda
8
+
9
+ before :all do
10
+ add_load_path(Dir[File.join(__dir__, 'locales/*.yml')])
11
+
12
+ Ree.enable_irb_mode
13
+
14
+ module ReeRodaTestSwagger
15
+ include Ree::PackageDSL
16
+
17
+ package do
18
+ depends_on :ree_actions
19
+ depends_on :ree_dao
20
+ end
21
+ end
22
+
23
+ class ReeRodaTestSwagger::Cmd
24
+ include ReeActions::DSL
25
+
26
+ action :cmd
27
+
28
+ ActionCaster = build_mapper.use(:cast) do
29
+ integer :id
30
+ end
31
+
32
+ InvalidErr = ReeErrors::ValidationError.build(:invalid, "invalid")
33
+
34
+ contract(Any, Any => Any).throws(InvalidErr)
35
+ def call(access, attrs)
36
+ raise InvalidErr if false
37
+ end
38
+ end
39
+
40
+ class ReeRodaTestSwagger::TestRoutes
41
+ include ReeRoutes::DSL
42
+
43
+ routes :test_routes do
44
+ default_warden_scope :identity
45
+ opts = { from: :ree_roda_test_swagger }
46
+
47
+ post "api/actions" do
48
+ summary "Some action"
49
+ action :cmd, **opts
50
+ end
51
+ end
52
+ end
53
+
54
+ class TestSwaggerApp < ReeRoda::App
55
+ plugin :ree_routes
56
+
57
+ ree_routes ReeRodaTestSwagger::TestRoutes.new
58
+
59
+ route do |r|
60
+ r.ree_routes
61
+ end
62
+ end
63
+ end
64
+
65
+ after :all do
66
+ Ree.disable_irb_mode
67
+ end
68
+
69
+ let(:routes) { TestSwaggerApp.instance_variable_get(:@ree_routes) }
70
+
71
+ it {
72
+ swagger = build_swagger_from_routes(routes, "test", "test", "1.0", "https://example.com")
73
+
74
+ expect(swagger.dig(:paths, "/api/actions", :post, :responses, 422, :description))
75
+ .to eq("- type: **validation**, code: **invalid**, message: **invalid**")
76
+ }
77
+ end
@@ -0,0 +1,2 @@
1
+ en:
2
+ invalid: "invalid"
@@ -0,0 +1,2 @@
1
+ ru:
2
+ invalid: "invalid"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ReeLib
4
- VERSION = "1.0.45"
4
+ VERSION = "1.0.47"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ree_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.45
4
+ version: 1.0.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruslan Gatiyatov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-10 00:00:00.000000000 Z
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ree
@@ -1131,6 +1131,9 @@ files:
1131
1131
  - lib/ree_lib/packages/ree_roda/spec/package_schema_spec.rb
1132
1132
  - lib/ree_lib/packages/ree_roda/spec/ree_roda/app_spec.rb
1133
1133
  - lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_routing_tree_spec.rb
1134
+ - lib/ree_lib/packages/ree_roda/spec/ree_roda/services/build_swagger_from_routes_spec.rb
1135
+ - lib/ree_lib/packages/ree_roda/spec/ree_roda/services/locales/en.yml
1136
+ - lib/ree_lib/packages/ree_roda/spec/ree_roda/services/locales/ru.yml
1134
1137
  - lib/ree_lib/packages/ree_roda/spec/spec_helper.rb
1135
1138
  - lib/ree_lib/packages/ree_routes/.gitignore
1136
1139
  - lib/ree_lib/packages/ree_routes/.rspec