everything-core 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cac2a61a41333091daa8d890ed1f76d5489fd926eeb40d49bcb94166a67fbb1
4
- data.tar.gz: a9706095474bbf816907ee161cedf94d2c11721d016074470a24c365b7f9cc1b
3
+ metadata.gz: bae9b9a7c10aa14d43dbf312ba25c0a2dec325000f8bc75bda0150aefc00fbd1
4
+ data.tar.gz: d9ac581faf22de423daf8fc3cd990f9b81bad9679e03439e701cdaa3d4515f67
5
5
  SHA512:
6
- metadata.gz: 33d436558aa5bf1b4228f4f0bcb544ece781f6fb21bdf80329ecaccc13fc621f4df234fdbacb9517bf7183c7d2756790ec73cce29c63037480ddf22af5fec2fa
7
- data.tar.gz: 51ac31b045ff9db5cfce7f50d140877790d86f4d067e6f1b7348e6822e922052d989ad94281a4afb5767f33eda3dc97d98b7194a0872d302a0773bde1fb38bf2
6
+ metadata.gz: 5bdd8c94ac5d55fcbdc6b075a4e22a8343f67e8e55ab2391d92161896e413387612ba855c0287091129abdd2b39d75224dcef4512b6345d5a75640bd2993fcf8
7
+ data.tar.gz: 2bef7eba4b4ce2498df87d852c675de6b4a532a8ac34c4f2546721ba917a501169311068a893a403d15471ae99c4781d649db549794c75842e848984aa238fcf
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
3
4
  - 2.7.1
4
5
  before_install: gem install bundler
@@ -1,5 +1,15 @@
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
+
3
13
  ## 0.0.12
4
14
 
5
15
  - Add an Everything logger
data/README.md CHANGED
@@ -75,7 +75,7 @@ and content.
75
75
  ```ruby
76
76
  require 'everything'
77
77
 
78
- piece_path = File.join(Everything.path, 'your-piece-here')
78
+ piece_path = Everything.path.join('your-piece-here')
79
79
  piece = Everything::Piece.new(piece_path)
80
80
 
81
81
  piece.name # => 'your-piece-here'
@@ -30,5 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'rake', '>= 13.0.1'
31
31
  spec.add_development_dependency 'rspec', '~> 3.9'
32
32
  spec.add_development_dependency 'timecop', '~> 0.9'
33
+ spec.add_development_dependency 'fakefs', '~> 1.2.2'
33
34
  end
34
35
 
@@ -1,6 +1,7 @@
1
1
  require 'dotenv'
2
2
  Dotenv.load
3
3
 
4
+ require 'pathname'
4
5
  require 'fastenv'
5
6
  require 'everything/version'
6
7
  require 'everything/logger'
@@ -8,7 +9,7 @@ require 'everything/piece'
8
9
 
9
10
  module Everything
10
11
  def self.path
11
- Fastenv.everything_path
12
+ Pathname.new(Fastenv.everything_path)
12
13
  end
13
14
  end
14
15
 
@@ -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,11 +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
+
10
22
  def file_name
11
23
  'index.md'
12
24
  end
13
25
 
14
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
15
30
  @file_path ||= File.join(piece_path, file_name)
16
31
  end
17
32
 
@@ -23,8 +38,12 @@ module Everything
23
38
  partitioned_text.last
24
39
  end
25
40
 
41
+ def path
42
+ @path ||= dir.join(file_name)
43
+ end
44
+
26
45
  def raw_markdown
27
- @raw_markdown ||= File.read(file_path)
46
+ @raw_markdown ||= absolute_path.read
28
47
  end
29
48
 
30
49
  def raw_markdown=(value)
@@ -34,7 +53,7 @@ module Everything
34
53
  def save
35
54
  FileUtils.mkdir_p(piece_path)
36
55
 
37
- File.write(file_path, @raw_markdown)
56
+ absolute_path.write(@raw_markdown)
38
57
  end
39
58
 
40
59
  private
@@ -43,6 +62,12 @@ module Everything
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
+
@@ -15,12 +15,31 @@ module Everything
15
15
  @piece_path = piece_path
16
16
  end
17
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
+
18
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
19
34
  @file_path ||= File.join(piece_path, file_name)
20
35
  end
21
36
 
37
+ def path
38
+ @path ||= dir.join(file_name)
39
+ end
40
+
22
41
  def raw_yaml
23
- @raw_yaml ||= YAML.load_file(file_path)
42
+ @raw_yaml ||= YAML.load_file(absolute_path)
24
43
  end
25
44
 
26
45
  def raw_yaml=(value)
@@ -30,7 +49,7 @@ module Everything
30
49
  def save
31
50
  FileUtils.mkdir_p(piece_path)
32
51
 
33
- File.write(file_path, @raw_yaml)
52
+ absolute_path.write(@raw_yaml)
34
53
  end
35
54
 
36
55
  def_delegators :raw_yaml, :[]
@@ -41,6 +60,11 @@ module Everything
41
60
  def file_name
42
61
  'index.yaml'
43
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
44
68
  end
45
69
  end
46
70
  end
@@ -1,3 +1,3 @@
1
1
  module Everything
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everything-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Tolle
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-07-23 00:00:00.000000000 Z
11
+ date: 2020-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.9'
97
+ - !ruby/object:Gem::Dependency
98
+ name: fakefs
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.2.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.2.2
97
111
  description: Gives you access to pieces within your everything repo.
98
112
  email:
99
113
  - kyle@nullsix.com