1hdoc 0.2.3 → 0.2.4
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/README.md +17 -9
- data/lib/1hdoc/actions/push.rb +12 -0
- data/lib/1hdoc/core/configuration.rb +26 -9
- data/lib/1hdoc/core/progress.rb +9 -1
- data/lib/1hdoc/core/repository.rb +4 -0
- data/lib/1hdoc/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e20ddfded5850fe29763cf2f76f6b250ee443f57
|
4
|
+
data.tar.gz: 98513221bb36b0c149389fcab9e85e73e1c21269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68c996a8fb5fb1e6f3f96ead94b64bb0ec5e1de3f115659b63873d663c8af7d08a715177341c835c49c7073cfb78802da3930cd77da20546d4b3f00dbc99e126
|
7
|
+
data.tar.gz: 0f9f81919845a558d434bcd8779b214e4e1cef01d9040b14b59d480c168a27104c9f4b15fd17bdc48350a1654c18b07a3b75cb36ca4c64d0a406297aafbf684f
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# 1hdoc
|
2
2
|
|
3
|
+
[](https://www.codacy.com/app/dom-corvasce/1hdoc?utm_source=github.com&utm_medium=referral&utm_content=domcorvasce/1hdoc&utm_campaign=badger)
|
3
4
|
[](https://badge.fury.io/rb/1hdoc)
|
4
5
|
|
5
6
|
Keep track of your progress during #100DaysOfCode event.
|
@@ -66,7 +67,7 @@ Have you ended Day 2?
|
|
66
67
|
Great! Let's 1hdoc track your progress. Type:
|
67
68
|
|
68
69
|
```shell
|
69
|
-
1hdoc
|
70
|
+
1hdoc -c
|
70
71
|
```
|
71
72
|
|
72
73
|
By default, 1hdoc don't push to the repo automatically after you
|
@@ -84,20 +85,27 @@ You can change this behavior by assigning `true` to `auto_push` option in
|
|
84
85
|
If you turn off `auto_push` you can push to the repo typing:
|
85
86
|
|
86
87
|
```shell
|
87
|
-
1hdoc
|
88
|
+
1hdoc -p
|
88
89
|
```
|
89
90
|
|
91
|
+
## FAQ
|
92
|
+
|
93
|
+
- **I got an error when I try to use 1hdoc. How can I resolve?**
|
94
|
+
|
95
|
+
If the error is the following:
|
96
|
+
|
97
|
+
```shell
|
98
|
+
`require': libreadline.so.6: cannot open shared object fie
|
99
|
+
```
|
100
|
+
|
101
|
+
this means Ruby tries to get the older version of Readline so you need
|
102
|
+
to reinstall it like reported [here](https://github.com/deivid-rodriguez/byebug/issues/307).
|
103
|
+
|
90
104
|
## Contribute
|
91
105
|
|
92
106
|
Everyone can contribute to this project:
|
93
107
|
|
94
|
-
|
95
|
-
- Fixing my bad english
|
96
|
-
- Proposing new features
|
97
|
-
- Improving code
|
98
|
-
- and doing a plethora of other things..
|
99
|
-
|
100
|
-
Feel free to open an issue and propose a pull request.
|
108
|
+
Feel free to open an issue or propose a pull request.
|
101
109
|
|
102
110
|
## License
|
103
111
|
|
data/lib/1hdoc/actions/push.rb
CHANGED
@@ -3,8 +3,20 @@ module HDOC
|
|
3
3
|
##
|
4
4
|
# Push the progress to the repository.
|
5
5
|
def push
|
6
|
+
if user_already_pushed?
|
7
|
+
$stderr.puts 'You already pushed for today'
|
8
|
+
return
|
9
|
+
end
|
10
|
+
|
6
11
|
open_repository
|
7
12
|
@repository.push
|
8
13
|
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def user_already_pushed?
|
18
|
+
config = Configuration.new(ENVIRONMENT[:configuration_file])
|
19
|
+
config.options[:last_commit_on] == Time.now.strftime('%Y-%m-%d')
|
20
|
+
end
|
9
21
|
end
|
10
22
|
end
|
@@ -5,31 +5,48 @@ module HDOC
|
|
5
5
|
class Configuration
|
6
6
|
attr_reader :options, :file_path
|
7
7
|
|
8
|
+
##
|
9
|
+
# Initializes a new configuration file with a set of defaults options:
|
10
|
+
#
|
11
|
+
# ```
|
12
|
+
# # Using a custom format
|
13
|
+
# Configuration.init('~/package.json', JSON, name: 'howsweather', version: '0.1.4')
|
14
|
+
#
|
15
|
+
# # Using default format
|
16
|
+
# Configuration.init('~/.1hdoc.yml', day: 0, last_commit_on: Time.now)
|
17
|
+
# ```
|
8
18
|
def self.init(file_path, file_parser = YAML, **options)
|
9
19
|
file_path = File.expand_path(file_path)
|
20
|
+
dumped_options = file_parser.dump(options)
|
10
21
|
|
11
|
-
File.open(file_path, 'w')
|
12
|
-
configuration_file.puts file_parser.dump(options)
|
13
|
-
end
|
22
|
+
File.open(file_path, 'w') { |config| config.puts(dumped_options) }
|
14
23
|
end
|
15
24
|
|
16
25
|
def initialize(file_path, file_parser = YAML)
|
17
26
|
@file_path = File.expand_path(file_path)
|
18
27
|
@file_parser = file_parser
|
19
|
-
@options =
|
20
|
-
|
21
|
-
raise "Unable to find #{@file_path}" unless File.exist? @file_path
|
22
|
-
load_options
|
28
|
+
@options = load_options
|
23
29
|
end
|
24
30
|
|
25
31
|
def load_options
|
26
|
-
|
32
|
+
raise "Unable to find #{file_path}" unless File.exist? file_path
|
33
|
+
@file_parser.load(File.read(file_path))
|
27
34
|
end
|
28
35
|
|
36
|
+
##
|
37
|
+
# Updates configuration file by rewriting the whole file using
|
38
|
+
# init's singleton method.
|
39
|
+
#
|
40
|
+
# You should avoid this method for big files and use it for small ones.
|
29
41
|
def update
|
30
|
-
|
42
|
+
self.class.init(@file_path, @file_parser, options)
|
31
43
|
end
|
32
44
|
|
45
|
+
##
|
46
|
+
# Sets a new option or a edit an existing one.
|
47
|
+
#
|
48
|
+
# It's used in pair with Configuration#update in order to update
|
49
|
+
# an existing configuration file.
|
33
50
|
def set(option, value)
|
34
51
|
@options[option] = value
|
35
52
|
end
|
data/lib/1hdoc/core/progress.rb
CHANGED
@@ -18,8 +18,16 @@ module HDOC
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def register
|
21
|
+
$stderr.puts 'Finish your answer by typing :!'
|
22
|
+
|
21
23
|
QUESTIONS.each do |field, question|
|
22
|
-
|
24
|
+
$stderr.puts question
|
25
|
+
@record[field] = ''
|
26
|
+
|
27
|
+
while text_line = Readline.readline
|
28
|
+
@record[field] += text_line.sub(':!', '') + "\n"
|
29
|
+
break if text_line[':!']
|
30
|
+
end
|
23
31
|
end
|
24
32
|
end
|
25
33
|
|
@@ -2,6 +2,8 @@ module HDOC
|
|
2
2
|
##
|
3
3
|
# Provides an interface for interact with Git repositories.
|
4
4
|
class Repository
|
5
|
+
attr_reader :adapter
|
6
|
+
|
5
7
|
def self.clone(url, destination, adapter = Git)
|
6
8
|
adapter.clone(url, destination)
|
7
9
|
rescue adapter::GitExecuteError => error
|
@@ -22,6 +24,8 @@ module HDOC
|
|
22
24
|
|
23
25
|
def push
|
24
26
|
@repo.push
|
27
|
+
rescue adapter::GitExecuteError => error
|
28
|
+
$stderr.puts error.message
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
data/lib/1hdoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 1hdoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dom Corvasce
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -110,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
requirements:
|
111
111
|
- git >= 1.6
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.6.
|
113
|
+
rubygems_version: 2.6.10
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: "#100DaysOfCode CLI tracker"
|