From e3337f6d116fcdd3e24c3a4b6c53b9d934eb8f96 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Nov 2016 17:22:02 +0200 Subject: [PATCH 01/13] write Fibonacci class --- hw1/fibonacci.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/hw1/fibonacci.rb b/hw1/fibonacci.rb index e69de29..b5b484a 100644 --- a/hw1/fibonacci.rb +++ b/hw1/fibonacci.rb @@ -0,0 +1,30 @@ +class Fibonacci + include Enumerable + + def initialize( n ) + @n = n + end + + def each + sequence = Array.new + sequence << 0 if @n == 0 + if @n > 1 + sequence << 1 + @n -= 1 + end + + x, y = 0, 1 + + (1..@n).map do + z = (x + y) + x = y + y = z + sequence << y.to_s + end + sequence.map(&:to_s) + end + + def map + each + end +end \ No newline at end of file From 8c40f04a7193930862fc6ab04408efaa91cfd1a1 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Nov 2016 18:15:48 +0200 Subject: [PATCH 02/13] implement Fibonacci class with yield --- hw1/fibonacci.rb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/hw1/fibonacci.rb b/hw1/fibonacci.rb index b5b484a..93e7486 100644 --- a/hw1/fibonacci.rb +++ b/hw1/fibonacci.rb @@ -6,25 +6,13 @@ def initialize( n ) end def each - sequence = Array.new - sequence << 0 if @n == 0 - if @n > 1 - sequence << 1 - @n -= 1 - end - x, y = 0, 1 - (1..@n).map do + @n.times do z = (x + y) x = y y = z - sequence << y.to_s + yield x end - sequence.map(&:to_s) - end - - def map - each end end \ No newline at end of file From bbe4499076e61ee49ff6960af1e2d8898121ed2e Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Thu, 17 Nov 2016 12:48:02 +0200 Subject: [PATCH 03/13] add router tests; re-write router to custom path --- hw2/app/app.rb | 6 +++++ hw2/lib/router.rb | 44 +++++++++++++++++++++++++++++----- hw2/spec/lib/router_spec.rb | 48 +++++++++++++++++++++++++++++-------- 3 files changed, 82 insertions(+), 16 deletions(-) diff --git a/hw2/app/app.rb b/hw2/app/app.rb index 2be87a8..1c7af9e 100644 --- a/hw2/app/app.rb +++ b/hw2/app/app.rb @@ -1,4 +1,10 @@ Application = Router.new do get '/test', ->(env) { [200, {}, ['get test']] } post '/test', ->(env) { [200, {}, ['post test']] } + + get '/users/:id', ->(env) { [200, {}, ['post /users/:id']] } + get '/users/:id/comments/:comment/rating/:rating', ->(env) { [200, {}, ['post with users comment rating']] } + get '/users/articles/:title', ->(env) { [200, {}, ['post with user articles title']] } + # get '/', ->(env) { [404, {}, ['page not found']] } + # get '/test/:id/with/:smth', ->(env) { [200, {}, ['get test with id value']] } end diff --git a/hw2/lib/router.rb b/hw2/lib/router.rb index eb6e53d..bd21ca9 100644 --- a/hw2/lib/router.rb +++ b/hw2/lib/router.rb @@ -1,25 +1,57 @@ class Router def call(env) - @routes[env['REQUEST_METHOD']][env['REQUEST_PATH']].call(env) + find_route(env).call(env) end private def initialize(&block) - @routes = {} + @routes = [] instance_exec(&block) end + def find_route(env) + # puts "call find_route #{@routes}" + @routes.each do |route| + # puts "#{env['REQUEST_METHOD']} ||||| #{route[:method]} ||||| #{env['REQUEST_PATH']} + # |||| #{route[:regexp]}" + if env['REQUEST_METHOD'] == route[:method] && env['REQUEST_PATH'] =~ route[:regexp] + # puts "return true if REQUEST_METHOD == method" + env['router.params'] = extract_params(route[:pattern], env['REQUEST_PATH']) + return route[:app] + end + end + + return ->(_env) { [404, {}, ['not found']] } + end + + + def path_to_regexp(path) + Regexp.new('\A' + path.gsub(/:[\w-]+/, '[\w-]+') + '\Z') + end + + def extract_params(pattern, path) + pattern + .split('/') + .zip(path.split('/')) + .reject { |e| e.first == e.last } + .map { |e| [e.first[1..-1], e.last] } + .to_h + end + + def match(http_method, path, rack_app) + # puts "call match" + @routes << { pattern: path, app: rack_app, regexp: path_to_regexp(path), method: http_method } + end + def get(path, rack_app) + # puts "call get" match('GET', path, rack_app) end def post(path, rack_app) + # puts "call post" match('POST', path, rack_app) end - def match(http_method, path, rack_app) - @routes[http_method] ||= {} - @routes[http_method][path] = rack_app - end end diff --git a/hw2/spec/lib/router_spec.rb b/hw2/spec/lib/router_spec.rb index e53a275..ba7e80d 100644 --- a/hw2/spec/lib/router_spec.rb +++ b/hw2/spec/lib/router_spec.rb @@ -4,15 +4,10 @@ get '/test', ->(env) { [200, {}, ['get test']] } post '/test', ->(env) { [200, {}, ['post test']] } - ## - # TODO: router should match path by pattern like - # Pattern: /posts/:name - # Paths: - # /post/about_ruby - # /post/43 - # Cover this with tests. - # - get '/post/:name', ->(env) { [200, {}, ['post show page']] } + get '/users/5', ->(env) { [200, {}, ['get /users/:id']] } + get '/users/5/comments/2/rating/4', ->(env) { [200, {}, ['get /users/:id/comments/:comment/rating/:rating']] } + get '/users/articles/14', ->(env) { [200, {}, ['get /users/articles/:title']]} + get '/', ->(env) { [404, {}, ['page not found']] } end end @@ -31,4 +26,37 @@ expect(subject.call(env)).to eq [200, {}, ['post test']] end end -end + + context 'router by pattern /users/:id' do + let(:env) { { 'REQUEST_PATH' => "/users/5", 'REQUEST_METHOD' => 'GET'} } + + it 'matches request' do + expect(subject.call(env)).to eq [200, {}, ['get /users/:id']] + end + end + + context 'router by pattern /users/:id/comments/:comment/rating/:rating' do + let(:env) { { 'REQUEST_PATH' => "/users/5/comments/2/rating/4", 'REQUEST_METHOD' => 'GET'} } + + it 'matches request' do + expect(subject.call(env)).to eq [200, {}, ['get /users/:id/comments/:comment/rating/:rating']] + end + end + + context 'router by pattern /users/articles/:title' do + let(:env) { { 'REQUEST_PATH' => "/users/articles/14", 'REQUEST_METHOD' => 'GET'} } + + it 'matches request' do + expect(subject.call(env)).to eq [200, {}, ['get /users/articles/:title']] + end + end + + context 'when path has parameter' do + let(:env) { { 'REQUEST_PATH' => "/", 'REQUEST_METHOD' => 'GET'} } + + it 'returns 404' do + expect(subject.call(env)).to eq [404, {}, ['page not found']] + end + end + +end \ No newline at end of file From 4f9964bd5b6cc8c7697636784487c2d600bdf9be Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Sun, 27 Nov 2016 12:54:38 +0200 Subject: [PATCH 04/13] copied controller --- hw2/Gemfile | 1 + hw2/Gemfile.lock | 4 +++- hw2/app/app.rb | 24 +++++++++++++------ hw2/lib/controller.rb | 36 ++++++++++++++++++++++++++++ hw2/lib/router.rb | 55 ++++++++++++++++++++++++++----------------- hw2/main.rb | 2 ++ 6 files changed, 93 insertions(+), 29 deletions(-) create mode 100644 hw2/lib/controller.rb diff --git a/hw2/Gemfile b/hw2/Gemfile index f8bf844..b9b145b 100644 --- a/hw2/Gemfile +++ b/hw2/Gemfile @@ -3,3 +3,4 @@ source "https://rubygems.org" gem "rack" gem "rspec" +gem "oj" \ No newline at end of file diff --git a/hw2/Gemfile.lock b/hw2/Gemfile.lock index ec73d13..3643f22 100644 --- a/hw2/Gemfile.lock +++ b/hw2/Gemfile.lock @@ -2,6 +2,7 @@ GEM remote: https://rubygems.org/ specs: diff-lcs (1.2.5) + oj (2.17.5) rack (2.0.1) rspec (3.5.0) rspec-core (~> 3.5.0) @@ -21,8 +22,9 @@ PLATFORMS ruby DEPENDENCIES + oj rack rspec BUNDLED WITH - 1.13.5 + 1.13.6 diff --git a/hw2/app/app.rb b/hw2/app/app.rb index 1c7af9e..d66610d 100644 --- a/hw2/app/app.rb +++ b/hw2/app/app.rb @@ -1,10 +1,20 @@ +class TestController < Controller + def show + response(:json, params) + end + + def test + response(:text, "Request method: #{request.request_method}") + end +end + Application = Router.new do - get '/test', ->(env) { [200, {}, ['get test']] } - post '/test', ->(env) { [200, {}, ['post test']] } + # get '/test', ->(env) { [200, {}, ['get test']] } + # post '/test', ->(env) { [200, {}, ['post test']] } + get '/post/:name/:other_one', 'test#show' + get '/test', 'test#test' + #get '/users/:id', ->(env) { [200, {}, ['post /users/:id']] } + # get '/users/:id/comments/:comment/rating/:rating', ->(env) { [200, {}, ['post with users comment rating']] } + # get '/users/articles/:title', ->(env) { [200, {}, ['post with user articles title']] } - get '/users/:id', ->(env) { [200, {}, ['post /users/:id']] } - get '/users/:id/comments/:comment/rating/:rating', ->(env) { [200, {}, ['post with users comment rating']] } - get '/users/articles/:title', ->(env) { [200, {}, ['post with user articles title']] } - # get '/', ->(env) { [404, {}, ['page not found']] } - # get '/test/:id/with/:smth', ->(env) { [200, {}, ['get test with id value']] } end diff --git a/hw2/lib/controller.rb b/hw2/lib/controller.rb new file mode 100644 index 0000000..6b69f58 --- /dev/null +++ b/hw2/lib/controller.rb @@ -0,0 +1,36 @@ +class Controller + RESPONSE_TYPES = { + text: ['text/plain', ->(c) { c.to_s }], + json: ['application/json', ->(c) { Oj.dump(c) }] + }.freeze + + def call(env) + @env = env + @request = Rack::Request.new(env) + @request.params.merge!(env['router.params'] || {}) + send(@action_name) + #TODO: fix hardcode + [200, @response_headers, [@response_body]] + end + + def self.action(action_name) + proc { |env| new(action_name).call(env) } + end + +private + attr_reader :request + + def initialize(action_name) + @action_name = action_name + end + + def params + request.params + end + + def response(type, content) + @response_headers ||= {} + @response_headers.merge!('Content-Type' => RESPONSE_TYPES[type][0]) + @response_body = RESPONSE_TYPES[type][1].call(content) + end +end diff --git a/hw2/lib/router.rb b/hw2/lib/router.rb index bd21ca9..bd737b5 100644 --- a/hw2/lib/router.rb +++ b/hw2/lib/router.rb @@ -11,12 +11,8 @@ def initialize(&block) end def find_route(env) - # puts "call find_route #{@routes}" @routes.each do |route| - # puts "#{env['REQUEST_METHOD']} ||||| #{route[:method]} ||||| #{env['REQUEST_PATH']} - # |||| #{route[:regexp]}" if env['REQUEST_METHOD'] == route[:method] && env['REQUEST_PATH'] =~ route[:regexp] - # puts "return true if REQUEST_METHOD == method" env['router.params'] = extract_params(route[:pattern], env['REQUEST_PATH']) return route[:app] end @@ -25,33 +21,50 @@ def find_route(env) return ->(_env) { [404, {}, ['not found']] } end - - def path_to_regexp(path) - Regexp.new('\A' + path.gsub(/:[\w-]+/, '[\w-]+') + '\Z') + def get(path, rack_app) + match('GET', path, rack_app) end - def extract_params(pattern, path) - pattern - .split('/') - .zip(path.split('/')) - .reject { |e| e.first == e.last } - .map { |e| [e.first[1..-1], e.last] } - .to_h + def post(path, rack_app) + match('POST', path, rack_app) end def match(http_method, path, rack_app) - # puts "call match" + rack_app = get_controller_action(rack_app) if rack_app.is_a?(String) @routes << { pattern: path, app: rack_app, regexp: path_to_regexp(path), method: http_method } end - def get(path, rack_app) - # puts "call get" - match('GET', path, rack_app) + def get_controller_action(str) + controller_name, action_name = str.split('#') # tests#show => ['tests', 'show'] + controller_name = to_upper_camel_case(controller_name) + Kernel.const_get(controller_name).send(:action, action_name) + # controller_name = public_test + # action_name = show + # PublicTestController.action('show') end - def post(path, rack_app) - # puts "call post" - match('POST', path, rack_app) + def to_upper_camel_case(str) + str # 'public_pages/tests' => PublicPages::TestsController + .split('/') # ['public_pages', 'test'] + .map { |part| part.split('_').map(&:capitalize).join } # ['PublicPages', 'Test'] + .join('::') + 'Controller' end + + # /post/:name + def path_to_regexp(path) + Regexp.new('\A' + path.gsub(/:[\w-]+/, '[\w-]+') + '\Z') + end + + # /post/:name + # /post/test_one + # { name: 'test_one' } + def extract_params(pattern, path) + pattern + .split('/') # ['post', ':name'] + .zip(path.split('/')) # [['post', 'post'],[':name', 'post']] + .reject { |e| e.first == e.last } # [[':name', 'post']] + .map { |e| [e.first[1..-1], e.last] } # [['name', 'post']] + .to_h + end end diff --git a/hw2/main.rb b/hw2/main.rb index acfd4b3..c196801 100644 --- a/hw2/main.rb +++ b/hw2/main.rb @@ -1,2 +1,4 @@ +require 'rack' +require './lib/controller' require './lib/router' require './app/app' From f1f0ced050b16a51413c2539c823866e3b8bada0 Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Sun, 27 Nov 2016 13:46:37 +0200 Subject: [PATCH 05/13] add rspec test to controller --- hw2/spec/lib/controller_spec.rb | 35 +++++++++++++++++++++++++++++++++ hw2/spec/spec_helper.rb | 3 +++ 2 files changed, 38 insertions(+) create mode 100644 hw2/spec/lib/controller_spec.rb diff --git a/hw2/spec/lib/controller_spec.rb b/hw2/spec/lib/controller_spec.rb new file mode 100644 index 0000000..2dec642 --- /dev/null +++ b/hw2/spec/lib/controller_spec.rb @@ -0,0 +1,35 @@ +RSpec.describe Controller do + let(:controller) do + + Class.new(Controller) do + def text_action + response(:text, 'test text') + end + + def json_action + response(:json, params) + end + + def data_params + response(:json, some_key: params['some_info']) + end + end + end + + context 'shows request status' do + it 'for action with text type' do + expect(controller.action(:text_action).call(Rack::MockRequest.env_for('/test_in_text'))) + .to eq([200, { 'Content-Type' => 'text/plain' }, ['test text']]) + end + + it 'for action with json type' do + expect(controller.action(:json_action).call(Rack::MockRequest.env_for('/test_in_json'))) + .to eq([200, { 'Content-Type' => 'application/json' }, ["{}"]]) + end + end + + it 'shows readed param from address line to params hash' do + expect(controller.action(:data_params).call(Rack::MockRequest.env_for('/test?some_info=key'))) + .to eq([200, { 'Content-Type' => 'application/json' }, ["{\":some_key\":\"key\"}"]]) + end +end diff --git a/hw2/spec/spec_helper.rb b/hw2/spec/spec_helper.rb index ef0fca6..4fe567d 100644 --- a/hw2/spec/spec_helper.rb +++ b/hw2/spec/spec_helper.rb @@ -1,3 +1,6 @@ +require 'rack' +require 'oj' +require './lib/controller' require './lib/router' RSpec.configure do |config| From 0c9872aae415d965611d1658c575444a75a604dd Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Sun, 27 Nov 2016 15:12:38 +0200 Subject: [PATCH 06/13] add accompanying comments to router and controller --- hw2/app/app.rb | 15 +++++++----- hw2/lib/controller.rb | 42 ++++++++++++++++----------------- hw2/lib/router.rb | 38 ++++++++++++++--------------- hw2/main.rb | 2 ++ hw2/spec/lib/controller_spec.rb | 2 +- hw2/spec/spec_helper.rb | 2 +- 6 files changed, 53 insertions(+), 48 deletions(-) diff --git a/hw2/app/app.rb b/hw2/app/app.rb index d66610d..7c74a80 100644 --- a/hw2/app/app.rb +++ b/hw2/app/app.rb @@ -1,18 +1,21 @@ -class TestController < Controller - def show +class TestController < Controller #inherit Controller class + def show # method show for return params response(:json, params) end - def test - response(:text, "Request method: #{request.request_method}") + def test # method test for return request method + response(:text, "Request method: #{request.request_method}") # params = "Request method: #{request.request_method}", end end -Application = Router.new do +Application = Router.new do # create new instance of Router + # get '/test', ->(env) { [200, {}, ['get test']] } # post '/test', ->(env) { [200, {}, ['post test']] } + get '/post/:name/:other_one', 'test#show' - get '/test', 'test#test' + get '/test', 'test#test' # "#{request.request_method} = get" + #get '/users/:id', ->(env) { [200, {}, ['post /users/:id']] } # get '/users/:id/comments/:comment/rating/:rating', ->(env) { [200, {}, ['post with users comment rating']] } # get '/users/articles/:title', ->(env) { [200, {}, ['post with user articles title']] } diff --git a/hw2/lib/controller.rb b/hw2/lib/controller.rb index 6b69f58..4849bfb 100644 --- a/hw2/lib/controller.rb +++ b/hw2/lib/controller.rb @@ -1,36 +1,36 @@ class Controller - RESPONSE_TYPES = { - text: ['text/plain', ->(c) { c.to_s }], - json: ['application/json', ->(c) { Oj.dump(c) }] - }.freeze + RESPONSE_TYPES = { # mini cheat, for work with response + text: ['text/plain', ->(c) { c.to_s }], # key where stored text params data + json: ['application/json', ->(c) { Oj.dump(c) }] # key where stored json + }.freeze # freeze this constant, for avoid random changing - def call(env) - @env = env - @request = Rack::Request.new(env) - @request.params.merge!(env['router.params'] || {}) - send(@action_name) - #TODO: fix hardcode - [200, @response_headers, [@response_body]] + def call(env) # env standart Rack params + @env = env # writed env into instance @env + @request = Rack::Request.new(env) # writed new rack request into instance @request + @request.params.merge!(env['router.params'] || {}) # merge with router.params if it exist + send(@action_name) # send @action_name + + [200, @response_headers, [@response_body]] # return array with route end - def self.action(action_name) - proc { |env| new(action_name).call(env) } + def self.action(action_name) # call action method for self object, action_name = call method name + proc { |env| new(action_name).call(env) } # proc create new action and call it end private - attr_reader :request + attr_reader :request # create getter for request - def initialize(action_name) - @action_name = action_name + def initialize(action_name) # init with, call method name + @action_name = action_name # writed action_name into instance @action_name end - def params + def params # params return request params request.params end - def response(type, content) - @response_headers ||= {} - @response_headers.merge!('Content-Type' => RESPONSE_TYPES[type][0]) - @response_body = RESPONSE_TYPES[type][1].call(content) + def response(type, content) #response in header and body + @response_headers ||= {} # if @response_headers empty assign hash + @response_headers.merge!('Content-Type' => RESPONSE_TYPES[type][0]) # merge @response_headers with 'Content-Type' => RESPONSE_TYPES[text]['some text'] + @response_body = RESPONSE_TYPES[type][1].call(content) # assign @response_body to RESPONSE_TYPES[json][some json] and call content arguments end end diff --git a/hw2/lib/router.rb b/hw2/lib/router.rb index bd737b5..b534818 100644 --- a/hw2/lib/router.rb +++ b/hw2/lib/router.rb @@ -1,49 +1,49 @@ class Router - def call(env) - find_route(env).call(env) + def call(env) # call method with env params + find_route(env).call(env) # call env end private - def initialize(&block) - @routes = [] - instance_exec(&block) + def initialize(&block) # initialize of code blok + @routes = [] # set to null @routes + instance_exec(&block) #call &block end - def find_route(env) - @routes.each do |route| + def find_route(env) # check if route exist + @routes.each do |route| # in @routes all route + # check if requst method of call and requst method of route matche + # and requst path of call math with route path if env['REQUEST_METHOD'] == route[:method] && env['REQUEST_PATH'] =~ route[:regexp] + # if all matches, assing to router.params extract params env['router.params'] = extract_params(route[:pattern], env['REQUEST_PATH']) - return route[:app] + return route[:app] # return applocation end end - return ->(_env) { [404, {}, ['not found']] } + return ->(_env) { [404, {}, ['not found']] } # if not exist return -> 404 end - def get(path, rack_app) + def get(path, rack_app) # get request match('GET', path, rack_app) end - def post(path, rack_app) + def post(path, rack_app) # post request match('POST', path, rack_app) end - def match(http_method, path, rack_app) + def match(http_method, path, rack_app) # match rack_app = get_controller_action(rack_app) if rack_app.is_a?(String) @routes << { pattern: path, app: rack_app, regexp: path_to_regexp(path), method: http_method } end def get_controller_action(str) controller_name, action_name = str.split('#') # tests#show => ['tests', 'show'] - controller_name = to_upper_camel_case(controller_name) + controller_name = to_upper_camel_case(controller_name)# ['tests', 'show'] => ['TestsController', 'show'] Kernel.const_get(controller_name).send(:action, action_name) - # controller_name = public_test - # action_name = show - # PublicTestController.action('show') end - def to_upper_camel_case(str) + def to_upper_camel_case(str) # up str # 'public_pages/tests' => PublicPages::TestsController .split('/') # ['public_pages', 'test'] .map { |part| part.split('_').map(&:capitalize).join } # ['PublicPages', 'Test'] @@ -52,7 +52,7 @@ def to_upper_camel_case(str) # /post/:name - def path_to_regexp(path) + def path_to_regexp(path) # return processing path Regexp.new('\A' + path.gsub(/:[\w-]+/, '[\w-]+') + '\Z') end @@ -65,6 +65,6 @@ def extract_params(pattern, path) .zip(path.split('/')) # [['post', 'post'],[':name', 'post']] .reject { |e| e.first == e.last } # [[':name', 'post']] .map { |e| [e.first[1..-1], e.last] } # [['name', 'post']] - .to_h + .to_h # { name = > post } end end diff --git a/hw2/main.rb b/hw2/main.rb index c196801..c7ac84b 100644 --- a/hw2/main.rb +++ b/hw2/main.rb @@ -1,4 +1,6 @@ require 'rack' +require 'oj' + require './lib/controller' require './lib/router' require './app/app' diff --git a/hw2/spec/lib/controller_spec.rb b/hw2/spec/lib/controller_spec.rb index 2dec642..c47d329 100644 --- a/hw2/spec/lib/controller_spec.rb +++ b/hw2/spec/lib/controller_spec.rb @@ -29,7 +29,7 @@ def data_params end it 'shows readed param from address line to params hash' do - expect(controller.action(:data_params).call(Rack::MockRequest.env_for('/test?some_info=key'))) + expect(controller.action(:data_params).call(Rack::MockRequest.env_for('/message?some_info=key'))) .to eq([200, { 'Content-Type' => 'application/json' }, ["{\":some_key\":\"key\"}"]]) end end diff --git a/hw2/spec/spec_helper.rb b/hw2/spec/spec_helper.rb index 4fe567d..f35e583 100644 --- a/hw2/spec/spec_helper.rb +++ b/hw2/spec/spec_helper.rb @@ -1,5 +1,5 @@ require 'rack' -require 'oj' +require 'oj' #optimized json require './lib/controller' require './lib/router' From 7b59624272b42cc7d503323bad2f3f7f6eee7002 Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Tue, 13 Dec 2016 15:01:16 +0200 Subject: [PATCH 07/13] add hw3/hw4 --- .travis.yml | 10 +++++++--- Gemfile~ | 4 ++++ check.sh | 1 - hw3 | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 Gemfile~ delete mode 100644 check.sh create mode 160000 hw3 diff --git a/.travis.yml b/.travis.yml index 2d528b0..1aa0ada 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,9 @@ +sudo: false language: ruby rvm: - - 2.3.1 -script: - - bash check.sh + - 2.3.0 +before_install: + - gem install bundler -v 1.13.2 + - gem install rake -v 10.0 + - gem install oj -v 2.17.5 + - gem install rspec -v 3.5.0 diff --git a/Gemfile~ b/Gemfile~ new file mode 100644 index 0000000..7db8998 --- /dev/null +++ b/Gemfile~ @@ -0,0 +1,4 @@ +# frozen_string_literal: true +source "https://rubygems.org" + +# gem "rails" diff --git a/check.sh b/check.sh deleted file mode 100644 index ce6c4ea..0000000 --- a/check.sh +++ /dev/null @@ -1 +0,0 @@ -ruby ./hw1/fibonacci_test.rb && (cd hw2 && bundle install && bundle exec rspec) diff --git a/hw3 b/hw3 new file mode 160000 index 0000000..fd37b12 --- /dev/null +++ b/hw3 @@ -0,0 +1 @@ +Subproject commit fd37b12d9965848b4e73e37d28a2eaa3e60276bc From b09568f311d39e4e237ee5f09f36ef1f4ab24322 Mon Sep 17 00:00:00 2001 From: Sergei Lysenko Date: Tue, 13 Dec 2016 15:03:06 +0200 Subject: [PATCH 08/13] Create README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..d0a534c --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# kottans_2016_homeworks + +gem https://github.com/lysenko-sergei-developer/lysenko_kottans_rack +travis https://travis-ci.org/lysenko-sergei-developer/lysenko_kottans_rack From d1d758ad382ad04f699d5ccbe7662a8b09d05fb4 Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Tue, 13 Dec 2016 15:12:56 +0200 Subject: [PATCH 09/13] add Rakefile --- Rakefile | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Rakefile diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..43022f7 --- /dev/null +++ b/Rakefile @@ -0,0 +1,2 @@ +require "bundler/gem_tasks" +task :default => :spec From 1ea87842c0514a9183519fc5021a4b2bb6e9a443 Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Tue, 13 Dec 2016 15:16:08 +0200 Subject: [PATCH 10/13] add check.sh file --- check.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 check.sh diff --git a/check.sh b/check.sh new file mode 100644 index 0000000..7265d9e --- /dev/null +++ b/check.sh @@ -0,0 +1 @@ +ruby ./hw1/fiboacci_test.rb && (cd hw2 && bundle install && bundle exec rspec) From 11631d6912925cf06f557a440348c8165bf84d0f Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Tue, 13 Dec 2016 15:33:23 +0200 Subject: [PATCH 11/13] some fix in rakefile --- Gemfile~ | 4 ---- Rakefile | 2 -- 2 files changed, 6 deletions(-) delete mode 100644 Gemfile~ delete mode 100644 Rakefile diff --git a/Gemfile~ b/Gemfile~ deleted file mode 100644 index 7db8998..0000000 --- a/Gemfile~ +++ /dev/null @@ -1,4 +0,0 @@ -# frozen_string_literal: true -source "https://rubygems.org" - -# gem "rails" diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 43022f7..0000000 --- a/Rakefile +++ /dev/null @@ -1,2 +0,0 @@ -require "bundler/gem_tasks" -task :default => :spec From 65de5f065ff239380f0c622ec4b947c4f64474ab Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Tue, 13 Dec 2016 15:46:15 +0200 Subject: [PATCH 12/13] some fix --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1aa0ada..f3f835d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,8 +2,5 @@ sudo: false language: ruby rvm: - 2.3.0 -before_install: - - gem install bundler -v 1.13.2 - - gem install rake -v 10.0 - - gem install oj -v 2.17.5 - - gem install rspec -v 3.5.0 +script: + - bash check.sh From 0b7439d07e0fe010551af30f88075221a5f63150 Mon Sep 17 00:00:00 2001 From: Sergey Lysenko Date: Tue, 13 Dec 2016 16:16:22 +0200 Subject: [PATCH 13/13] some fix --- check.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check.sh b/check.sh index 7265d9e..ce6c4ea 100644 --- a/check.sh +++ b/check.sh @@ -1 +1 @@ -ruby ./hw1/fiboacci_test.rb && (cd hw2 && bundle install && bundle exec rspec) +ruby ./hw1/fibonacci_test.rb && (cd hw2 && bundle install && bundle exec rspec)