mechmarket 0.0.1 → 0.0.2

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: c5a5e075da555360a3d9c67ac5b0400ea5bf0ed2e7a0ec428af688b37933736d
4
- data.tar.gz: b0b7ce277c9f2f8dd5ded5645795c3e8fd99788fec36db91aa50a15f8d7fbdbe
3
+ metadata.gz: b6b7cd4cec8f72d7ce374b635adf2448032a76e328a8e801e104f255c21acab0
4
+ data.tar.gz: 73698bb7f99b07ef56a16247ea1f6f7997b695254352d0a775d0315cb27b5836
5
5
  SHA512:
6
- metadata.gz: c8c4fe6ec103170b0cb26167c102f88606e0283de9ac980f4c87f0001c1ed80f55c3733e3686cacbc5e749300e87c47575ee6ee126aa92c99a31124776b02981
7
- data.tar.gz: ad9f9e1d9ccaef2431268c2dcd1b725af374cf70f8ecd5227cf0aef33456a48df644a7b1b856972ab7f6d169360ab2f7b4b2f7ad26b75eb120643fe87e6bed96
6
+ metadata.gz: 01eea8bcae8009be52bc4f7638d076f182c265726b860a772aba294fa04324ac85e98247f74f32a918370b0da9dd293b70ddb8f0353a57e61f5c02fbb263dd15
7
+ data.tar.gz: 0f09122ae0466f96159cd68917495bb704f4e7ec663dc21ab414f0cb7e1662a0bf7dc126ea44e2e7c1be757c8c95afdfc646b728978e6207831c9227b2f7c3f2
data/.gitignore CHANGED
@@ -1,3 +1,2 @@
1
- config.yml
2
- db
3
1
  spec/examples.txt
2
+ *.gem
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mechmarket (0.0.1)
5
- httparty (~> 0.17.0)
6
- mail (~> 2.7.1)
7
- sqlite3 (~> 1.4.1)
4
+ mechmarket (0.0.2)
5
+ httparty (~> 0.17)
6
+ mail (~> 2.7)
7
+ sqlite3 (~> 1.4)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
@@ -66,11 +66,11 @@ PLATFORMS
66
66
  ruby
67
67
 
68
68
  DEPENDENCIES
69
- awesome_print
69
+ awesome_print (~> 1.8)
70
70
  mechmarket!
71
- rspec
72
- rubocop
73
- webmock
71
+ rspec (~> 3.8)
72
+ rubocop (~> 0.74)
73
+ webmock (~> 3.7)
74
74
 
75
75
  BUNDLED WITH
76
76
  1.16.6
@@ -4,28 +4,33 @@
4
4
  require 'bundler/setup'
5
5
  require 'mechmarket'
6
6
 
7
- config = Mechmarket::Config.new
8
- mechmarket = Mechmarket::Client.new
9
- posts = mechmarket.posts
10
- max_id = Mechmarket::Post.max_id
7
+ begin
8
+ config = Mechmarket::Config.new
9
+ mechmarket = Mechmarket::Client.new
10
+ posts = mechmarket.posts
11
+ max_id = Mechmarket::Post.max_id
11
12
 
12
- posts.each do |post|
13
- post.save if post.new_record?
14
- end
13
+ posts.each do |post|
14
+ post.save if post.new_record?
15
+ end
15
16
 
16
- config.queries.each do |query|
17
- hits = Mechmarket::Post.search(query: query, type: 'Selling', min_id: max_id)
18
- next if hits.empty?
17
+ config.queries.each do |query|
18
+ hits = Mechmarket::Post.search(query: query, type: 'Selling', min_id: max_id)
19
+ next if hits.empty?
19
20
 
20
- subject = "Potential r/mechmarket match for \"#{query}\""
21
- body = hits.map { |post| "#{post.age}m ago\n#{post.title}\n#{post.url}" }.join("\n\n")
22
- Mechmarket::Alert.deliver(config: config, subject: subject, body: body)
23
- end
21
+ subject = "Potential r/mechmarket match for \"#{query}\""
22
+ body = hits.map { |post| "#{post.age}m ago\n#{post.title}\n#{post.url}" }.join("\n\n")
23
+ Mechmarket::Alert.deliver(config: config, subject: subject, body: body)
24
+ end
24
25
 
25
- if posts.empty?
26
- puts 'API call failed. Check error logs.'
27
- exit(1)
28
- else
29
- puts "[#{Time.now}] Scanned #{posts.size} post(s) for #{config.queries.size} phrases(s)."
30
- exit(0)
26
+ if posts.empty?
27
+ puts 'API call failed. Check error logs.'
28
+ exit(1)
29
+ else
30
+ puts "[#{Time.now}] Scanned #{posts.size} post(s) for #{config.queries.size} phrases(s)."
31
+ exit(0)
32
+ end
33
+ rescue SQLite3::SQLException => e
34
+ puts 'Run mechmarket-migrate to create your database.'
35
+ raise e
31
36
  end
@@ -7,6 +7,7 @@ require 'mechmarket'
7
7
  begin
8
8
  puts "max_id: #{Mechmarket::Post.max_id}"
9
9
  puts "m65-a search: #{Mechmarket::Post.search(query: 'm65-a').map(&:title).inspect}"
10
- rescue SQLite3::CantOpenException
11
- puts 'You must run mechmarket-migrate first.'
10
+ rescue SQLite3::SQLException => e
11
+ puts 'Run mechmarket-migrate to create your database.'
12
+ raise e
12
13
  end
@@ -5,10 +5,13 @@ module Mechmarket
5
5
  attr_reader :username, :password, :queries
6
6
 
7
7
  def initialize
8
- config = YAML.load_file(File.expand_path('../../config.yml', __dir__))
9
- @username = config['username']
10
- @password = config['password']
11
- @queries = config['queries']
8
+ config = YAML.load_file("#{ENV['HOME']}/.mechmarket/mechmarket.yml")
9
+ @username = config['username']
10
+ @password = config['password']
11
+ @queries = config['queries']
12
+ rescue Errno::ENOENT => e
13
+ puts 'Add your username, password and queries to $HOME/.mechmarket/mechmarket.yml.'
14
+ raise e
12
15
  end
13
16
  end
14
17
  end
@@ -15,7 +15,7 @@ module Mechmarket
15
15
 
16
16
  class << self
17
17
  def database
18
- @database ||= SQLite3::Database.new(File.expand_path('../../db/mechmarket.db', __dir__))
18
+ @database ||= SQLite3::Database.new("#{ENV['HOME']}/.mechmarket/mechmarket.db")
19
19
  end
20
20
 
21
21
  def migrate(debug: false)
@@ -2,10 +2,10 @@
2
2
 
3
3
  # To publish the next version:
4
4
  # gem build mechmarket.gemspec
5
- # gem push mechmarket-0.0.1.gem
5
+ # gem push mechmarket-0.0.2.gem
6
6
  Gem::Specification.new do |s|
7
7
  s.name = 'mechmarket'
8
- s.version = '0.0.1'
8
+ s.version = '0.0.2'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.licenses = ['MIT']
11
11
  s.authors = ['Chris Estreich']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mechmarket
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Estreich
@@ -129,7 +129,6 @@ files:
129
129
  - bin/mechmarket-migrate
130
130
  - bin/mechmarket-run
131
131
  - bin/mechmarket-test
132
- - config-example.yml
133
132
  - lib/mechmarket.rb
134
133
  - lib/mechmarket/alert.rb
135
134
  - lib/mechmarket/client.rb
@@ -1,5 +0,0 @@
1
- username: my_username
2
- password: my_app_specific_password
3
- queries:
4
- - jelly key
5
- - mito laser