File tree Expand file tree Collapse file tree 11 files changed +171
-0
lines changed
developing/testing_applications Expand file tree Collapse file tree 11 files changed +171
-0
lines changed Original file line number Diff line number Diff line change
1
+ --require spec_helper
Original file line number Diff line number Diff line change
1
+ FROM ruby:2.4.3-alpine
2
+
3
+ RUN apk add --no-cache \
4
+ build-base
5
+
6
+ WORKDIR /tmp
7
+
8
+ COPY Gemfile* ./
9
+ RUN bundle install
10
+
11
+ WORKDIR /app
12
+
13
+ ENV PATH=./bin:$PATH
14
+
15
+ CMD ["client" ]
Original file line number Diff line number Diff line change
1
+ source "https://rubygems.org"
2
+
3
+ gem 'activesupport'
4
+ gem "rspec"
Original file line number Diff line number Diff line change
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (5.1.4 )
5
+ concurrent-ruby (~> 1.0 , >= 1.0.2 )
6
+ i18n (~> 0.7 )
7
+ minitest (~> 5.1 )
8
+ tzinfo (~> 1.1 )
9
+ coderay (1.1.2 )
10
+ concurrent-ruby (1.0.5 )
11
+ diff-lcs (1.3 )
12
+ ffi (1.9.21 )
13
+ formatador (0.2.5 )
14
+ guard (2.14.2 )
15
+ formatador (>= 0.2.4 )
16
+ listen (>= 2.7 , < 4.0 )
17
+ lumberjack (>= 1.0.12 , < 2.0 )
18
+ nenv (~> 0.1 )
19
+ notiffany (~> 0.0 )
20
+ pry (>= 0.9.12 )
21
+ shellany (~> 0.0 )
22
+ thor (>= 0.18.1 )
23
+ guard-compat (1.2.1 )
24
+ guard-rspec (4.7.3 )
25
+ guard (~> 2.1 )
26
+ guard-compat (~> 1.1 )
27
+ rspec (>= 2.99.0 , < 4.0 )
28
+ i18n (0.9.1 )
29
+ concurrent-ruby (~> 1.0 )
30
+ listen (3.1.5 )
31
+ rb-fsevent (~> 0.9 , >= 0.9.4 )
32
+ rb-inotify (~> 0.9 , >= 0.9.7 )
33
+ ruby_dep (~> 1.2 )
34
+ lumberjack (1.0.12 )
35
+ method_source (0.9.0 )
36
+ minitest (5.10.3 )
37
+ nenv (0.3.0 )
38
+ notiffany (0.1.1 )
39
+ nenv (~> 0.1 )
40
+ shellany (~> 0.0 )
41
+ pry (0.11.3 )
42
+ coderay (~> 1.1.0 )
43
+ method_source (~> 0.9.0 )
44
+ rb-fsevent (0.10.2 )
45
+ rb-inotify (0.9.10 )
46
+ ffi (>= 0.5.0 , < 2 )
47
+ rspec (3.7.0 )
48
+ rspec-core (~> 3.7.0 )
49
+ rspec-expectations (~> 3.7.0 )
50
+ rspec-mocks (~> 3.7.0 )
51
+ rspec-core (3.7.1 )
52
+ rspec-support (~> 3.7.0 )
53
+ rspec-expectations (3.7.0 )
54
+ diff-lcs (>= 1.2.0 , < 2.0 )
55
+ rspec-support (~> 3.7.0 )
56
+ rspec-mocks (3.7.0 )
57
+ diff-lcs (>= 1.2.0 , < 2.0 )
58
+ rspec-support (~> 3.7.0 )
59
+ rspec-support (3.7.1 )
60
+ ruby_dep (1.5.0 )
61
+ shellany (0.0.1 )
62
+ thor (0.20.0 )
63
+ thread_safe (0.3.6 )
64
+ tzinfo (1.2.4 )
65
+ thread_safe (~> 0.1 )
66
+
67
+ PLATFORMS
68
+ ruby
69
+
70
+ DEPENDENCIES
71
+ activesupport
72
+ guard-rspec
73
+ rspec
74
+
75
+ BUNDLED WITH
76
+ 1.15.4
Original file line number Diff line number Diff line change
1
+ require 'active_support/all'
2
+ class AnagramChecker
3
+ def anagram? ( a , b )
4
+ return false if a . blank? || b . blank?
5
+ a . to_s . split ( '' ) . sort == b . to_s . split ( '' ) . sort
6
+ end
7
+ end
Original file line number Diff line number Diff line change
1
+ require './app/anagram_checker.rb'
2
+
3
+ checker = AnagramChecker . new
4
+
5
+ while ( true )
6
+ print "Please input the first word: "
7
+ a = gets . chomp
8
+ print "Please enter the second word: "
9
+ b = gets . chomp
10
+
11
+ puts "Comparing words..."
12
+ if checker . anagram? ( a , b )
13
+ puts "#{ a } /#{ b } is a valid anagram"
14
+ else
15
+ puts "#{ a } /#{ b } is NOT a valid anagram"
16
+ end
17
+ puts
18
+ end
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+ exec ruby app/client.rb
Original file line number Diff line number Diff line change
1
+ version : " 3.4"
2
+
3
+ services :
4
+ app :
5
+ command : tail -f /dev/null
Original file line number Diff line number Diff line change
1
+ version : " 3.4"
2
+
3
+ services :
4
+ app :
5
+ image : jfahrer/anagram_checker:latest
6
+ stdin_open : true
7
+ tty : true
8
+ build :
9
+ context : .
10
+ volumes :
11
+ - .:/app
12
+ - data
13
+
14
+ volumes :
15
+ data :
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+ require './app/anagram_checker'
3
+
4
+ RSpec . describe AnagramChecker do
5
+ it 'identifies anagrams' do
6
+ checker = AnagramChecker . new
7
+ expect ( checker . anagram? ( 'julian' , 'nailuj' ) ) . to be_truthy
8
+ expect ( checker . anagram? ( 'julian' , 'julian' ) ) . to be_truthy
9
+ expect ( checker . anagram? ( 'julian' , 'uijnla' ) ) . to be_truthy
10
+ expect ( checker . anagram? ( 'julian' , 'iijnla' ) ) . to be_falsy
11
+ expect ( checker . anagram? ( 'julian' , 'juliann' ) ) . to be_falsy
12
+ end
13
+
14
+ it 'handles nil cases' do
15
+ checker = AnagramChecker . new
16
+ expect ( checker . anagram? ( 'julian' , nil ) ) . to be_falsy
17
+ expect ( checker . anagram? ( nil , nil ) ) . to be_falsy
18
+ end
19
+ end
You can’t perform that action at this time.
0 commit comments