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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5dad5c88918707ccb9b869c2cac95e6744e8878d287abd3183151ab0d2889af7
4
- data.tar.gz: 62909da6b9f2793facd24961f6c19fb93466d729d336951508af4c43547bab11
3
+ metadata.gz: 3f63cc130bdfa8bf2b08af931bb7328f0a366f589755c67a074edfc5d7fc1b14
4
+ data.tar.gz: 3bba5cc07007e5a54d02ba6d724c413e32530b30baf0c142a6f90e5f78c6f835
5
5
  SHA512:
6
- metadata.gz: 2a54af9513b56863365613056f727484e9a74dbbf301e51606a80c398393f1c8af4f87dfda915820abd654b762d11976c67491406eb1a688c15a34cb9d71e20b
7
- data.tar.gz: 417368352ac62592f97a97815887f5d30f4c9def15b2f59383c539637224e095c5e85d951d1f366ab417c7d84247e73d1662c4d4cd569c41d53764d6be267cc2
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: Standalone Command
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
- ### Example: Option 1
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: Option 2
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
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'todo_analyser'
6
+
7
+ TodoAnalyser.run
@@ -4,5 +4,5 @@
4
4
  # Versioning
5
5
  ##
6
6
  module TodoAnalyser
7
- VERSION = '1.0.0'
7
+ VERSION = '1.0.1'
8
8
  end
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
- # Command-line argument parsing
17
- options = {}
18
- OptionParser.new do |opts|
19
- opts.banner = 'Usage: todo_analyser.rb URL [OPTIONS]'
20
-
21
- opts.on('-n', '--number N', 'Number of TODOs to consume (default: 20)') do |n|
22
- options[:number] = n.to_i
23
- end
24
- end.parse!
25
-
26
- todos_path = ARGV[0]
27
- raise 'Please specify a file to consume TODOs from.' unless todos_path
28
-
29
- # Default Values
30
- number = options[:number] || 20
31
-
32
- # Calls
33
- reader = TodoReaderJSON.new(todos_path)
34
- consumer = TodoConsumer.new(reader, number, ConsoleOutput.new)
35
- consumer.consume
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 TodoAnalyser
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
- # Command-line argument parsing
81
- options = {}
82
- OptionParser.new do |opts|
83
- opts.banner = 'Usage: todo_analyser.rb URL [OPTIONS]'
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
- opts.on('-n', '--number N', 'Number of TODOs to consume (default: 20)') do |n|
86
- options[:number] = n.to_i
87
- end
88
- end.parse!
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 = ARGV[0]
91
- raise 'Please specify a file to consume TODOs from.' unless todos_path
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
- # Default Values
94
- number = options[:number] || 20
104
+ raise 'Please specify a file to consume TODOs from.' unless todos_path
105
+
106
+ analyse(todos_path, number)
107
+ end
95
108
 
96
- # Calls
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.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