everything-core 0.0.7 → 0.0.12

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
- SHA1:
3
- metadata.gz: 8aca9092f34828f75505f2d3c36a03bd20845114
4
- data.tar.gz: 7dfbd73bc6f5a5009f5abe169359067bca9b0b29
2
+ SHA256:
3
+ metadata.gz: 5cac2a61a41333091daa8d890ed1f76d5489fd926eeb40d49bcb94166a67fbb1
4
+ data.tar.gz: a9706095474bbf816907ee161cedf94d2c11721d016074470a24c365b7f9cc1b
5
5
  SHA512:
6
- metadata.gz: f7d1b41ee152d93d758cfa0cbe2b082cb07c11d39dfcdc45063bf7f756d669d95d31d8678b5e4c14a13408779f9dfc91ee9aa8f85854c84da6e03d8ea9738cb3
7
- data.tar.gz: 64dd8236c33db109b282af925f74b60acb51045ff30cdf3a80b2c501c489b7a36212c812ee65fbcd2d12b3ce5aa143131505046158fffdedc98fb50bcb07ca5d
6
+ metadata.gz: 33d436558aa5bf1b4228f4f0bcb544ece781f6fb21bdf80329ecaccc13fc621f4df234fdbacb9517bf7183c7d2756790ec73cce29c63037480ddf22af5fec2fa
7
+ data.tar.gz: 51ac31b045ff9db5cfce7f50d140877790d86f4d067e6f1b7348e6822e922052d989ad94281a4afb5767f33eda3dc97d98b7194a0872d302a0773bde1fb38bf2
@@ -1,4 +1,4 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.3
4
- before_install: gem install bundler -v 1.11.2
3
+ - 2.7.1
4
+ before_install: gem install bundler
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.0.12
4
+
5
+ - Add an Everything logger
6
+ - Add a Debug logger
7
+ - Add a Verbose logger
8
+ - Add an Error logger
9
+ - Add a LogIt module to make logging easy
10
+
11
+ ## 0.0.11
12
+
13
+ - Update changelog for 0.0.10 changes
14
+ - Update travis settings to use ruby 2.7.1 and bundler 2
15
+
16
+ ## 0.0.10
17
+
18
+ - Upgrade to Bundler v2
19
+
20
+ ## 0.0.9
21
+
22
+ - Make Content#file_name a public method
23
+
24
+ ## 0.0.8
25
+
26
+ - Require modules which had been used but not explicitly required
27
+ - Add #raw_markdown=, #save to Content
28
+ - Add #raw_yaml=, #save to Metadata
29
+ - Add #raw_markdown=, #raw_yaml, #raw_yaml=, #save to Piece
30
+
3
31
  ## 0.0.7
4
32
 
5
33
  - Add a piece#name to return the name from the piece's path
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source 'https://rubygems.org'
2
+ ruby '2.7.1'
2
3
 
3
4
  # The gem's dependencies are specified in `everything-core.gemspec`.
4
5
  gemspec
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 install everything-core
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,7 +72,7 @@ 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
78
  piece_path = File.join(Everything.path, 'your-piece-here')
@@ -69,6 +87,14 @@ piece.content # Return an instance of the piece's content
69
87
  piece.metadata # Return an instance of the piece's metadata
