everything-core 0.0.8 → 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +3 -2
- data/CHANGELOG.md +31 -0
- data/Gemfile +1 -0
- data/README.md +42 -9
- data/bin/console +1 -1
- data/bin/setup +0 -2
- data/everything-core.gemspec +19 -12
- data/lib/everything.rb +3 -1
- data/lib/everything/logger.rb +25 -0
- data/lib/everything/logger/base.rb +17 -0
- data/lib/everything/logger/debug.rb +7 -0
- data/lib/everything/logger/error.rb +11 -0
- data/lib/everything/logger/log_it.rb +24 -0
- data/lib/everything/logger/verbose.rb +11 -0
- data/lib/everything/piece.rb +2 -2
- data/lib/everything/piece/content.rb +31 -6
- data/lib/everything/piece/metadata.rb +31 -2
- data/lib/everything/version.rb +1 -1
- metadata +53 -32
- data/spec/everything/piece/content_spec.rb +0 -190
- data/spec/everything/piece/metadata_spec.rb +0 -198
- data/spec/everything/piece_spec.rb +0 -195
- data/spec/everything_spec.rb +0 -19
- data/spec/spec_helper.rb +0 -99
- data/spec/support/pieces.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bae9b9a7c10aa14d43dbf312ba25c0a2dec325000f8bc75bda0150aefc00fbd1
|
4
|
+
data.tar.gz: d9ac581faf22de423daf8fc3cd990f9b81bad9679e03439e701cdaa3d4515f67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bdd8c94ac5d55fcbdc6b075a4e22a8343f67e8e55ab2391d92161896e413387612ba855c0287091129abdd2b39d75224dcef4512b6345d5a75640bd2993fcf8
|
7
|
+
data.tar.gz: 2bef7eba4b4ce2498df87d852c675de6b4a532a8ac34c4f2546721ba917a501169311068a893a403d15471ae99c4781d649db549794c75842e848984aa238fcf
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,36 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.0.13
|
4
|
+
|
5
|
+
- **BREAKING CHANGE**: Make Everything.path an instance of Pathname
|
6
|
+
- Add #absolute_dir, #absolute_path, #dir, #file_name, #path to Everything::Piece
|
7
|
+
- Memoize Everything::Piece#name
|
8
|
+
- Add #absolute_dir, #absolute_path, #dir, #path to Everything::Piece::Content
|
9
|
+
- Add #absolute_dir, #absolute_path, #dir, #path to Everything::Piece::Metadata
|
10
|
+
- Deprecate #file_path on Everything::Piece::Content and Everything::Piece::Metadata
|
11
|
+
- Use Pathname convenience methods when working with files and paths internally
|
12
|
+
|
13
|
+
## 0.0.12
|
14
|
+
|
15
|
+
- Add an Everything logger
|
16
|
+
- Add a Debug logger
|
17
|
+
- Add a Verbose logger
|
18
|
+
- Add an Error logger
|
19
|
+
- Add a LogIt module to make logging easy
|
20
|
+
|
21
|
+
## 0.0.11
|
22
|
+
|
23
|
+
- Update changelog for 0.0.10 changes
|
24
|
+
- Update travis settings to use ruby 2.7.1 and bundler 2
|
25
|
+
|
26
|
+
## 0.0.10
|
27
|
+
|
28
|
+
- Upgrade to Bundler v2
|
29
|
+
|
30
|
+
## 0.0.9
|
31
|
+
|
32
|
+
- Make Content#file_name a public method
|
33
|
+
|
3
34
|
## 0.0.8
|
4
35
|
|
5
36
|
- Require modules which had been used but not explicitly required
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Must define these environment variables:
|
|
22
22
|
Add this line to your application's Gemfile:
|
23
23
|
|
24
24
|
```ruby
|
25
|
-
gem
|
25
|
+
gem 'everything-core', require: 'everything'
|
26
26
|
```
|
27
27
|
|
28
28
|
And then execute:
|
@@ -34,6 +34,24 @@ Or install it yourself as:
|
|
34
34
|
$ gem install everything-core
|
35
35
|
|
36
36
|
|
37
|
+
## Requiring
|
38
|
+
|
39
|
+
You can require it yourself in your code:
|
40
|
+
|
41
|
+
```
|
42
|
+
require 'everything'
|
43
|
+
```
|
44
|
+
|
45
|
+
Or, if you use Bundler and list the gem in your Gemfile, you can require all the
|
46
|
+
gems from your Gemfile:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
require 'rubygems'
|
50
|
+
require 'bundler/setup'
|
51
|
+
Bundler.require(:default)
|
52
|
+
```
|
53
|
+
|
54
|
+
|
37
55
|
## Usage
|
38
56
|
|
39
57
|
This assumes you have a `EVERYTHING_PATH` environment variable either set in
|
@@ -42,7 +60,7 @@ your shell or in dotenv's `.env` file.
|
|
42
60
|
For example, let's assume you have the following folder and file under your
|
43
61
|
everything path
|
44
62
|
|
45
|
-
```
|
63
|
+
```ruby
|
46
64
|
your-piece-here/index.md
|
47
65
|
|
48
66
|
# Your Piece Here
|
@@ -54,10 +72,10 @@ The rest of the body of your file...
|
|
54
72
|
To use the piece from IRB, you could do the following to get the piece's title
|
55
73
|
and content.
|
56
74
|
|
57
|
-
```
|
75
|
+
```ruby
|
58
76
|
require 'everything'
|
59
77
|
|
60
|
-
piece_path =
|
78
|
+
piece_path = Everything.path.join('your-piece-here')
|
61
79
|
piece = Everything::Piece.new(piece_path)
|
62
80
|
|
63
81
|
piece.name # => 'your-piece-here'
|
@@ -67,8 +85,11 @@ piece['categories'] # Returns the value for the `categories` metadata key
|
|
67
85
|
piece.public? # Convience method to return the value for the boolean `public` metadata key
|
68
86
|
piece.content # Return an instance of the piece's content
|
69
87
|
piece.metadata # Return an instance of the piece's metadata
|
88
|
+
```
|
70
89
|
|
71
|
-
|
90
|
+
You can also edit a piece's content and metadata
|
91
|
+
|
92
|
+
```ruby
|
72
93
|
piece.raw_markdown = some_markdown # Sets the raw_markdown on the piece's content
|
73
94
|
piece.raw_yaml = some_yaml # Sets the raw_yaml on the piece's metadata
|
74
95
|
piece.save # Save the piece's content and metadata to disk
|
@@ -81,10 +102,22 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
81
102
|
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
82
103
|
prompt that will allow you to experiment.
|
83
104
|
|
84
|
-
To install this gem onto your local machine, run `
|
85
|
-
|
86
|
-
|
87
|
-
|
105
|
+
To install this gem onto your local machine, run `rake install`.
|
106
|
+
|
107
|
+
To release a new version,
|
108
|
+
- check out a new branch
|
109
|
+
- make your code changes
|
110
|
+
- update the version number in `lib/everything/version.rb`
|
111
|
+
- update the `CHANGELOG.md` with what changed.
|
112
|
+
- commit your code changes
|
113
|
+
- push new branch to github with `git push -u origin HEAD`
|
114
|
+
- create a new PR for this
|
115
|
+
- merge in PR to master
|
116
|
+
- locally, check out master again
|
117
|
+
- git pull
|
118
|
+
- create a build with `rake build`
|
119
|
+
- run `rake release`, which will create a git tag for the version,
|
120
|
+
push git commits and tags, and push the `.gem` file to
|
88
121
|
[rubygems.org](https://rubygems.org).
|
89
122
|
|
90
123
|
|
data/bin/console
CHANGED
data/bin/setup
CHANGED
data/everything-core.gemspec
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'everything/version'
|
1
|
+
require_relative 'lib/everything/version'
|
5
2
|
|
6
3
|
Gem::Specification.new do |spec|
|
7
4
|
spec.name = 'everything-core'
|
@@ -12,17 +9,27 @@ Gem::Specification.new do |spec|
|
|
12
9
|
spec.description = %q{Gives you access to pieces within your everything repo.}
|
13
10
|
spec.homepage = 'https://github.com/kyletolle/everything-core'
|
14
11
|
spec.license = 'MIT'
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.1")
|
15
13
|
|
16
|
-
spec.
|
17
|
-
spec.
|
18
|
-
|
19
|
-
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
15
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
20
25
|
|
21
26
|
spec.add_runtime_dependency 'dotenv', '~> 2.1'
|
22
|
-
spec.add_runtime_dependency 'fastenv', '= 0.0.
|
27
|
+
spec.add_runtime_dependency 'fastenv', '= 0.0.3'
|
23
28
|
|
24
|
-
spec.add_development_dependency 'bundler', '~> 1
|
25
|
-
spec.add_development_dependency 'rake', '
|
26
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
29
|
+
spec.add_development_dependency 'bundler', '~> 2.1'
|
30
|
+
spec.add_development_dependency 'rake', '>= 13.0.1'
|
31
|
+
spec.add_development_dependency 'rspec', '~> 3.9'
|
32
|
+
spec.add_development_dependency 'timecop', '~> 0.9'
|
33
|
+
spec.add_development_dependency 'fakefs', '~> 1.2.2'
|
27
34
|
end
|
28
35
|
|
data/lib/everything.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
require 'dotenv'
|
2
2
|
Dotenv.load
|
3
3
|
|
4
|
+
require 'pathname'
|
4
5
|
require 'fastenv'
|
5
6
|
require 'everything/version'
|
7
|
+
require 'everything/logger'
|
6
8
|
require 'everything/piece'
|
7
9
|
|
8
10
|
module Everything
|
9
11
|
def self.path
|
10
|
-
Fastenv.everything_path
|
12
|
+
Pathname.new(Fastenv.everything_path)
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require_relative 'logger/base'
|
3
|
+
require_relative 'logger/debug'
|
4
|
+
require_relative 'logger/error'
|
5
|
+
require_relative 'logger/verbose'
|
6
|
+
require_relative 'logger/log_it'
|
7
|
+
|
8
|
+
module Everything
|
9
|
+
def self.logger
|
10
|
+
@logger ||= default_logger
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.logger=(value)
|
14
|
+
@logger = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.default_logger
|
18
|
+
::Logger.new(
|
19
|
+
$stdout,
|
20
|
+
level: ::Logger::ERROR,
|
21
|
+
progname: self.class.to_s
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Everything
|
2
|
+
class Logger
|
3
|
+
class Base < ::Logger
|
4
|
+
DATETIME_PROGNAME_MESSAGE_FORMATTER =
|
5
|
+
proc { |severity, datetime, progname, msg|
|
6
|
+
iso8601_time = datetime.utc.iso8601
|
7
|
+
"#{iso8601_time}: #{progname}: #{msg}\n"
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize(logdev, progname: nil)
|
11
|
+
super
|
12
|
+
self.formatter = DATETIME_PROGNAME_MESSAGE_FORMATTER
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Everything
|
2
|
+
class Logger
|
3
|
+
module LogIt
|
4
|
+
def debug_it(message)
|
5
|
+
Everything.logger.debug(class_name) { message }
|
6
|
+
end
|
7
|
+
|
8
|
+
def error_it(message)
|
9
|
+
Everything.logger.error(class_name) { message }
|
10
|
+
end
|
11
|
+
|
12
|
+
def info_it(message)
|
13
|
+
Everything.logger.info(class_name) { message }
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def class_name
|
19
|
+
self.class.to_s
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
data/lib/everything/piece.rb
CHANGED
@@ -14,7 +14,7 @@ module Everything
|
|
14
14
|
@content ||= Content.new(full_path)
|
15
15
|
end
|
16
16
|
|
17
|
-
def_delegators :content, :body, :raw_markdown, :raw_markdown=, :title
|
17
|
+
def_delegators :content, :absolute_dir, :absolute_path, :body, :dir, :file_name, :path, :raw_markdown, :raw_markdown=, :title
|
18
18
|
|
19
19
|
def metadata
|
20
20
|
@metadata ||= Metadata.new(full_path)
|
@@ -27,7 +27,7 @@ module Everything
|
|
27
27
|
def_delegators :metadata, :raw_yaml, :raw_yaml=
|
28
28
|
|
29
29
|
def name
|
30
|
-
File.basename(full_path)
|
30
|
+
@name ||= File.basename(full_path)
|
31
31
|
end
|
32
32
|
|
33
33
|
def save
|
@@ -7,7 +7,26 @@ module Everything
|
|
7
7
|
@piece_path = piece_path
|
8
8
|
end
|
9
9
|
|
10
|
+
def absolute_dir
|
11
|
+
@absolute_dir ||= Everything.path.join(dir)
|
12
|
+
end
|
13
|
+
|
14
|
+
def absolute_path
|
15
|
+
@absolute_path ||= absolute_dir.join(file_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def dir
|
19
|
+
@dir ||= calculated_dir
|
20
|
+
end
|
21
|
+
|
22
|
+
def file_name
|
23
|
+
'index.md'
|
24
|
+
end
|
25
|
+
|
10
26
|
def file_path
|
27
|
+
# TODO: Could try a deprecation approach like http://seejohncode.com/2012/01/09/deprecating-methods-in-ruby/
|
28
|
+
deprecation_message = "Piece Content's #file_path is deprecated and will be removed soon. Use #absolute_path instead."
|
29
|
+
warn deprecation_message
|
11
30
|
@file_path ||= File.join(piece_path, file_name)
|
12
31
|
end
|
13
32
|
|
@@ -19,8 +38,12 @@ module Everything
|
|
19
38
|
partitioned_text.last
|
20
39
|
end
|
21
40
|
|
41
|
+
def path
|
42
|
+
@path ||= dir.join(file_name)
|
43
|
+
end
|
44
|
+
|
22
45
|
def raw_markdown
|
23
|
-
@raw_markdown ||=
|
46
|
+
@raw_markdown ||= absolute_path.read
|
24
47
|
end
|
25
48
|
|
26
49
|
def raw_markdown=(value)
|
@@ -30,19 +53,21 @@ module Everything
|
|
30
53
|
def save
|
31
54
|
FileUtils.mkdir_p(piece_path)
|
32
55
|
|
33
|
-
|
56
|
+
absolute_path.write(@raw_markdown)
|
34
57
|
end
|
35
58
|
|
36
59
|
private
|
37
60
|
attr_reader :piece_path
|
38
61
|
|
39
|
-
def file_name
|
40
|
-
'index.md'
|
41
|
-
end
|
42
|
-
|
43
62
|
def partitioned_text
|
44
63
|
@partitioned_text ||= raw_markdown.partition("\n\n")
|
45
64
|
end
|
65
|
+
|
66
|
+
def calculated_dir
|
67
|
+
full_pathname = Pathname.new(piece_path)
|
68
|
+
_relative_pathname = full_pathname.relative_path_from(Everything.path)
|
69
|
+
end
|
46
70
|
end
|
47
71
|
end
|
48
72
|
end
|
73
|
+
|
@@ -6,16 +6,40 @@ module Everything
|
|
6
6
|
class Metadata
|
7
7
|
extend Forwardable
|
8
8
|
|
9
|
+
# TODO: Need to add some ways in here to save the metadata file once it's
|
10
|
+
# been edited.
|
11
|
+
# TODO: Also add a #to_s or #inspect methods to render the raw_yaml
|
12
|
+
# TODO: Also add a #[]= here that delegates to raw_yaml as well.
|
13
|
+
|
9
14
|
def initialize(piece_path)
|
10
15
|
@piece_path = piece_path
|
11
16
|
end
|
12
17
|
|
18
|
+
def absolute_dir
|
19
|
+
@absolute_dir ||= Everything.path.join(dir)
|
20
|
+
end
|
21
|
+
|
22
|
+
def absolute_path
|
23
|
+
@absolute_path ||= absolute_dir.join(file_name)
|
24
|
+
end
|
25
|
+
|
26
|
+
def dir
|
27
|
+
@dir ||= calculated_dir
|
28
|
+
end
|
29
|
+
|
13
30
|
def file_path
|
31
|
+
# TODO: Could try a deprecation approach like http://seejohncode.com/2012/01/09/deprecating-methods-in-ruby/
|
32
|
+
deprecation_message = "Piece Metadata's #file_path is deprecated and will be removed soon. Use #absolute_path instead."
|
33
|
+
warn deprecation_message
|
14
34
|
@file_path ||= File.join(piece_path, file_name)
|
15
35
|
end
|
16
36
|
|
37
|
+
def path
|
38
|
+
@path ||= dir.join(file_name)
|
39
|
+
end
|
40
|
+
|
17
41
|
def raw_yaml
|
18
|
-
@raw_yaml ||= YAML.load_file(
|
42
|
+
@raw_yaml ||= YAML.load_file(absolute_path)
|
19
43
|
end
|
20
44
|
|
21
45
|
def raw_yaml=(value)
|
@@ -25,7 +49,7 @@ module Everything
|
|
25
49
|
def save
|
26
50
|
FileUtils.mkdir_p(piece_path)
|
27
51
|
|
28
|
-
|
52
|
+
absolute_path.write(@raw_yaml)
|
29
53
|
end
|
30
54
|
|
31
55
|
def_delegators :raw_yaml, :[]
|
@@ -36,6 +60,11 @@ module Everything
|
|
36
60
|
def file_name
|
37
61
|
'index.yaml'
|
38
62
|
end
|
63
|
+
|
64
|
+
def calculated_dir
|
65
|
+
full_pathname = Pathname.new(piece_path)
|
66
|
+
_relative_pathname = full_pathname.relative_path_from(Everything.path)
|
67
|
+
end
|
39
68
|
end
|
40
69
|
end
|
41
70
|
end
|