answersengine 0.7.0 → 0.8.0

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
  SHA1:
3
- metadata.gz: 947baa69d00fcee7157fb5ebe8ef768463b98fed
4
- data.tar.gz: 4f1cc691ec1cd59885106b0aaac0096fb7514000
3
+ metadata.gz: 2f2cae0b108477738464b3850caa5409cf0262d5
4
+ data.tar.gz: 8ccf57b51e24ee5dc19dd0c8a55b55840e597274
5
5
  SHA512:
6
- metadata.gz: 10f7401085e95cd4d9e4ddf4a03344354787fed98375355fa892ddc1e0a3c9de0fc9df97ffa9753186c0fb043a1dd4ef848c07662af4dbdd2ab7138e190ae3af
7
- data.tar.gz: 035302d2e340a03f200897a837888c6317bf91433e20c1d3f27c430d53a040c0dc1021ddb3624dd17b6d7440997f96e98905e8eb9663e5b3ee28466338c7076b
6
+ metadata.gz: 015c71d29870ce0fec136e894c6fc5a05bbf889adda5bad7493f63e989f6cc783df3fd92fc46c5485a87514848d07438f323c3338f1505c166a73b752c6415de
7
+ data.tar.gz: ab8e0772e2cbf04c0eff48872651fdb5847973343e45b31f4820e559e4c361678b54a385dadb4ad20ed42a72f15223254824ffe9e3a43518b2da0e811137b2f7
@@ -1,7 +1,9 @@
1
1
  require 'thor'
2
2
  require 'answersengine/scraper'
3
+ require 'answersengine/cli/scraper_var'
3
4
  require 'answersengine/cli/scraper_exporter'
4
5
  require 'answersengine/cli/scraper_export'
6
+ require 'answersengine/cli/scraper_job_var'
5
7
  require 'answersengine/cli/scraper_job'
6
8
  require 'answersengine/cli/global_page'
7
9
  require 'answersengine/cli/scraper_page'
@@ -15,6 +17,7 @@ require 'answersengine/cli/finisher'
15
17
  require 'answersengine/cli/env_var'
16
18
 
17
19
 
20
+
18
21
  module AnswersEngine
19
22
  class CLI < Thor
20
23
  desc "scraper SUBCOMMAND ...ARGS", "manage scrapers"
@@ -172,6 +172,9 @@ module AnswersEngine
172
172
  desc "exporter SUBCOMMAND ...ARGS", "manage scraper's exporters"
173
173
  subcommand "exporter", ScraperExporter
174
174
 
175
+ desc "var SUBCOMMAND ...ARGS", "for managing scraper's variables"
176
+ subcommand "var", ScraperVar
177
+
175
178
 
176
179
  end
177
180
  end
@@ -65,6 +65,10 @@ module AnswersEngine
65
65
  puts "#{client.update(scraper_name, options)}"
66
66
  end
67
67
 
68
+ desc "var SUBCOMMAND ...ARGS", "for managing scraper's job variables"
69
+ subcommand "var", ScraperJobVar
70
+
71
+
68
72
  end
69
73
  end
70
74
 
@@ -0,0 +1,48 @@
1
+ module AnswersEngine
2
+ class CLI < Thor
3
+ class ScraperJobVar < Thor
4
+
5
+ package_name "job var"
6
+ def self.banner(command, namespace = nil, subcommand = false)
7
+ "#{basename} scraper #{@package_name} #{command.usage}"
8
+ end
9
+
10
+ desc "list <scraper_name>", "List environment variables on the scrape job"
11
+ long_desc <<-LONGDESC
12
+ List all environment variables on the scrape job.
13
+ LONGDESC
14
+ option :page, :aliases => :p, type: :numeric, desc: 'Get the next set of records by page.'
15
+ option :per_page, :aliases => :P, type: :numeric, desc: 'Number of records per page. Max 500 per page.'
16
+ def list(scraper_name)
17
+ client = Client::ScraperJobVar.new(options)
18
+ puts "#{client.all(scraper_name)}"
19
+ end
20
+
21
+ desc "set <scraper_name> <var_name> <value>", "Set an environment var on the scrape job"
22
+ long_desc <<-LONGDESC
23
+ Creates an environment variable\x5
24
+ <var_name>: Var name can only consist of alphabets, numbers, underscores. Name must be unique to your scrape job, otherwise it will be overwritten.\x5
25
+ <value>: Value of variable.\x5
26
+ LONGDESC
27
+ option :secret, type: :boolean, desc: 'Set true to make it decrypt the value. Default: false'
28
+ def set(scraper_name, var_name, value)
29
+ # puts "options #{options}"
30
+ client = Client::ScraperJobVar.new(options)
31
+ puts "#{client.set(scraper_name, var_name, value, options)}"
32
+ end
33
+
34
+ desc "show <scraper_name> <var_name>", "Show an environment variable on the scrape job"
35
+ def show(scraper_name, var_name)
36
+ client = Client::ScraperJobVar.new(options)
37
+ puts "#{client.find(scraper_name, var_name)}"
38
+ end
39
+
40
+ desc "unset <scraper_name> <var_name>", "Deletes an environment variable on the scrape job"
41
+ def unset(scraper_name, var_name)
42
+ client = Client::ScraperJobVar.new(options)
43
+ puts "#{client.unset(scraper_name, var_name)}"
44
+ end
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,48 @@
1
+ module AnswersEngine
2
+ class CLI < Thor
3
+ class ScraperVar < Thor
4
+
5
+ package_name "scraper var"
6
+ def self.banner(command, namespace = nil, subcommand = false)
7
+ "#{basename} #{@package_name} #{command.usage}"
8
+ end
9
+
10
+ desc "list <scraper_name>", "List environment variables on the scraper"
11
+ long_desc <<-LONGDESC
12
+ List all environment variables on the scraper.
13
+ LONGDESC
14
+ option :page, :aliases => :p, type: :numeric, desc: 'Get the next set of records by page.'
15
+ option :per_page, :aliases => :P, type: :numeric, desc: 'Number of records per page. Max 500 per page.'
16
+ def list(scraper_name)
17
+ client = Client::ScraperVar.new(options)
18
+ puts "#{client.all(scraper_name)}"
19
+ end
20
+
21
+ desc "set <scraper_name> <var_name> <value>", "Set an environment var on the scraper"
22
+ long_desc <<-LONGDESC
23
+ Creates an environment variable\x5
24
+ <var_name>: Var name can only consist of alphabets, numbers, underscores. Name must be unique to your scraper, otherwise it will be overwritten.\x5
25
+ <value>: Value of variable.\x5
26
+ LONGDESC
27
+ option :secret, type: :boolean, desc: 'Set true to make it decrypt the value. Default: false'
28
+ def set(scraper_name, var_name, value)
29
+ # puts "options #{options}"
30
+ client = Client::ScraperVar.new(options)
31
+ puts "#{client.set(scraper_name, var_name, value, options)}"
32
+ end
33
+
34
+ desc "show <scraper_name> <var_name>", "Show an environment variable on the scraper"
35
+ def show(scraper_name, var_name)
36
+ client = Client::ScraperVar.new(options)
37
+ puts "#{client.find(scraper_name, var_name)}"
38
+ end
39
+
40
+ desc "unset <scraper_name> <var_name>", "Deletes an environment variable on the scraper"
41
+ def unset(scraper_name, var_name)
42
+ client = Client::ScraperVar.new(options)
43
+ puts "#{client.unset(scraper_name, var_name)}"
44
+ end
45
+ end
46
+ end
47
+
48
+ end
@@ -18,6 +18,8 @@ require "answersengine/client/job_output"
18
18
  require "answersengine/client/job_stat"
