todo_analyser 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Dockerfile +16 -0
- data/README.md +20 -4
- data/exe/todo_analyser +7 -0
- data/lib/todo_analyser/version.rb +1 -1
- data/lib/todo_analyser.rb +28 -20
- data/run/todo_analyser.rb +27 -17
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f63cc130bdfa8bf2b08af931bb7328f0a366f589755c67a074edfc5d7fc1b14
|
4
|
+
data.tar.gz: 3bba5cc07007e5a54d02ba6d724c413e32530b30baf0c142a6f90e5f78c6f835
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c00b2be314fc85b712846c5e9bbb2a53cea54028beb794a6d732698f856817eab4d5fa1eb70e4c9dfa049541afcaf5db691908c3aa40cbff3e6991ad6079ba85
|
7
|
+
data.tar.gz: 86a79e52c428ed05eb18f6492448a0e2b7f492b5b1bd7f066884a78795118e9ba5c8a96d005b0254c7f2daf31639c62b4cde2173fc6035c85c0b8b4c9cb413ee
|
data/Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
FROM ruby:3.3-slim
|
2
|
+
LABEL authors="sureshinde"
|
3
|
+
|
4
|
+
RUN apt update && apt install -y git
|
5
|
+
|
6
|
+
RUN bundle config --global frozen 1
|
7
|
+
|
8
|
+
WORKDIR /app
|
9
|
+
|
10
|
+
COPY Gemfile Gemfile.lock todo_analyser.gemspec ./
|
11
|
+
|
12
|
+
COPY . .
|
13
|
+
|
14
|
+
RUN bundle install
|
15
|
+
|
16
|
+
ENTRYPOINT ["bin/console"]
|
data/README.md
CHANGED
@@ -22,23 +22,39 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
22
22
|
## Usage
|
23
23
|
|
24
24
|
### Option 1: Console Command
|
25
|
-
|
26
25
|
$ bin/console -h # To display information about command arguments
|
27
26
|
$ bin/console <URL> [OPTIONS]
|
28
27
|
$ OPTIONS: -n, --number N [Number of TODOs to consume (default: 20)]
|
29
28
|
|
30
|
-
### Option 2:
|
29
|
+
### Option 2: Bundle Command
|
30
|
+
$ bundle exec todo_analyser -h # To display information about command arguments
|
31
|
+
$ bundle exec todo_analyser <URL> [OPTIONS]
|
32
|
+
|
33
|
+
### Option 3: Standalone Command
|
31
34
|
$ run/todo_analyser.rb -h # To display information about command arguments
|
32
35
|
$ run/todo_analyser.rb <URL> [OPTIONS]
|
33
36
|
|
34
|
-
###
|
37
|
+
### Option 4: Docker Command
|
38
|
+
$ docker build -t todo_analyser .
|
39
|
+
$ docker run todo_analyser -h # To display information about command arguments
|
40
|
+
$ docker run todo_analyser <URL> [OPTIONS]
|
41
|
+
|
42
|
+
### Example: Console Command
|
35
43
|
$ bin/console https://jsonplaceholder.typicode.com/todos
|
36
44
|
$ bin/console -n 10 https://jsonplaceholder.typicode.com/todos
|
37
45
|
|
38
|
-
### Example:
|
46
|
+
### Example: Bundle Command
|
47
|
+
$ bundle exec todo_analyser https://jsonplaceholder.typicode.com/todos
|
48
|
+
$ bundle exec todo_analyser -n 10 https://jsonplaceholder.typicode.com/todos
|
49
|
+
|
50
|
+
### Example: Standalone Command
|
39
51
|
$ run/todo_analyser.rb https://jsonplaceholder.typicode.com/todos
|
40
52
|
$ run/todo_analyser.rb -n 10 https://jsonplaceholder.typicode.com/todos
|
41
53
|
|
54
|
+
### Example: Docker Command
|
55
|
+
$ docker run todo_analyser https://jsonplaceholder.typicode.com/todos
|
56
|
+
$ docker run todo_analyser -n 10 https://jsonplaceholder.typicode.com/todos
|
57
|
+
|
42
58
|
|
43
59
|
## Contributing
|
44
60
|
|
data/exe/todo_analyser
ADDED
data/lib/todo_analyser.rb
CHANGED
@@ -13,24 +13,32 @@ require_relative 'todo_analyser/todo_consumer'
|
|
13
13
|
module TodoAnalyser
|
14
14
|
class Error < StandardError; end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
16
|
+
def self.configure
|
17
|
+
# Command-line argument parsing
|
18
|
+
options = {}
|
19
|
+
OptionParser.new do |opts|
|
20
|
+
opts.banner = 'Usage: todo_analyser.rb URL [OPTIONS]'
|
21
|
+
|
22
|
+
opts.on('-n', '--number N', 'Number of TODOs to consume (default: 20)') do |n|
|
23
|
+
options[:number] = n.to_i
|
24
|
+
end
|
25
|
+
end.parse!
|
26
|
+
|
27
|
+
[ARGV[0], options[:number] || 20]
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.analyse(todos_path, number)
|
31
|
+
# Calls
|
32
|
+
reader = TodoReaderJSON.new(todos_path)
|
33
|
+
consumer = TodoConsumer.new(reader, number, ConsoleOutput.new)
|
34
|
+
consumer.consume
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.run
|
38
|
+
todos_path, number = configure
|
39
|
+
|
40
|
+
raise 'Please specify a file to consume TODOs from.' unless todos_path
|
41
|
+
|
42
|
+
analyse(todos_path, number)
|
43
|
+
end
|
36
44
|
end
|
data/run/todo_analyser.rb
CHANGED
@@ -8,7 +8,7 @@ require 'net/http'
|
|
8
8
|
##
|
9
9
|
# Module to Run the Parser & Analyser
|
10
10
|
##
|
11
|
-
module
|
11
|
+
module StandAloneTodoAnalyser
|
12
12
|
# Interface for reading the response
|
13
13
|
module TodoReaderInterface
|
14
14
|
def read
|
@@ -77,24 +77,34 @@ module TodoAnalyser
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
def self.configure
|
81
|
+
# Command-line argument parsing
|
82
|
+
options = {}
|
83
|
+
OptionParser.new do |opts|
|
84
|
+
opts.banner = 'Usage: todo_analyser.rb URL [OPTIONS]'
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
86
|
+
opts.on('-n', '--number N', 'Number of TODOs to consume (default: 20)') do |n|
|
87
|
+
options[:number] = n.to_i
|
88
|
+
end
|
89
|
+
end.parse!
|
90
|
+
|
91
|
+
[ARGV[0], options[:number] || 20]
|
92
|
+
end
|
89
93
|
|
90
|
-
todos_path
|
91
|
-
|
94
|
+
def self.analyse(todos_path, number)
|
95
|
+
# Calls
|
96
|
+
reader = TodoReaderJSON.new(todos_path)
|
97
|
+
consumer = TodoConsumer.new(reader, number, ConsoleOutput.new)
|
98
|
+
consumer.consume
|
99
|
+
end
|
100
|
+
|
101
|
+
def self.run
|
102
|
+
todos_path, number = configure
|
92
103
|
|
93
|
-
|
94
|
-
|
104
|
+
raise 'Please specify a file to consume TODOs from.' unless todos_path
|
105
|
+
|
106
|
+
analyse(todos_path, number)
|
107
|
+
end
|
95
108
|
|
96
|
-
|
97
|
-
reader = TodoReaderJSON.new(todos_path)
|
98
|
-
consumer = TodoConsumer.new(reader, number, ConsoleOutput.new)
|
99
|
-
consumer.consume
|
109
|
+
run
|
100
110
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: todo_analyser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Suresh Shinde
|
@@ -13,16 +13,19 @@ dependencies: []
|
|
13
13
|
description: To-Do List Parser to parse the TODOs for even numbered items from list
|
14
14
|
email:
|
15
15
|
- sureshindes@gmail.com
|
16
|
-
executables:
|
16
|
+
executables:
|
17
|
+
- todo_analyser
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
19
20
|
files:
|
20
21
|
- ".rspec"
|
21
22
|
- CHANGELOG.md
|
22
23
|
- CODE_OF_CONDUCT.md
|
24
|
+
- Dockerfile
|
23
25
|
- LICENSE.txt
|
24
26
|
- README.md
|
25
27
|
- Rakefile
|
28
|
+
- exe/todo_analyser
|
26
29
|
- lib/todo_analyser.rb
|
27
30
|
- lib/todo_analyser/console_output.rb
|
28
31
|
- lib/todo_analyser/todo.rb
|