Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed errors on startup and Changed Dockerfile for local environments #183

Merged
merged 4 commits into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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" <[email protected]>
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