19
19
  require "answersengine/client/backblaze_content"
20
20
  require "answersengine/client/env_var"
21
+ require "answersengine/client/scraper_var"
22
+ require "answersengine/client/scraper_job_var"
21
23
 
22
24
 
23
25
  module AnswersEngine
@@ -0,0 +1,28 @@
1
+ module AnswersEngine
2
+ module Client
3
+ class ScraperJobVar < AnswersEngine::Client::Base
4
+
5
+ def find(scraper_name, var_name)
6
+ self.class.get("/scrapers/#{scraper_name}/current_job/vars/#{var_name}", @options)
7
+ end
8
+
9
+ def all(scraper_name, opts={})
10
+ params = @options.merge opts
11
+ self.class.get("/scrapers/#{scraper_name}/current_job/vars", params)
12
+ end
13
+
14
+ def set(scraper_name, var_name, value, opts={})
15
+ body = {}
16
+ body[:value] = value
17
+ body[:secret] = opts[:secret] if opts[:secret]
18
+ params = @options.merge({body: body.to_json})
19
+ self.class.put("/scrapers/#{scraper_name}/current_job/vars/#{var_name}", params)
20
+ end
21
+
22
+ def unset(scraper_name, var_name, opts={})
23
+ params = @options.merge(opts)
24
+ self.class.delete("/scrapers/#{scraper_name}/current_job/vars/#{var_name}", params)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,28 @@
1
+ module AnswersEngine
2
+ module Client
3
+ class ScraperVar < AnswersEngine::Client::Base
4
+
5
+ def find(scraper_name, var_name)
6
+ self.class.get("/scrapers/#{scraper_name}/vars/#{var_name}", @options)
7
+ end
8
+
9
+ def all(scraper_name, opts={})
10
+ params = @options.merge opts
11
+ self.class.get("/scrapers/#{scraper_name}/vars", params)
12
+ end
13
+
14
+ def set(scraper_name, var_name, value, opts={})
15
+ body = {}
16
+ body[:value] = value
17
+ body[:secret] = opts[:secret] if opts[:secret]
18
+ params = @options.merge({body: body.to_json})
19
+ self.class.put("/scrapers/#{scraper_name}/vars/#{var_name}", params)
20
+ end
21
+
22
+ def unset(scraper_name, var_name, opts={})
23
+ params = @options.merge(opts)
24
+ self.class.delete("/scrapers/#{scraper_name}/vars/#{var_name}", params)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module AnswersEngine
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: answersengine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Parama Danoesubroto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2019-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -200,7 +200,9 @@ files:
200
200
  - lib/answersengine/cli/scraper_export.rb
201
201
  - lib/answersengine/cli/scraper_exporter.rb
202
202
  - lib/answersengine/cli/scraper_job.rb
203
+ - lib/answersengine/cli/scraper_job_var.rb
203
204
  - lib/answersengine/cli/scraper_page.rb
205
+ - lib/answersengine/cli/scraper_var.rb
204
206
  - lib/answersengine/cli/seeder.rb
205
207
  - lib/answersengine/client.rb
206
208
  - lib/answersengine/client/auth_token.rb
@@ -223,6 +225,8 @@ files:
223
225
  - lib/answersengine/client/scraper_job.rb
224
226
  - lib/answersengine/client/scraper_job_output.rb
225
227
  - lib/answersengine/client/scraper_job_page.rb
228
+ - lib/answersengine/client/scraper_job_var.rb
229
+ - lib/answersengine/client/scraper_var.rb
226
230
  - lib/answersengine/plugin.rb
227
231
  - lib/answersengine/plugin/context_exposer.rb
228
232
  - lib/answersengine/scraper.rb