farmstead 0.0.47 → 0.0.48

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: 84f17c36d90a78c53393d73db4986e9826bfce69
4
- data.tar.gz: 752a9e161dda9bb050ab9725557c88f53206f941
3
+ metadata.gz: 76eed38e0bcb82ac852d9c5909f5b196e158dec9
4
+ data.tar.gz: 02c6768169ac7b44d792b1ac728ec2df7f291d6f
5
5
  SHA512:
6
- metadata.gz: 232d6b021ccf08e8215ea054d341c9587de06b92a9884264761549b273a87db05e6697d3cb8ce1df49f39248f4405edf7f92ff0723cdc4de7130746953f7c29d
7
- data.tar.gz: 226d4e3571fc41e451e350910f6680f174fc7a23b7d0ca4a4dcd1d921313e8642a6b5be5855166de8739c35f49cac3a810c08baf668fb1bcb31efd634ff35211
6
+ metadata.gz: 967d13b9a83c5ddc18439538a9a0fe152d115344095669d10439d2f2023ec050b803dbb8cde264e6fe0c22e8a045b7affbee440ed8693c1cd30a0994b42d2269
7
+ data.tar.gz: 5263d000b55a24a1196530c5c9c407d92f1774be5859713c0ddd9eb3c45569e0cb536d4d9f28991f8a459a91bef5d0a88bb89fc0f2b764dd6e468b1f9275334e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- farmstead (0.0.47)
4
+ farmstead (0.0.48)
5
5
  httparty (~> 0.15.6)
6
6
  mechanize (~> 2.7)
7
7
  mysql2 (~> 0.4.10)
@@ -8,9 +8,10 @@ module Farmstead
8
8
  Farmstead::DB.setup
9
9
  end
10
10
 
11
- desc "list", "List the sources"
12
- def list
13
- puts "List the sources"
11
+ desc "list table", "List all records in a table"
12
+ def list(table)
13
+ puts "List all records in a table"
14
+ Farmstead::DB.list(table)
14
15
  end
15
16
  end
16
17
  end
data/lib/farmstead/db.rb CHANGED
@@ -24,6 +24,23 @@ module Farmstead
24
24
  String(:type)
25
25
  String(:module)
26
26
  end
27
+ @@DB.create_table :test do
28
+ primary_key(:id)
29
+ String(:result)
30
+ end
31
+ end
32
+
33
+ def self.list(table)
34
+ self.pull_variables
35
+ ds = @@DB[table]
36
+ puts ds.all
37
+ end
38
+
39
+ # Insert an array of values into a table
40
+ def self.insert(table,array)
41
+ self.pull_variables
42
+ ds = @@DB[table]
43
+ ds.insert(array)
27
44
  end
28
45
 
29
46
  end
@@ -9,35 +9,23 @@
9
9
  # Every micro-service inherits the Service class
10
10
  module Farmstead
11
11
  module Extract
12
- class Producer < Farmstead::Service
12
+ class Service < Farmstead::Service
13
13
  def run
14
- loop do
15
- puts "Do something"
16
- sleep 300
17
- end
18
- end
19
- end
20
-
21
- # Subscribed to the Field topic
22
- # Works on message
23
- class Consumer < Farmstead::Service
24
- def run
25
- @consumer.subscribe('Field')
14
+ @consumer.subscribe("Field")
26
15
  trap('TERM') { @consumer.stop }
27
16
  @consumer.each_message do |message|
28
17
  puts "Received: #{message.value}"
29
- magic_work(message.value)
18
+ # Run the extract method of the module referenced by the message
19
+ obj = JSON.parse(message.value)
20
+ my_module = Object.const_get "<%= ENV['name'].capitalize %>::#{obj["module"]}"
21
+ result = my_module::extract
22
+ Farmstead::DB.insert("test",[result])
23
+ @producer.produce(result, topic: "Forest")
24
+ @producer.deliver_messages
30
25
  @consumer.mark_message_as_processed(message)
31
26
  end
32
27
  end
33
-
34
- def magic_work(site)
35
- hash = JSON.parse(site)
36
- hash['scarecrow'] = 'true'
37
- json = hash.to_json
38
- puts "Writing: #{json}"
39
- write_message(json, topic: 'Forest')
40
- end
41
28
  end
42
29
  end
43
30
  end
31
+
@@ -16,6 +16,7 @@ gem "omniauth-auth0", "~> 2.0.0"
16
16
  gem "puma", "~> 3.0"
17
17
  gem "ruby-kafka", "~> 0.5.1"
18
18
  gem "sass-rails", "~> 5.0"
19
+ gem "sequel", "~> 5.4.0"
19
20
  gem "turbolinks", "~> 5"
20
21
  gem "uglifier", ">= 1.3.0"
21
22
  gem "watir", "~> 6.10"
@@ -23,15 +23,6 @@ module Farmstead
23
23
  #@selenium_hub = ENV['SELENIUM_HUB']
24
24
  end
25
25
 
26
- def mysql_init
27
- @mysql = Mysql2::Client.new(
28
- host: @mysql_host,
29
- username: @mysql_user,
30
- password: @mysql_pass,
31
- database: @mysql_db
32
- )
33
- end
34
-
35
26
  # Runs on an infinite loop processing records
36
27
  # on MySQL DB and writing messages accordingly
37
28
  def producer
@@ -85,5 +76,13 @@ module Farmstead
85
76
  time1 = Time.new
86
77
  write_file(@logfile, "Current Time : #{time1.inspect}")
87
78
  end
79
+
80
+ def magic_work(body)
81
+ hash = JSON.parse(body)
82
+ hash['scarecrow'] = 'true'
83
+ json = hash.to_json
84
+ puts "Writing: #{json}"
85
+ write_message(json, topic: 'Forest')
86
+ end
88
87
  end
89
88
  end
@@ -1,3 +1,3 @@
1
1
  module Farmstead
2
- VERSION = "0.0.47"
2
+ VERSION = "0.0.48"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: farmstead
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.47
4
+ version: 0.0.48
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ken Jenney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-22 00:00:00.000000000 Z
11
+ date: 2018-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor