Skip to content

Commit

Permalink
Added update executable
Browse files Browse the repository at this point in the history
  • Loading branch information
jusleg committed Jan 31, 2018
1 parent c0e4897 commit 957e7de
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## V0.3.0
Introduction quotify CLI. Pretty barebone implementation with update method. `quotify update` or `quotify u` updates the database.

## V0.2.0
Saves the quotes in memory to prevent too many IO operations. Added configs that can be updated at runtime. `quotes.yml` only works with symbols as keys. From now on, prioritize symbols over strings. A new field `updated_at` was added to `quotes.yml` to allow for updating quotes using gem command. This will be added in the future.

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GEM
docile (1.1.5)
json (2.1.0)
metaclass (0.0.4)
minitest (5.11.1)
minitest (5.11.3)
mocha (1.3.0)
metaclass (~> 0.0.1)
rake (12.3.0)
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ Quotify::Quote.new.to_s(spacer: " 🔥 ")
Quotify.configure_with(File.join(__dir__, 'custom_quotes.yml'))
```

## Update the quote database
To pull the newest database version with all those spicy quotes, run `quotify update` or `quotify u` in the terminal.

## Contributing
You can run all the tests with:
```
Expand Down
26 changes: 26 additions & 0 deletions bin/quotify
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env ruby

require 'quotify'
require 'HTTParty'
require 'yaml'
require 'pry'

if ARGV[0] == 'update' || ARGV[0] == 'u'
puts "-------------------------------------\n"\
" ____ __ _ ____
/ __ \\__ ______ / /_(_) __/_ __
/ / / / / / / __ \\/ __/ / /_/ / / /
/ /_/ / /_/ / /_/ / /_/ / __/ /_/ /
\\___\\_\\__,_/\\____/\\__/_/_/ \\__, /
/____/ \n"\
"-------------------------------------\n"\
"#{Quotify.generate}\n\n"
payload = YAML.load(HTTParty.get('https://raw.githubusercontent.com/jusleg/quotify-ruby/master/lib/quotify/quotes.yml'))

if Quotify.config[:updated_at] < payload[:updated_at]
File.write(File.join(__dir__, '../lib/quotify/quotes.yml'), payload.to_yaml)
puts "Updated the quote database. Enjoy the new quotes. As always, believe in yourself.\n\n"
else
puts "Nothing to update\n\n"
end
end
7 changes: 4 additions & 3 deletions quotify.gemspec
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
Gem::Specification.new do |s|
s.name = 'quotify'
s.version = '0.2.0'
s.date = '2018-01-04'
s.version = '0.3.0'
s.date = '2018-01-31'
s.summary = 'Generates random quotes'
s.description = 'Generates random quotes. Perfect placeholder text.'
s.author = 'Justin Leger'
s.email = '[email protected]'
s.files = ['lib/quotify/quotes.yml', 'lib/quotify/quote.rb', 'lib/quotify.rb', 'LICENSE', 'CHANGELOG.md']
s.homepage = 'https://github.com/jusleg/quotify-ruby'
s.license = 'MIT'
s.executables << 'quotify'

s.metadata = {
"source_code_uri" => "https://github.com/jusleg/quotify-ruby",
"changelog_uri" => "https://github.com/jusleg/quotify-ruby/blob/master/CHANGELOG.md"
}

s.add_dependency 'json'
s.add_development_dependency "rake"
s.add_development_dependency 'rake'
s.add_development_dependency 'mocha'
s.add_development_dependency 'minitest'
s.add_development_dependency 'simplecov'
Expand Down

0 comments on commit 957e7de

Please sign in to comment.