Skip to content

Commit

Permalink
Merge pull request #183 from oieioi/fix-outdated
Browse files Browse the repository at this point in the history
Fixed errors on startup and Changed Dockerfile for local environments
  • Loading branch information
jugyo committed Nov 17, 2017
2 parents 42edb45 + 32e9cdc commit 6ff0a5e
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
vendor/
Gemfile.lock
.bundle/
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ pkg
#*.swp
consumer.yml
Gemfile.lock

/vendor/
.ruby-version
26 changes: 11 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
# Based on the Fedora image
FROM fedora
FROM ruby:2.4.2

MAINTAINER "Maciej Lasyk" <maciek@lasyk.info>
RUN apt-get update
RUN apt-get install -y libssl-dev git locales locales-all
ENV LANG C.UTF-8

# install main packages:
RUN yum -y update
RUN yum -y install openssl-devel openssl readline readline-devel gcc gcc-c++ rubygems rubygems-devel ruby ruby-devel
RUN gem install bundler
RUN gem install earthquake -v 1.0.2

# install earthquake
RUN gem install earthquake

# set the env:
RUN useradd -d /home/twitter twitter
USER twitter
ENV HOME /home/twitter
WORKDIR /home/twitter

CMD ["earthquake"]
WORKDIR /root/earthquake
COPY . .
RUN bundle install
RUN cp /usr/local/bundle/gems/earthquake-1.0.2/consumer.yml ./
CMD ["bundle", "exec", "ruby", "./bin/earthquake"]
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ source "http://rubygems.org"

# Specify your gem's dependencies in earthquake.gemspec
gemspec

gem 'twitter-stream', git: 'https://github.com/voloko/twitter-stream.git'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Quick-installation using Docker (http://docker.io)

Just clone the repo and:

$ sudo docker build -t earthquake .
$ sudo docker run --rm -i -name earthquake -t earthquake
$ docker build -t earthquake .
$ docker run --rm -v $HOME/.earthquake:/root/.earthquake -it earthquake

Normall installation
-----
Expand Down
5 changes: 4 additions & 1 deletion earthquake.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

# for twitter-stream
s.add_runtime_dependency "eventmachine", "= 1.0.5"
s.add_runtime_dependency "twitter-stream"
s.add_runtime_dependency "notify"
s.add_runtime_dependency "i18n"
Expand All @@ -27,7 +29,8 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "oauth"
s.add_runtime_dependency "jugyo-twitter_oauth", "= 0.5.0.pre5"
s.add_runtime_dependency "slop", "~> 3.4.0"
s.add_development_dependency "rspec", "~> 2.0"
s.add_development_dependency "rake", '< 11.0'
s.add_development_dependency "rspec"
s.add_development_dependency "bundler"

# specify any dependencies here; for example:
Expand Down
9 changes: 5 additions & 4 deletions lib/earthquake/twitter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,22 @@ module Twitter
end

once do
class ::TwitterOAuth::Client
module ClientWithCache
[:status, :info].each do |m|
define_method("#{m}_with_cache") do |*args|
define_method(m) do |*args|
key = "#{m}:#{args.join(',')}"
if result = Earthquake.cache.read(key)
result.dup
else
result = __send__(:"#{m}_without_cache", *args)
result = super *args
Earthquake.cache.write(key, result.dup)
result
end
end
alias_method_chain m, :cache
end
end

::TwitterOAuth::Client.prepend(ClientWithCache)
end

extend Twitter
Expand Down
18 changes: 4 additions & 14 deletions spec/earthquake_option_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
it 'parses debug option' do
%w{-d --debug}.each do |opt|
options = Earthquake::OptionParser.new([opt]).parse
expect(options[:debug]).to be_true
expect(options[:debug]).to be_truthy
end
end

it 'parses no-logo option' do
%w{-n --no-logo}.each do |opt|
options = Earthquake::OptionParser.new([opt]).parse
expect(options[:'no-logo']).to be_true
expect(options[:'no-logo']).to be_truthy
end
end

Expand All @@ -32,7 +32,7 @@

it 'parses no-stream option' do
options = Earthquake::OptionParser.new(['--no-stream']).parse
expect(options[:'no-stream']).to be_true
expect(options[:'no-stream']).to be_truthy
end

def with_test_output_stream(out, &block)
Expand All @@ -45,17 +45,7 @@ def with_test_output_stream(out, &block)
end

it 'parses help option' do
old_stderr = $stderr
begin
$stderr = out = StringIO.new
Earthquake::OptionParser.new(['--help']).parse
out.close
expect(out.string).to match(/^Usage: /)
rescue => e
# do nothing
ensure
$stderr = old_stderr
end
expect{ Earthquake::OptionParser.new(['--help']).parse }.to output(/^Usage: /).to_stdout
end

it 'raises exception for invalid option' do
Expand Down

0 comments on commit 6ff0a5e

Please sign in to comment.