eco-helpers 3.0.0 → 3.0.1

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
  SHA256:
3
- metadata.gz: f87b772a3ca7272d32299e202d5f0a500f4e814b5281e00d2e49484a52fa42df
4
- data.tar.gz: dde02113e49cc438157123b892b5ab2e747707f824ec0b228240a1f8aacebe29
3
+ metadata.gz: 47fd3e322ea8c31b1db092d07ac97038c3377f0511f3346859cbe31705f8b59c
4
+ data.tar.gz: ff4f1f43958e1277636b39d49675714bb4b89db326dde17c5b57678a77b3310c
5
5
  SHA512:
6
- metadata.gz: 3cc9947ab00adc1881db3a69cbe0873b5a2ec1275c92d3127f5826b5acb96db5b9b72cdc4297a0658172cdd321cdd46c4f02fddb7b93f05296ad2d2be2509298
7
- data.tar.gz: '0330899821bab587d827d9079638e9cef5528f8c01e68aab5379e7d358b9de7dffb18ed6b49f12268737b953c4bb95419cbf0c4816b96dcf819d03857880d451'
6
+ metadata.gz: 4e9f752dbf9f145eac3c905a387f0f91f4174e699be895e02bcfc23bef1465b9c25cf708d44df9ab6140bfb66e61d062657a67bb68caefef536aaca8c40b392c
7
+ data.tar.gz: '092d48959d3ffc5344a6bf4e22007bdbc644aaf0d9cfc035bb9ba34ef65ce42238dde0c78c38454ecb8b65ef5dc8c98d76d510f66f738546037f63c48683232a'
data/CHANGELOG.md CHANGED
@@ -2,12 +2,22 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- ## [3.0.0] - 2024-08-01
5
+ ## [3.0.1] - 2024-08-09
6
6
 
7
7
  ### Added
8
8
 
9
+ - `GraphQLSchema` case to extract the schema in a json file
10
+
9
11
  ### Changed
10
12
 
13
+ - `SplitCsv` case namespace
14
+
15
+ ### Fixed
16
+
17
+ - have `Eco::VERSION` defined
18
+
19
+ ## [3.0.0] - 2024-08-01
20
+
11
21
  - require `ruby 3`
12
22
 
13
23
  ### Fixed
data/eco-helpers.gemspec CHANGED
@@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
41
41
  spec.add_dependency 'dotenv', '~> 3'
42
42
  spec.add_dependency 'ecoportal-api', '~> 0.10'
43
43
  spec.add_dependency 'ecoportal-api-graphql', '~> 0.4'
44
- spec.add_dependency 'ecoportal-api-v2', '~> 2.0'
44
+ spec.add_dependency 'ecoportal-api-v2', '~> 2.0', '>= 2.0.8'
45
45
  spec.add_dependency 'ed25519', '~> 1.2'
46
46
  spec.add_dependency 'fast_excel', '>= 0.5.0', '< 0.6'
47
47
  spec.add_dependency 'fuzzy_match', '>= 2.1.0', '< 2.2'
