jyaasa_interviewer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/interview +17 -0
- data/data/questions.yaml +72 -0
- data/lib/answer_formator.rb +16 -0
- data/lib/interview.rb +34 -0
- data/lib/interview_cli.rb +12 -0
- data/lib/question.rb +16 -0
- data/lib/question_set.rb +21 -0
- data/lib/user.rb +10 -0
- data/lib/utils.rb +26 -0
- metadata +53 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 60b6e2c34eb7b6d0203567faf5783f5b0e52b00d
|
4
|
+
data.tar.gz: 5b36c96a970ae63710f213131413b430418937c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c1addcda442a1cc919dd4d06d6ccc59cf80036ddaa91c9da307ed7562ddfb453e99b304cd349115dad2a417d57d1ced28784f5559d1532a4138f4ff0580834d6
|
7
|
+
data.tar.gz: b50fa21b05d0a18755a738411ada9bde0d7f5cfa5166ce1b7ba3a16aadaf7abfc2b78e4cbc6dd75fa9e72ae4cf8a222d80a04d528f4395e96ca20d74fe67e0a4
|
data/bin/interview
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'thor'
|
3
|
+
require "highline/import"
|
4
|
+
require "yaml"
|
5
|
+
require "pry"
|
6
|
+
require "colorize"
|
7
|
+
require 'rest-client'
|
8
|
+
require 'fileutils'
|
9
|
+
require './lib/interview_cli'
|
10
|
+
require './lib/user'
|
11
|
+
require './lib/interview'
|
12
|
+
require './lib/question'
|
13
|
+
require './lib/question_set'
|
14
|
+
require './lib/answer_formator'
|
15
|
+
require './lib/utils'
|
16
|
+
|
17
|
+
InterviewCLI.start
|
data/data/questions.yaml
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
Simple questions:
|
2
|
+
- Difference between symbol and string in rails.
|
3
|
+
- Explain how (almost) everything is an object in Ruby
|
4
|
+
- What’s your favorite testing tool?
|
5
|
+
- What are Gems and which are some of your favorites?
|
6
|
+
- What is a class?
|
7
|
+
- What is the difference between a class and a module?
|
8
|
+
- What is an object?
|
9
|
+
- How would you declare and use a constructor in Ruby?
|
10
|
+
- How and when would you declare a Global Variable?
|
11
|
+
- How would you create getter and setter methods in Ruby?
|
12
|
+
- Describe the difference between class and instance variables?
|
13
|
+
- Explain some of the looping structures available in Ruby?
|
14
|
+
- Explain the difference between a has_one and belongs_to association
|
15
|
+
- Explain a polymorphic association
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
MEDIUM/HARD QUESTIONS:
|
20
|
+
- What is a Proc?
|
21
|
+
- What is a lambda?
|
22
|
+
- What are the three levels of method access control for classes and what do they signify? What do they imply about the method?
|
23
|
+
- Explain what functional testing is
|
24
|
+
- There are three ways to invoke a method in ruby. Can you give me at least two?
|
25
|
+
- Explain this ruby idiom a ||= b
|
26
|
+
- What does self mean?
|
27
|
+
- What is unit testing (in classical terms)? What is the primary technique when writing a test?
|
28
|
+
- |
|
29
|
+
What is the primary difference in these two code snippets?
|
30
|
+
// Java
|
31
|
+
public boolean isEmpty(String s) {
|
32
|
+
return s.length() == 0;
|
33
|
+
}
|
34
|
+
# ruby
|
35
|
+
def empty?(s)
|
36
|
+
return s.size == 0
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
- What is your favorite api resource for ruby?
|
41
|
+
- What is the difference between Ruby’s Hash and ActiveSupport’s HashWithIndifferentAccess?
|
42
|
+
- What is CSRF? How does Rails protect against it?
|
43
|
+
- How would you define a Person model so that any Person can be assigned as the parent of another Person (as demonstrated in the Rails console below)? What columns would you need to define in the migration creating the table for Person?
|
44
|
+
- |
|
45
|
+
What paths (HTTP verb and URL) will be defined by the following snippet in config/routes.rb?
|
46
|
+
resources :posts do
|
47
|
+
member do
|
48
|
+
get 'comments'
|
49
|
+
end
|
50
|
+
collection do
|
51
|
+
post 'bulk_upload'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
- |
|
56
|
+
Create a route to be able to display pages with different information about different types of beer. The route should recognize URL paths like /beer/<beer_type> and should use the same controller action for each type of beer with the actually beer type passed into the controller action as a parameter. The valid beer types are as follows
|
57
|
+
IPA
|
58
|
+
brown_ale
|
59
|
+
pilsner
|
60
|
+
lager
|
61
|
+
lambic
|
62
|
+
hefeweizen
|
63
|
+
Any other type of beer specified should generate a 404 status code.
|
64
|
+
- A Rails-specific question how Date.today differs from Date.current?
|
65
|
+
- What is database transactions and how it is represented in Rails.
|
66
|
+
- Tell me about your development environment.
|
67
|
+
|
68
|
+
|
69
|
+
Practical Ruby Questions:
|
70
|
+
- web scraping . Write a ruby program that gets the headlines for the users displayed from todays edition of ekantipur.com
|
71
|
+
|
72
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class AnswerFormator
|
2
|
+
attr_accessor :formatted_content
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@formatted_content = ""
|
6
|
+
end
|
7
|
+
|
8
|
+
def format(interview)
|
9
|
+
user = interview.user
|
10
|
+
@formatted_content += "email: #{user.email}\n"
|
11
|
+
@formatted_content += "name: #{user.name}\n"
|
12
|
+
interview.questions.each{|q|
|
13
|
+
@formatted_content += "\nQuestion: #{q.text} \n Answer: #{q.answer} \n\n"
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
data/lib/interview.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
class Interview
|
2
|
+
attr_accessor :user, :questions, :formator
|
3
|
+
def initialize(user)
|
4
|
+
@user = user
|
5
|
+
@formator = AnswerFormator.new
|
6
|
+
get_questions
|
7
|
+
end
|
8
|
+
|
9
|
+
def get_questions
|
10
|
+
set = QuestionSet.new
|
11
|
+
@questions= set.questions
|
12
|
+
end
|
13
|
+
|
14
|
+
def start
|
15
|
+
$/ = "\nsubmit"
|
16
|
+
@questions.each {|question|
|
17
|
+
say "\n**Here is your question: (Type the answer into the console. Type 'submit' and press enter in new line to submit your answer for the question)**\n\n".red
|
18
|
+
question.answer = ask(question.text.blue).gsub('submit','')
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def submit
|
23
|
+
@formator.format(self)
|
24
|
+
file_path = "#{Dir.pwd}/tmp/#{@user.name}.txt"
|
25
|
+
Utils.write(file_path,@formator.formatted_content)
|
26
|
+
Utils.send_to_jyaasa(file_path,@user)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
def show
|
32
|
+
@formator.formatted_content
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class InterviewCLI < Thor
|
2
|
+
desc "start", "start the interview"
|
3
|
+
def start
|
4
|
+
name = ask "\nEnter your full name.".green
|
5
|
+
email = ask( "\nEnter your email address to get back to you. ".green) { |q| q.echo = '*' }
|
6
|
+
user = User.new(name,email)
|
7
|
+
interview = Interview.new(user)
|
8
|
+
interview.start
|
9
|
+
interview.submit
|
10
|
+
Utils.clear_tmp
|
11
|
+
end
|
12
|
+
end
|
data/lib/question.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
class Question
|
2
|
+
attr_accessor :text, :answer
|
3
|
+
|
4
|
+
def initialize(question=nil)
|
5
|
+
@text = question
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.build(question_list)
|
9
|
+
container = []
|
10
|
+
question_list.each {|question|
|
11
|
+
container << self.new(question)
|
12
|
+
}
|
13
|
+
container
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/question_set.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
class QuestionSet
|
2
|
+
attr_accessor :questions_pool, :questions
|
3
|
+
def initialize
|
4
|
+
@questions_pool = load_pool
|
5
|
+
@questions =Array.new
|
6
|
+
self.fetch
|
7
|
+
end
|
8
|
+
|
9
|
+
def fetch
|
10
|
+
categories = @questions_pool.keys
|
11
|
+
categories.each { |category|
|
12
|
+
@questions +=Question.build(@questions_pool[category].sample(1))
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def load_pool
|
18
|
+
YAML.load(File.read('./data/questions.yaml'))
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/lib/user.rb
ADDED
data/lib/utils.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
class Utils
|
2
|
+
|
3
|
+
def self.write(path, content)
|
4
|
+
dirname = File.dirname(path)
|
5
|
+
unless File.directory?(dirname)
|
6
|
+
FileUtils.mkdir_p(dirname)
|
7
|
+
end
|
8
|
+
path = File.open(path, 'w') { |file| file.write(content) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.send_to_jyaasa(file_path,user)
|
12
|
+
RestClient.post('https://getsimpleform.com/messages', :form_api_token => '272fb8189aa754dc5e74cec3922b9401', :name => user.name, :email => user.email, :attachment => File.new(file_path, 'rb')) do |response, request, result, &block|
|
13
|
+
if [301, 302, 307].include? response.code
|
14
|
+
redirected_url = response.headers[:location]
|
15
|
+
else
|
16
|
+
response.return!(request, result, &block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
say "You response has been emailed to Jyaasa Technologies".green
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.clear_tmp
|
23
|
+
FileUtils.rm_rf(Dir.glob("#{Dir.pwd}/tmp/"))
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jyaasa_interviewer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kapil Raj Nakhwa (@xecutioner303)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Command line utility for remote interview at Jyaasa Technologies
|
14
|
+
email: kapilnakhwa@gmail.com
|
15
|
+
executables:
|
16
|
+
- interview
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- bin/interview
|
21
|
+
- data/questions.yaml
|
22
|
+
- lib/answer_formator.rb
|
23
|
+
- lib/interview.rb
|
24
|
+
- lib/interview_cli.rb
|
25
|
+
- lib/question.rb
|
26
|
+
- lib/question_set.rb
|
27
|
+
- lib/user.rb
|
28
|
+
- lib/utils.rb
|
29
|
+
homepage: http://rubygems.org/gems/jyaasa_interviewer
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata: {}
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 2.4.6
|
50
|
+
signing_key:
|
51
|
+
specification_version: 4
|
52
|
+
summary: Command line utility for remote interview
|
53
|
+
test_files: []
|