70
88
  ```
71
89
 
90
+ You can also edit a piece's content and metadata
91
+
92
+ ```ruby
93
+ piece.raw_markdown = some_markdown # Sets the raw_markdown on the piece's content
94
+ piece.raw_yaml = some_yaml # Sets the raw_yaml on the piece's metadata
95
+ piece.save # Save the piece's content and metadata to disk
96
+ ```
97
+
72
98
 
73
99
  ## Development
74
100
 
@@ -76,10 +102,22 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
76
102
  `rake spec` to run the tests. You can also run `bin/console` for an interactive
77
103
  prompt that will allow you to experiment.
78
104
 
79
- To install this gem onto your local machine, run `bundle exec rake install`. To
80
- release a new version, update the version number in `version.rb`, and then run
81
- `bundle exec rake release`, which will create a git tag for the version, push
82
- git commits and tags, and push the `.gem` file to
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
83
121
  [rubygems.org](https://rubygems.org).
84
122
 
85
123
 
@@ -11,4 +11,4 @@ require "everything"
11
11
  # Pry.start
12
12
 
13
13
  require "irb"
14
- IRB.start
14
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -4,5 +4,3 @@ IFS=$'\n\t'
4
4
  set -vx
5
5
 
6
6
  bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,7 +1,4 @@
1
- # coding: utf-8
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,26 @@ 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.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ['lib']
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.2'
27
+ spec.add_runtime_dependency 'fastenv', '= 0.0.3'
23
28
 
24
- spec.add_development_dependency 'bundler', '~> 1.11'
25
- spec.add_development_dependency 'rake', '~> 10.5'
26
- spec.add_development_dependency 'rspec', '~> 3.4'
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'
27
33
  end
28
34
 
@@ -3,6 +3,7 @@ Dotenv.load
3
3
 
4
4
  require 'fastenv'
5
5
  require 'everything/version'
6
+ require 'everything/logger'
6
7
  require 'everything/piece'
7
8
 
8
9
  module Everything
@@ -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,7 @@
1
+ module Everything
2
+ class Logger
3
+ class Debug < Everything::Logger::Base
4
+ end
5
+ end
6
+ end
7
+
@@ -0,0 +1,11 @@
1
+ module Everything
2
+ class Logger
3
+ class Error < Everything::Logger::Base
4
+ def initialize(logdev, progname: nil)
5
+ super
6
+ self.level = ::Logger::ERROR
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -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
+
@@ -0,0 +1,11 @@
1
+ module Everything
2
+ class Logger
3
+ class Verbose < Everything::Logger::Base
4
+ def initialize(logdev, progname: nil)
5
+ super
6
+ self.level = ::Logger::INFO
7
+ end
8
+ end
9
+ end
10
+ end
11
+
@@ -1,3 +1,5 @@
1
+ require 'forwardable'
2
+
1
3
  module Everything
2
4
  class Piece
3
5
  extend Forwardable
@@ -12,7 +14,7 @@ module Everything
12
14
  @content ||= Content.new(full_path)
13
15
  end
14
16
 
15
- def_delegators :content, :body, :raw_markdown, :title
17
+ def_delegators :content, :body, :raw_markdown, :raw_markdown=, :title
16
18
 
17
19
  def metadata
18
20
  @metadata ||= Metadata.new(full_path)
@@ -22,9 +24,16 @@ module Everything
22
24
  metadata['public']
23
25
  end
24
26
 
27
+ def_delegators :metadata, :raw_yaml, :raw_yaml=
28
+
25
29
  def name
26
30
  File.basename(full_path)
27
31
  end
32
+
33
+ def save
34
+ content.save
35
+ metadata.save
36
+ end
28
37
  end
29
38
  end
30
39
 
@@ -1,3 +1,5 @@
1
+ require 'fileutils'
2
+
1
3
  module Everything
2
4
  class Piece
3
5
  class Content
@@ -5,6 +7,10 @@ module Everything
5
7
  @piece_path = piece_path
6
8
  end
7
9
 
10
+ def file_name
11
+ 'index.md'
12
+ end
13
+
8
14
  def file_path
9
15
  @file_path ||= File.join(piece_path, file_name)
10
16
  end
@@ -21,13 +27,19 @@ module Everything
21
27
  @raw_markdown ||= File.read(file_path)
22
28
  end
23
29
 
24
- private
25
- attr_reader :piece_path
30
+ def raw_markdown=(value)
31
+ @raw_markdown = value
32
+ end
26
33
 
27
- def file_name
28
- 'index.md'
34
+ def save
35
+ FileUtils.mkdir_p(piece_path)
36
+
37
+ File.write(file_path, @raw_markdown)
29
38
  end
30
39
 
40
+ private
41
+ attr_reader :piece_path
42
+
31
43
  def partitioned_text
32
44
  @partitioned_text ||= raw_markdown.partition("\n\n")
33
45
  end
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
  require 'yaml'
2
3
 
3
4
  module Everything
@@ -5,6 +6,11 @@ module Everything
5
6
  class Metadata
6
7
  extend Forwardable
7
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
+
8
14
  def initialize(piece_path)
9
15
  @piece_path = piece_path
10
16
  end
@@ -17,6 +23,16 @@ module Everything
17
23
  @raw_yaml ||= YAML.load_file(file_path)
18
24
  end
19
25
 
26
+ def raw_yaml=(value)
27
+ @raw_yaml = value
28
+ end
29
+
30
+ def save
31
+ FileUtils.mkdir_p(piece_path)
32
+
33
+ File.write(file_path, @raw_yaml)
34
+ end
35
+
20
36
  def_delegators :raw_yaml, :[]
21
37
 
22
38
  private
@@ -1,3 +1,3 @@
1
1
  module Everything
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.12'
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.7
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Tolle
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2020-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -30,62 +30,74 @@ dependencies:
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.2
33
+ version: 0.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.2
40
+ version: 0.0.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.11'
47
+ version: '2.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.11'
54
+ version: '2.1'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 13.0.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 13.0.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '10.5'
75
+ version: '3.9'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '10.5'
82
+ version: '3.9'
69
83
  - !ruby/object:Gem::Dependency
70
- name: rspec
84
+ name: timecop
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '3.4'
89
+ version: '0.9'
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '3.4'
96
+ version: '0.9'
83
97
  description: Gives you access to pieces within your everything repo.
84
98
  email:
85
99
  - kyle@nullsix.com
86
- executables:
87
- - console
88
- - setup
100
+ executables: []
89
101
  extensions: []
90
102
  extra_rdoc_files: []
91
103
  files:
@@ -102,20 +114,22 @@ files:
102
114
  - bin/setup
103
115
  - everything-core.gemspec
104
116
  - lib/everything.rb
117
+ - lib/everything/logger.rb
118
+ - lib/everything/logger/base.rb
119
+ - lib/everything/logger/debug.rb
120
+ - lib/everything/logger/error.rb
121
+ - lib/everything/logger/log_it.rb
122
+ - lib/everything/logger/verbose.rb
105
123
  - lib/everything/piece.rb
106
124
  - lib/everything/piece/content.rb
107
125
  - lib/everything/piece/metadata.rb
108
126
  - lib/everything/version.rb
109
- - spec/everything/piece/content_spec.rb
110
- - spec/everything/piece/metadata_spec.rb
111
- - spec/everything/piece_spec.rb
112
- - spec/everything_spec.rb
113
- - spec/spec_helper.rb
114
- - spec/support/pieces.rb
115
127
  homepage: https://github.com/kyletolle/everything-core
116
128
  licenses:
117
129
  - MIT
118
- metadata: {}
130
+ metadata:
131
+ homepage_uri: https://github.com/kyletolle/everything-core
132
+ source_code_uri: https://github.com/kyletolle/everything-core
119
133
  post_install_message:
120
134
  rdoc_options: []
121
135
  require_paths:
@@ -124,22 +138,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
138
  requirements:
125
139
  - - ">="
126
140
  - !ruby/object:Gem::Version
127
- version: '0'
141
+ version: 2.7.1
128
142
  required_rubygems_version: !ruby/object:Gem::Requirement
129
143
  requirements:
130
144
  - - ">="
131
145
  - !ruby/object:Gem::Version
132
146
  version: '0'
133
147
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.4.5.1
148
+ rubygems_version: 3.1.2
136
149
  signing_key:
137
150
  specification_version: 4
138
151
  summary: Library for working with your `everything` repository.
139
- test_files:
140
- - spec/everything/piece/content_spec.rb
141
- - spec/everything/piece/metadata_spec.rb
142
- - spec/everything/piece_spec.rb
143
- - spec/everything_spec.rb
144
- - spec/spec_helper.rb
145
- - spec/support/pieces.rb
152
+ test_files: []
@@ -1,97 +0,0 @@
1
- require './spec/support/pieces'
2
-
3
- describe Everything::Piece::Content do
4
- shared_context 'with tmp piece markdown file on disk' do
5
- let(:tmp_piece_markdown_path) do
6
- File.join(tmp_piece_path, 'index.md')
7
- end
8
-
9
- let(:given_markdown) do
10
- <<MD
11
- # Piece Title Here
12
-
13
- The body is totally this right here.
14
-
15
- And it might even include multiple lines!
16
- MD
17
- end
18
-
19
- before do
20
- File.open(tmp_piece_markdown_path, 'w') do |markdown_file|
21
- markdown_file.puts given_markdown
22
- end
23
- end
24
- end
25
-
26
- let(:content) do
27
- described_class.new(tmp_piece_path)
28
- end
29
-
30
- describe '#file_path' do
31
- include_context 'with tmp piece on disk'
32
-
33
- let(:expected_file_path) do
34
- "#{tmp_piece_path}/index.md"
35
- end
36
-
37
- it 'is the index.md under the piece' do
38
- expect(content.file_path).to eq(expected_file_path)
39
- end
40
- end
41
-
42
- describe '#title' do
43
- include_context 'with tmp piece on disk'
44
- include_context 'with tmp piece markdown file on disk'
45
-
46
- let(:expected_title) do
47
- 'Piece Title Here'
48
- end
49
-
50
- it 'is the title from the markdown' do
51
- expect(content.title).to eq(expected_title)
52
- end
53
- end
54
-
55
- describe '#body' do
56
- include_context 'with tmp piece on disk'
57
- include_context 'with tmp piece markdown file on disk'
58
-
59
- let(:expected_body) do
60
- <<MD
61
- The body is totally this right here.
62
-
63
- And it might even include multiple lines!
64
- MD
65
- end
66
-
67
- it 'is the body text from the markdown' do
68
- expect(content.body).to eq(expected_body)
69
- end
70
- end
71
-
72
- describe '#raw_markdown' do
73
- include_context 'with tmp piece on disk'
74
- include_context 'with tmp piece markdown file on disk'
75
-
76
- let(:expected_raw_markdown) do
77
- given_markdown
78
- end
79
-
80
- it 'is the markdown from the file' do
81
- expect(content.raw_markdown).to eq(expected_raw_markdown)
82
- end
83
-
84
- it 'memoizes the file read' do
85
- allow(File)
86
- .to receive(:read)
87
- .and_call_original
88
-
89
- content.raw_markdown
90
- content.raw_markdown
91
-
92
- expect(File)
93
- .to have_received(:read)
94
- .exactly(:once)
95
- end
96
- end
97
- end
@@ -1,92 +0,0 @@
1
- require './spec/support/pieces'
2
-
3
- describe Everything::Piece::Metadata do
4
- shared_context 'with tmp piece metadata file on disk' do
5
- let(:tmp_piece_metadata_path) do
6
- File.join(tmp_piece_path, 'index.yaml')
7
- end
8
-
9
- let(:given_yaml) do
10
- <<YAML
11
- ---
12
- public: false
13
- YAML
14
- end
15
-
16
- before do
17
- File.open(tmp_piece_metadata_path, 'w') do |metadata_file|
18
- metadata_file.puts given_yaml
19
- end
20
- end
21
- end
22
-
23
- let(:metadata) do
24
- described_class.new(tmp_piece_path)
25
- end
26
-
27
- describe '#[]' do
28
- include_context 'with tmp piece on disk'
29
-
30
- let(:yaml_double) do
31
- instance_double(Hash)
32
- end
33
- let(:given_key) { 'public' }
34
-
35
- before do
36
- expect(YAML)
37
- .to receive(:load_file)
38
- .and_return(yaml_double)
39
- end
40
-
41
- it 'delegates to the yaml' do
42
- allow(yaml_double)
43
- .to receive(:[])
44
-
45
- metadata[given_key]
46
-
47
- expect(yaml_double)
48
- .to have_received(:[])
49
- .with(given_key)
50
- end
51
- end
52
-
53
- describe '#file_path' do
54
- include_context 'with tmp piece on disk'
55
-
56
- let(:expected_file_path) do
57
- "#{tmp_piece_path}/index.yaml"
58
- end
59
-
60
- it 'is the index.yaml under the piece' do
61
- expect(metadata.file_path).to eq(expected_file_path)
62
- end
63
- end
64
-
65
- describe '#raw_yaml' do
66
- include_context 'with tmp piece on disk'
67
- include_context 'with tmp piece metadata file on disk'
68
-
69
- let(:expected_raw_yaml) do
70
- {
71
- 'public' => false
72
- }
73
- end
74
-
75
- it 'is the yaml as parsed from the file' do
76
- expect(metadata.raw_yaml).to eq(expected_raw_yaml)
77
- end
78
-
79
- it 'memoizes the yaml read' do
80
- allow(YAML)
81
- .to receive(:load_file)
82
- .and_call_original
83
-
84
- metadata.raw_yaml
85
- metadata.raw_yaml
86
-
87
- expect(YAML)
88
- .to have_received(:load_file)
89
- .exactly(:once)
90
- end
91
- end
92
- end
@@ -1,118 +0,0 @@
1
- describe Everything::Piece do
2
- let(:given_full_path) do
3
- 'some/fake/path/here-is-our-piece'
4
- end
5
- let(:piece) do
6
- described_class.new(given_full_path)
7
- end
8
- shared_context 'with content double' do
9
- let(:content_double) do
10
- instance_double(Everything::Piece::Content)
11
- end
12
-
13
- before do
14
- allow(Everything::Piece::Content)
15
- .to receive(:new)
16
- .and_return(content_double)
17
- end
18
- end
19
-
20
- describe '#body' do
21
- include_context 'with content double'
22
-
23
- it 'delegates to the content' do
24
- allow(content_double).to receive(:body)
25
-
26
- piece.body
27
-
28
- expect(content_double).to have_received(:body)
29
- end
30
- end
31
-
32
- describe '#content' do
33
- it 'is an instance of Content' do
34
- expect(piece.content).to be_a(Everything::Piece::Content)
35
- end
36
-
37
- it "is created with the piece's full path" do
38
- expect(Everything::Piece::Content)
39
- .to receive(:new)
40
- .with(given_full_path)
41
-
42
- piece.content
43
- end
44
- end
45
-
46
- describe '#full_path' do
47
- it "returns the piece's full path" do
48
- expect(piece.full_path).to eq(given_full_path)
49
- end
50
- end
51
-
52
- describe '#metadata' do
53
- it 'is an instance of Metadata' do
54
- expect(piece.metadata).to be_a(Everything::Piece::Metadata)
55
- end
56
-
57
- it "is created with the piece's full path" do
58
- expect(Everything::Piece::Metadata)
59
- .to receive(:new)
60
- .with(given_full_path)
61
-
62
- piece.metadata
63
- end
64
- end
65
-
66
- describe '#name' do
67
- let(:expected_name) do
68
- 'here-is-our-piece'
69
- end
70
-
71
- it 'is the last part of the path' do
72
- expect(piece.name).to eq(expected_name)
73
- end
74
- end
75
-
76
- describe '#public?' do
77
- let(:metadata_double) do
78
- instance_double(Everything::Piece::Metadata)
79
- end
80
-
81
- it "returns the metadata's public value" do
82
- allow(Everything::Piece::Metadata)
83
- .to receive(:new)
84
- .and_return(metadata_double)
85
-
86
- expect(metadata_double)
87
- .to receive(:[])
88
- .with('public')
89
- .and_return(false)
90
-
91
- expect(piece.public?).to eq(false)
92
- end
93
- end
94
-
95
- describe '#raw_markdown' do
96
- include_context 'with content double'
97
-
98
- it 'delegates to the content' do
99
- allow(content_double).to receive(:raw_markdown)
100
-
101
- piece.raw_markdown
102
-
103
- expect(content_double).to have_received(:raw_markdown)
104
- end
105
- end
106
-
107
- describe '#title' do
108
- include_context 'with content double'
109
-
110
- it 'delegates to the content' do
111
- allow(content_double).to receive(:title)
112
-
113
- piece.title
114
-
115
- expect(content_double).to have_received(:title)
116
- end
117
- end
118
- end
@@ -1,19 +0,0 @@
1
- describe Everything do
2
- it 'has a version number' do
3
- expect(Everything::VERSION).not_to be nil
4
- end
5
-
6
- describe '.path' do
7
- let(:expected_path) do
8
- '/some/path/to/your/everything/repo/'
9
- end
10
-
11
- before do
12
- ENV['EVERYTHING_PATH'] = expected_path
13
- end
14
-
15
- it 'is the path from the environment' do
16
- expect(described_class.path).to eq(expected_path)
17
- end
18
- end
19
- end
@@ -1,99 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'everything'
3
-
4
- # This file was generated by the `rspec --init` command. Conventionally, all
5
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
6
- # The generated `.rspec` file contains `--require spec_helper` which will cause
7
- # this file to always be loaded, without a need to explicitly require it in any
8
- # files.
9
- #
10
- # Given that it is always loaded, you are encouraged to keep this file as
11
- # light-weight as possible. Requiring heavyweight dependencies from this file
12
- # will add to the boot time of your test suite on EVERY test run, even for an
13
- # individual file that may not need all of that loaded. Instead, consider making
14
- # a separate helper file that requires the additional dependencies and performs
15
- # the additional setup, and require it from the spec files that actually need
16
- # it.
17
- #
18
- # The `.rspec` file also contains a few flags that are not defaults but that
19
- # users commonly want.
20
- #
21
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
22
- RSpec.configure do |config|
23
- # rspec-expectations config goes here. You can use an alternate
24
- # assertion/expectation library such as wrong or the stdlib/minitest
25
- # assertions if you prefer.
26
- config.expect_with :rspec do |expectations|
27
- # This option will default to `true` in RSpec 4. It makes the `description`
28
- # and `failure_message` of custom matchers include text for helper methods
29
- # defined using `chain`, e.g.:
30
- # be_bigger_than(2).and_smaller_than(4).description
31
- # # => "be bigger than 2 and smaller than 4"
32
- # ...rather than:
33
- # # => "be bigger than 2"
34
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
35
- end
36
-
37
- # rspec-mocks config goes here. You can use an alternate test double
38
- # library (such as bogus or mocha) by changing the `mock_with` option here.
39
- config.mock_with :rspec do |mocks|
40
- # Prevents you from mocking or stubbing a method that does not exist on
41
- # a real object. This is generally recommended, and will default to
42
- # `true` in RSpec 4.
43
- mocks.verify_partial_doubles = true
44
- end
45
-
46
- # These two settings work together to allow you to limit a spec run
47
- # to individual examples or groups you care about by tagging them with
48
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
- # get run.
50
- config.filter_run :focus
51
- config.run_all_when_everything_filtered = true
52
-
53
- # This setting enables warnings. It's recommended, but in some cases may
54
- # be too noisy due to issues in dependencies.
55
- config.warnings = true
56
-
57
- # Run specs in random order to surface order dependencies. If you find an
58
- # order dependency and want to debug it, you can fix the order by providing
59
- # the seed, which is printed after each run.
60
- # --seed 1234
61
- config.order = :random
62
-
63
- # Seed global randomization in this process using the `--seed` CLI option.
64
- # Setting this allows you to use `--seed` to deterministically reproduce
65
- # test failures related to randomization by passing the same `--seed` value
66
- # as the one that triggered the failure.
67
- Kernel.srand config.seed
68
-
69
- # The settings below are suggested to provide a good initial experience
70
- # with RSpec, but feel free to customize to your heart's content.
71
- =begin
72
- # Limits the available syntax to the non-monkey patched syntax that is
73
- # recommended. For more details, see:
74
- # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
75
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
76
- # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
77
- config.disable_monkey_patching!
78
-
79
- # Many RSpec users commonly either run the entire suite or an individual
80
- # file, and it's useful to allow more verbose output when running an
81
- # individual spec file.
82
- if config.files_to_run.one?
83
- # Use the documentation formatter for detailed output,
84
- # unless a formatter has already been configured
85
- # (e.g. via a command-line flag).
86
- config.default_formatter = 'doc'
87
- end
88
-
89
- # Allows RSpec to persist some state between runs in order to support
90
- # the `--only-failures` and `--next-failure` CLI options. We recommend
91
- # you configure your source control system to ignore this file.
92
- config.example_status_persistence_file_path = "spec/examples.txt"
93
-
94
- # Print the 10 slowest examples and example groups at the
95
- # end of the spec run, to help surface which specs are running
96
- # particularly slow.
97
- config.profile_examples = 10
98
- =end
99
- end
@@ -1,10 +0,0 @@
1
- RSpec.shared_context 'with tmp piece on disk' do
2
- let!(:tmp_piece_path) do
3
- Dir.mktmpdir
4
- end
5
-
6
- after do
7
- # This will recursively remove everything under that tmp dir.
8
- FileUtils.remove_entry(tmp_piece_path)
9
- end
10
- end