@@ -0,0 +1,15 @@
1
+ class Eco::API::UseCases::Default::Meta::GraphQLSchema
2
+ class Cli < Eco::API::UseCases::Cli
3
+ desc "Retrieves and stores the GraphQL Schema"
4
+
5
+ callback do |_sess, options, _case|
6
+ file = SCR.get_arg(cli_name, with_param: true)
7
+ options.deep_merge!(output: {file: {name: file}})
8
+ end
9
+
10
+ add_option("-format", "Kind of extract (definition | json | yaml )") do |options|
11
+ format = SCR.get_arg("-format", with_param: true)
12
+ options.deep_merge!(output: {format: format})
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,78 @@
1
+ class Eco::API::UseCases::Default::Meta::GraphQLSchema < Eco::API::Common::Loaders::UseCase
2
+ include Eco::API::UseCases::GraphQL::Helpers::Base
3
+
4
+ require_relative 'cli/graphql_schema_cli'
5
+
6
+ OUT_FOLDER = "sftp".freeze
7
+ OUT_TIME_FORMAT = '%Y%m%dT%H%M%S'.freeze
8
+ OUT_FILENAME = "graphql_schema".freeze
9
+
10
+ name "graphql-schema"
11
+ type :other
12
+
13
+ def main(*_args)
14
+ return unless graphql_schema
15
+
16
+ File.open(output_filename, 'wb') { |fd| fd << schema_content }
17
+ log(:info) {
18
+ "Generated file: '#{output_filename}'"
19
+ }
20
+ end
21
+
22
+ private
23
+
24
+ def schema_content
25
+ case output_format
26
+ when :definition
27
+ graphql_schema.to_definition
28
+ when :json
29
+ graphql_schema.to_json
30
+ when :yaml
31
+ graphql_schema.to_yaml
32
+ else
33
+ raise ArgumentError, "Unknown '-format' #{output_format}"
34
+ end
35
+ end
36
+
37
+ def graphql_schema
38
+ @graphql_schema ||= graphql.client.schema
39
+ end
40
+
41
+ def output_filename(name = output_basename)
42
+ File.join(output_folder, "#{timestamp}_#{enviro_name}_#{name}.#{output_extension}")
43
+ end
44
+
45
+ def enviro_name
46
+ @enviro_name ||= ''.then do
47
+ host = graphql.client.host
48
+ uri = URI.parse("https://#{host}")
49
+ uri.host.split('.')[0].gsub('-', '_')
50
+ end
51
+ end
52
+
53
+ def output_extension
54
+ case output_format
55
+ when :definition then 'graphql'
56
+ when :json then 'json'
57
+ when :yaml then 'yml'
58
+ else
59
+ 'txt'
60
+ end
61
+ end
62
+
63
+ def output_folder
64
+ "#{config.active_enviro}/#{self.class::OUT_FOLDER}"
65
+ end
66
+
67
+ def timestamp(date = Time.now)
68
+ date.strftime(self.class::OUT_TIME_FORMAT)
69
+ end
70
+
71
+ def output_basename
72
+ options.dig(:output, :file, :name) || self.class::OUT_FILENAME
73
+ end
74
+
75
+ def output_format
76
+ @output_format ||= (options.dig(:output, :format) || :definition).to_sym
77
+ end
78
+ end
@@ -0,0 +1,12 @@
1
+ module Eco
2
+ module API
3
+ class UseCases
4
+ class Default
5
+ module Meta
6
+ end
7
+ end
8
+ end
9
+ end
10
+ end
11
+
12
+ require_relative 'meta/graphql_schema'
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::Utils::SplitCsv
1
+ class Eco::API::UseCases::Default::Utils::SplitCsv
2
2
  class Cli < Eco::API::UseCases::Cli
3
3
  desc "Splits an input file into multiple ones"
4
4
 
@@ -1,4 +1,4 @@
1
- class Eco::API::UseCases::Default::People::Utils::SplitCsv < Eco::API::Common::Loaders::UseCase
1
+ class Eco::API::UseCases::Default::Utils::SplitCsv < Eco::API::Common::Loaders::UseCase
2
2
  require_relative 'cli/split_csv_cli'
3
3
 
4
4
  MAX_ROWS = 15_000
@@ -12,6 +12,7 @@ module Eco
12
12
  end
13
13
  end
14
14
 
15
+ require_relative 'default/meta'
16
+ require_relative 'default/utils'
15
17
  require_relative 'default/people'
16
18
  require_relative 'default/locations'
17
- require_relative 'default/utils'
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = '3.0.0'.freeze
2
+ VERSION = '3.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-01 00:00:00.000000000 Z
11
+ date: 2024-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -261,6 +261,9 @@ dependencies:
261
261
  - - "~>"
262
262
  - !ruby/object:Gem::Version
263
263
  version: '2.0'
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ version: 2.0.8
264
267
  type: :runtime
265
268
  prerelease: false
266
269
  version_requirements: !ruby/object:Gem::Requirement
@@ -268,6 +271,9 @@ dependencies:
268
271
  - - "~>"
269
272
  - !ruby/object:Gem::Version
270
273
  version: '2.0'
274
+ - - ">="
275
+ - !ruby/object:Gem::Version
276
+ version: 2.0.8
271
277
  - !ruby/object:Gem::Dependency
272
278
  name: ed25519
273
279
  requirement: !ruby/object:Gem::Requirement
@@ -658,6 +664,9 @@ files:
658
664
  - lib/eco/api/usecases/default/locations/csv_to_tree_case.rb
659
665
  - lib/eco/api/usecases/default/locations/tagtree_extract_case.rb
660
666
  - lib/eco/api/usecases/default/locations/tagtree_upload_case.rb
667
+ - lib/eco/api/usecases/default/meta.rb
668
+ - lib/eco/api/usecases/default/meta/cli/graphql_schema_cli.rb
669
+ - lib/eco/api/usecases/default/meta/graphql_schema.rb
661
670
  - lib/eco/api/usecases/default/people.rb
662
671
  - lib/eco/api/usecases/default/people/amend.rb
663
672
  - lib/eco/api/usecases/default/people/amend/clean_unknown_tags_case.rb