everything-core 0.0.4 → 0.0.6
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/.gitignore +9 -2
- data/.travis.yml +4 -0
- data/CHANGELOG.md +13 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/README.md +50 -6
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/everything-core.gemspec +1 -1
- data/lib/everything/piece/content.rb +36 -0
- data/lib/everything/piece/metadata.rb +30 -0
- data/lib/everything/piece.rb +11 -13
- data/lib/everything/version.rb +1 -1
- data/spec/everything/piece/content_spec.rb +97 -0
- data/spec/everything/piece/metadata_spec.rb +92 -0
- data/spec/everything/piece_spec.rb +70 -37
- data/spec/spec_helper.rb +23 -23
- data/spec/support/pieces.rb +10 -0
- metadata +22 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1e55885b20990f6ab77929b12caf60764e35147
|
4
|
+
data.tar.gz: f1abad4f7afdad19f21149cfcc9ff84f0c287380
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1412bc7491dbe5f794afe3feaf2592d3a5a1fd06d652cfdfbbf1f5a562021699592a056464d14383f786960a0d0a7efaaacea88607555805df1586f967268cce
|
7
|
+
data.tar.gz: 09b06432902bedaee4cc7629207984e4e1c81c939f00258a4859b2afdc1db6acd7a7d18c97ebc96d73863d423ca954624ced23b222fe4272885570fc434e6781
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.0.6
|
4
|
+
|
5
|
+
- Add an Everything::Piece::Content class
|
6
|
+
- Add an Everything::Piece::Metadata class
|
7
|
+
- Rename piece#content to piece#body
|
8
|
+
- Add a piece#content to return the piece's content
|
9
|
+
- Add a piece#metadata to return the piece's metadata
|
10
|
+
- Add a piece#public? for easily checking the metadata for the `public` boolean
|
11
|
+
|
12
|
+
## 0.0.5
|
13
|
+
|
14
|
+
- Increase version number of dotenv dependency
|
15
|
+
|
3
16
|
## 0.0.4
|
4
17
|
|
5
18
|
- Add Everything::Piece#full_path to return path of the piece
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at kyle at nullsix dot com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
#
|
1
|
+
# Everything
|
2
|
+
[](http://badge.fury.io/rb/everything-core)
|
3
|
+
[](https://travis-ci.org/kyletolle/everything-core)
|
4
|
+
[](https://codeclimate.com/github/kyletolle/everything-core)
|
5
|
+
[](https://gemnasium.com/kyletolle/everything-core)
|
2
6
|
|
3
7
|
For familiarity with a `everything` repository, see the
|
4
8
|
[intro](http://blog.kyletolle.com/introducing-everything/).
|
@@ -12,12 +16,24 @@ Must define these environment variables:
|
|
12
16
|
|
13
17
|
- `EVERYTHING_PATH` - the full path to your everything repo.
|
14
18
|
|
19
|
+
|
15
20
|
## Installation
|
16
21
|
|
17
|
-
|
22
|
+
Add this line to your application's Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
18
25
|
gem install everything-core
|
19
26
|
```
|
20
27
|
|
28
|
+
And then execute:
|
29
|
+
|
30
|
+
$ bundle
|
31
|
+
|
32
|
+
Or install it yourself as:
|
33
|
+
|
34
|
+
$ gem install everything-core
|
35
|
+
|
36
|
+
|
21
37
|
## Usage
|
22
38
|
|
23
39
|
This assumes you have a `EVERYTHING_PATH` environment variable either set in
|
@@ -31,7 +47,7 @@ your-piece-here/index.md
|
|
31
47
|
|
32
48
|
# Your Piece Here
|
33
49
|
|
34
|
-
The rest of the
|
50
|
+
The rest of the body of your file...
|
35
51
|
|
36
52
|
```
|
37
53
|
|
@@ -44,11 +60,39 @@ require 'everything'
|
|
44
60
|
piece_path = File.join(Everything.path, 'your-piece-here')
|
45
61
|
piece = Everything::Piece.new(piece_path)
|
46
62
|
|
47
|
-
piece.title
|
48
|
-
piece.
|
63
|
+
piece.title # => "Your Piece Here"
|
64
|
+
piece.body # => "The rest of the body of your file...\n\n"
|
65
|
+
piece['categories'] # Returns the value for the `categories` metadata key
|
66
|
+
piece.public? # Convience method to return the value for the boolean `public` metadata key
|
67
|
+
piece.content # Return an instance of the piece's content
|
68
|
+
piece.metadata # Return an instance of the piece's metadata
|
49
69
|
```
|
50
70
|
|
71
|
+
|
72
|
+
## Development
|
73
|
+
|
74
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
75
|
+
`rake spec` to run the tests. You can also run `bin/console` for an interactive
|
76
|
+
prompt that will allow you to experiment.
|
77
|
+
|
78
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To
|
79
|
+
release a new version, update the version number in `version.rb`, and then run
|
80
|
+
`bundle exec rake release`, which will create a git tag for the version, push
|
81
|
+
git commits and tags, and push the `.gem` file to
|
82
|
+
[rubygems.org](https://rubygems.org).
|
83
|
+
|
84
|
+
|
85
|
+
## Contributing
|
86
|
+
|
87
|
+
Bug reports and pull requests are welcome on GitHub at
|
88
|
+
https://github.com/kyletolle/everything-core. This project is intended to
|
89
|
+
be a safe, welcoming space for collaboration, and contributors are expected to
|
90
|
+
adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
|
91
|
+
conduct.
|
92
|
+
|
93
|
+
|
51
94
|
## License
|
52
95
|
|
53
|
-
MIT
|
96
|
+
The gem is available as open source under the terms of the [MIT
|
97
|
+
License](http://opensource.org/licenses/MIT).
|
54
98
|
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "everything"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/everything-core.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'dotenv', '
|
21
|
+
spec.add_runtime_dependency 'dotenv', '~> 2.1'
|
22
22
|
spec.add_runtime_dependency 'fastenv', '= 0.0.2'
|
23
23
|
|
24
24
|
spec.add_development_dependency 'bundler', '~> 1.11'
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Everything
|
2
|
+
class Piece
|
3
|
+
class Content
|
4
|
+
def initialize(piece_path)
|
5
|
+
@piece_path = piece_path
|
6
|
+
end
|
7
|
+
|
8
|
+
def file_path
|
9
|
+
@file_path ||= File.join(piece_path, file_name)
|
10
|
+
end
|
11
|
+
|
12
|
+
def title
|
13
|
+
partitioned_text.first.sub('# ', '')
|
14
|
+
end
|
15
|
+
|
16
|
+
def body
|
17
|
+
partitioned_text.last
|
18
|
+
end
|
19
|
+
|
20
|
+
def raw_markdown
|
21
|
+
@raw_markdown ||= File.read(file_path)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
attr_reader :piece_path
|
26
|
+
|
27
|
+
def file_name
|
28
|
+
'index.md'
|
29
|
+
end
|
30
|
+
|
31
|
+
def partitioned_text
|
32
|
+
@partitioned_text ||= raw_markdown.partition("\n\n")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Everything
|
4
|
+
class Piece
|
5
|
+
class Metadata
|
6
|
+
extend Forwardable
|
7
|
+
|
8
|
+
def initialize(piece_path)
|
9
|
+
@piece_path = piece_path
|
10
|
+
end
|
11
|
+
|
12
|
+
def file_path
|
13
|
+
@file_path ||= File.join(piece_path, file_name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def raw_yaml
|
17
|
+
@raw_yaml ||= YAML.load_file(file_path)
|
18
|
+
end
|
19
|
+
|
20
|
+
def_delegators :raw_yaml, :[]
|
21
|
+
|
22
|
+
private
|
23
|
+
attr_reader :piece_path
|
24
|
+
|
25
|
+
def file_name
|
26
|
+
'index.yaml'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/everything/piece.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Everything
|
2
2
|
class Piece
|
3
|
+
extend Forwardable
|
4
|
+
|
3
5
|
attr_reader :full_path
|
4
6
|
|
5
7
|
def initialize(full_path)
|
@@ -7,25 +9,21 @@ module Everything
|
|
7
9
|
end
|
8
10
|
|
9
11
|
def content
|
10
|
-
@content ||=
|
12
|
+
@content ||= Content.new(full_path)
|
11
13
|
end
|
12
14
|
|
13
|
-
|
14
|
-
@title ||= partitioned_content.first.sub('# ', '')
|
15
|
-
end
|
15
|
+
def_delegators :content, :body, :raw_markdown, :title
|
16
16
|
|
17
|
-
def
|
18
|
-
@
|
17
|
+
def metadata
|
18
|
+
@metadata ||= Metadata.new(full_path)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
@content_path ||= File.join(@full_path, 'index.md')
|
24
|
-
end
|
25
|
-
|
26
|
-
def partitioned_content
|
27
|
-
@partitioned_content ||= raw_markdown.partition("\n\n")
|
21
|
+
def public?
|
22
|
+
metadata['public']
|
28
23
|
end
|
29
24
|
end
|
30
25
|
end
|
31
26
|
|
27
|
+
require 'everything/piece/content'
|
28
|
+
require 'everything/piece/metadata'
|
29
|
+
|
data/lib/everything/version.rb
CHANGED
@@ -0,0 +1,97 @@
|
|
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
|
@@ -0,0 +1,92 @@
|
|
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
|
@@ -5,41 +5,41 @@ describe Everything::Piece do
|
|
5
5
|
let(:piece) do
|
6
6
|
described_class.new(given_full_path)
|
7
7
|
end
|
8
|
-
|
9
|
-
|
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
|
10
18
|
end
|
11
|
-
let(:fake_markdown_text) do
|
12
|
-
<<MD
|
13
|
-
# Piece Title Here
|
14
19
|
|
15
|
-
|
20
|
+
describe '#body' do
|
21
|
+
include_context 'with content double'
|
16
22
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
23
|
+
it 'delegates to the content' do
|
24
|
+
allow(content_double).to receive(:body)
|
20
25
|
|
21
|
-
|
22
|
-
|
23
|
-
expect(
|
24
|
-
.to receive(:read)
|
25
|
-
.with(expected_markdown_file_path)
|
26
|
-
.and_return(fake_markdown_text)
|
26
|
+
piece.body
|
27
|
+
|
28
|
+
expect(content_double).to have_received(:body)
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
32
|
describe '#content' do
|
31
|
-
|
32
|
-
|
33
|
-
let(:expected_content) do
|
34
|
-
<<TEXT
|
35
|
-
The content is totally this right here.
|
36
|
-
|
37
|
-
And it might even include multiple lines!
|
38
|
-
TEXT
|
33
|
+
it 'is an instance of Content' do
|
34
|
+
expect(piece.content).to be_a(Everything::Piece::Content)
|
39
35
|
end
|
40
36
|
|
41
|
-
it
|
42
|
-
expect(
|
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
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -49,27 +49,60 @@ TEXT
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe '#
|
53
|
-
|
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)
|
54
61
|
|
55
|
-
|
56
|
-
fake_markdown_text
|
62
|
+
piece.metadata
|
57
63
|
end
|
64
|
+
end
|
58
65
|
|
59
|
-
|
60
|
-
|
66
|
+
describe '#public?' do
|
67
|
+
let(:metadata_double) do
|
68
|
+
instance_double(Everything::Piece::Metadata)
|
69
|
+
end
|
70
|
+
|
71
|
+
it "returns the metadata's public value" do
|
72
|
+
allow(Everything::Piece::Metadata)
|
73
|
+
.to receive(:new)
|
74
|
+
.and_return(metadata_double)
|
75
|
+
|
76
|
+
expect(metadata_double)
|
77
|
+
.to receive(:[])
|
78
|
+
.with('public')
|
79
|
+
.and_return(false)
|
80
|
+
|
81
|
+
expect(piece.public?).to eq(false)
|
61
82
|
end
|
62
83
|
end
|
63
84
|
|
64
|
-
describe '#
|
65
|
-
include_context 'with
|
85
|
+
describe '#raw_markdown' do
|
86
|
+
include_context 'with content double'
|
87
|
+
|
88
|
+
it 'delegates to the content' do
|
89
|
+
allow(content_double).to receive(:raw_markdown)
|
66
90
|
|
67
|
-
|
68
|
-
|
91
|
+
piece.raw_markdown
|
92
|
+
|
93
|
+
expect(content_double).to have_received(:raw_markdown)
|
69
94
|
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#title' do
|
98
|
+
include_context 'with content double'
|
99
|
+
|
100
|
+
it 'delegates to the content' do
|
101
|
+
allow(content_double).to receive(:title)
|
102
|
+
|
103
|
+
piece.title
|
70
104
|
|
71
|
-
|
72
|
-
expect(piece.title).to eq(expected_title)
|
105
|
+
expect(content_double).to have_received(:title)
|
73
106
|
end
|
74
107
|
end
|
75
108
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -43,9 +43,6 @@ RSpec.configure do |config|
|
|
43
43
|
mocks.verify_partial_doubles = true
|
44
44
|
end
|
45
45
|
|
46
|
-
# The settings below are suggested to provide a good initial experience
|
47
|
-
# with RSpec, but feel free to customize to your heart's content.
|
48
|
-
=begin
|
49
46
|
# These two settings work together to allow you to limit a spec run
|
50
47
|
# to individual examples or groups you care about by tagging them with
|
51
48
|
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
@@ -53,11 +50,25 @@ RSpec.configure do |config|
|
|
53
50
|
config.filter_run :focus
|
54
51
|
config.run_all_when_everything_filtered = true
|
55
52
|
|
56
|
-
#
|
57
|
-
#
|
58
|
-
|
59
|
-
config.example_status_persistence_file_path = "spec/examples.txt"
|
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
|
60
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
|
61
72
|
# Limits the available syntax to the non-monkey patched syntax that is
|
62
73
|
# recommended. For more details, see:
|
63
74
|
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
@@ -65,10 +76,6 @@ RSpec.configure do |config|
|
|
65
76
|
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
66
77
|
config.disable_monkey_patching!
|
67
78
|
|
68
|
-
# This setting enables warnings. It's recommended, but in some cases may
|
69
|
-
# be too noisy due to issues in dependencies.
|
70
|
-
config.warnings = true
|
71
|
-
|
72
79
|
# Many RSpec users commonly either run the entire suite or an individual
|
73
80
|
# file, and it's useful to allow more verbose output when running an
|
74
81
|
# individual spec file.
|
@@ -79,21 +86,14 @@ RSpec.configure do |config|
|
|
79
86
|
config.default_formatter = 'doc'
|
80
87
|
end
|
81
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
|
+
|
82
94
|
# Print the 10 slowest examples and example groups at the
|
83
95
|
# end of the spec run, to help surface which specs are running
|
84
96
|
# particularly slow.
|
85
97
|
config.profile_examples = 10
|
86
|
-
|
87
|
-
# Run specs in random order to surface order dependencies. If you find an
|
88
|
-
# order dependency and want to debug it, you can fix the order by providing
|
89
|
-
# the seed, which is printed after each run.
|
90
|
-
# --seed 1234
|
91
|
-
config.order = :random
|
92
|
-
|
93
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
94
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
95
|
-
# test failures related to randomization by passing the same `--seed` value
|
96
|
-
# as the one that triggered the failure.
|
97
|
-
Kernel.srand config.seed
|
98
98
|
=end
|
99
99
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: everything-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Tolle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: '2.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fastenv
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,23 +83,35 @@ dependencies:
|
|
83
83
|
description: Gives you access to pieces within your everything repo.
|
84
84
|
email:
|
85
85
|
- kyle@nullsix.com
|
86
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- console
|
88
|
+
- setup
|
87
89
|
extensions: []
|
88
90
|
extra_rdoc_files: []
|
89
91
|
files:
|
90
92
|
- ".gitignore"
|
91
93
|
- ".rspec"
|
94
|
+
- ".travis.yml"
|
92
95
|
- CHANGELOG.md
|
96
|
+
- CODE_OF_CONDUCT.md
|
93
97
|
- Gemfile
|
94
98
|
- LICENSE
|
95
99
|
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/console
|
102
|
+
- bin/setup
|
96
103
|
- everything-core.gemspec
|
97
104
|
- lib/everything.rb
|
98
105
|
- lib/everything/piece.rb
|
106
|
+
- lib/everything/piece/content.rb
|
107
|
+
- lib/everything/piece/metadata.rb
|
99
108
|
- lib/everything/version.rb
|
109
|
+
- spec/everything/piece/content_spec.rb
|
110
|
+
- spec/everything/piece/metadata_spec.rb
|
100
111
|
- spec/everything/piece_spec.rb
|
101
112
|
- spec/everything_spec.rb
|
102
113
|
- spec/spec_helper.rb
|
114
|
+
- spec/support/pieces.rb
|
103
115
|
homepage: https://github.com/kyletolle/everything-core
|
104
116
|
licenses:
|
105
117
|
- MIT
|
@@ -125,7 +137,9 @@ signing_key:
|
|
125
137
|
specification_version: 4
|
126
138
|
summary: Library for working with your `everything` repository.
|
127
139
|
test_files:
|
140
|
+
- spec/everything/piece/content_spec.rb
|
141
|
+
- spec/everything/piece/metadata_spec.rb
|
128
142
|
- spec/everything/piece_spec.rb
|
129
143
|
- spec/everything_spec.rb
|
130
144
|
- spec/spec_helper.rb
|
131
|
-
|
145
|
+
- spec/support/pieces.rb
|