rendering_engine 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzBjMGJhYjU0MDFjNzA3YmEzODJjNTBhNmI5NWJlZjhmYzViZDc0Zg==
5
- data.tar.gz: !binary |-
6
- YTI2OWRhOWNkMTIwNDc0NWJiYTg3YmZhNzUyNjU3M2E0ZDNmNmFlNg==
2
+ SHA1:
3
+ metadata.gz: b23fb266e360b45e33135d7a2c8e2ec3cfd17ab3
4
+ data.tar.gz: 3a78f2fa0eef4ad271ae72a153e83047359d7934
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NDI0OGRmM2JjMjY5ZDVhMDUyZmM5YTc3YTExYTU1NjhjMjZhYTBkMzkwMzZj
10
- MzVmYmIyNDgxMzUyNmU5ZTQzN2EyYzA4YjFkZDgzY2Y4YjlmNmVlNzk3Yjcw
11
- NjlhNGNjODg3ZmIxNDAzYWUzNzRhM2NkODZkN2VhNDQ2NzE0Njk=
12
- data.tar.gz: !binary |-
13
- NzljNjYwNjZkZTg3OGJhNGM1NmMyYWE0YjgyZTA1ZmUzZTI3NWY5MWQ1ZjNk
14
- ZDY4ODhjMTZkODU0ZjVmZmJlZDhmMDFiZDE2YTcwNWNhMGNkYjEwYWY1YTA2
15
- MmQyOGY2YWQwOTY3MTllNmIxZDQzZDBlZDRkZjdhZWJlZTdmMzM=
6
+ metadata.gz: 410ead0114544811441bc82756de35904474c56519ab21bb3027f70107d017cc012f0d3efffaaf8ce1ee4298d3568f35835f4177717317a5686be6b92a2995ee
7
+ data.tar.gz: 38b71f11ead7a33f98a93cd396a997ae74354b12c7ae0c0385a48d4048977dfdc3f99dd35f474561005576edd5fd21c357f3a92e2d471efb64e68a77920c9db7
data/.rspec CHANGED
@@ -1,2 +1,4 @@
1
1
  --color
2
+ --require spec_helper
2
3
  --format progress
4
+ --no-profile
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ script: bundle exec rake
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
@@ -0,0 +1,6 @@
1
+ guard :rspec, cmd: 'rspec' do
2
+ watch(%r{^lib/(.+).rb$}) { |m| "spec/unit/lib/#{m[1]}_spec.rb" }
3
+ watch(%r{^spec/(.+).rb$}) { |m| "spec/#{m[1]}.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ watch('Gemfile')
6
+ end
data/README.md CHANGED
@@ -16,7 +16,8 @@ Or install it yourself as:
16
16
 
17
17
  ## Usage
18
18
 
19
- $ content_provider = RenderingEngine::Provider.new(base_path)
19
+ $ file_repo = RenderingEngine::FileRepo.new(base_path)
20
+ $ content_provider = RenderingEngine::Provider.new(file_repo)
20
21
  $ content = content_provider.get(relative_file_path)
21
22
  $ content.source #gets source of file (rendered or not :D)
22
23
  $ content.kind return (:orginal, :template, :unknown)
@@ -35,10 +36,69 @@ Or install it yourself as:
35
36
  end
36
37
 
37
38
  def content_provider
38
- @content_provider ||= RenderingEngine::Provider.new(Rails.root.join('app/content'))
39
+ @content_provider ||= RenderingEngine::Provider.new(file_repo)
40
+ end
41
+
42
+ def file_repo
43
+ @file_repo ||= RenderingEngine::FileRepo(Rails.root.join('app/content'))
39
44
  end
40
45
  ---
41
46
 
47
+ ## Own File repository class
48
+ needed gems 'moped' and 'moped-gridfs'
49
+
50
+ ```
51
+ class MongoFileRepo
52
+ def initilaize(mongo)
53
+ @mongo = mongo
54
+ end
55
+
56
+ def get(file_path)
57
+ bucket.open(file_path, 'r+')
58
+ end
59
+
60
+ def read(file_path)
61
+ bucket.open(file_path, 'r').read
62
+ end
63
+
64
+ def exist?(file_path)
65
+ bucket.files.select { |f| f.filename == file_path }.count > 0
66
+ end
67
+
68
+ def save(file_path, body, opts = {})
69
+ file_opts = opts.merge(filename: file_path)
70
+ bucket.open(file_opts , 'w+').write(body)
71
+ end
72
+
73
+ def delete(file_path)
74
+ bucket.delete(file_path)
75
+ end
76
+
77
+ def file_dirname(file_path)
78
+ File.dirname(file_path)
79
+ end
80
+
81
+ private
82
+
83
+ attr_reader :mongo
84
+
85
+ def bucket
86
+ @bucket ||= mongo.bucket
87
+ end
88
+ end
89
+ ```
90
+
91
+ ### Usage own custom file repository class
92
+
93
+ ```
94
+
95
+ mongo = Moped::Session.new(['127.0.0.1:27017'], database: 'test')
96
+ file_repo = MongoFileRepo(mongo)
97
+ provider = RenderingEngine::Provider.new(file_repo)
98
+ provider.get(path, custom_helper: ContentCustomHelpers).source
99
+
100
+ ```
101
+
42
102
  ## Own Helper class
43
103
 
44
104
  ```
@@ -69,11 +129,12 @@ end
69
129
 
70
130
  ```
71
131
 
72
- ### Usage own custom class
132
+ ### Usage own custom helper class
73
133
 
74
134
  ```
75
135
 
76
- provider = RenderingEngine::Provider.new(Rails.root.join('app/content'), custom_helper: ContentCustomHelpers)
136
+ file_repo = RenderingEngine::FileRepo.new(Rails.root.join('app/content'))
137
+ provider = RenderingEngine::Provider.new(file_repo, custom_helper: ContentCustomHelpers)
77
138
  provider.get(path).source
78
139
 
79
140
  ```
@@ -82,10 +143,10 @@ or
82
143
 
83
144
  ```
84
145
 
85
- provider = RenderingEngine::Provider.new(Rails.root.join('app/content'))
146
+ file_repo = RenderingEngine::FileRepo.new(Rails.root.join('app/content'))
147
+ provider = RenderingEngine::Provider.new(file_repo)
86
148
  provider.get(path, custom_helper: ContentCustomHelpers).source
87
149
 
88
-
89
150
  ```
90
151
 
91
152
  ## Contributing
data/Rakefile CHANGED
@@ -1 +1,6 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -1,8 +1,8 @@
1
- require "rendering_engine/version"
2
- require "rendering_engine/content_helpers"
3
- require "rendering_engine/content"
4
- require "rendering_engine/provider"
1
+ require 'rendering_engine/version'
2
+ require 'rendering_engine/file_repo'
3
+ require 'rendering_engine/content_helpers'
4
+ require 'rendering_engine/content'
5
+ require 'rendering_engine/provider'
5
6
 
6
7
  module RenderingEngine
7
-
8
8
  end
@@ -2,9 +2,10 @@ require 'erb'
2
2
 
3
3
  module RenderingEngine
4
4
  class Content
5
- attr_reader :file_path, :data
5
+ attr_reader :file_repo, :file_path, :data
6
6
 
7
- def initialize(file_path, opts={})
7
+ def initialize(file_repo, file_path, opts = {})
8
+ @file_repo = file_repo
8
9
  @file_path = file_path
9
10
  @base_folder_path = opts[:base_folder_path]
10
11
  @data = opts[:data]
@@ -14,9 +15,9 @@ module RenderingEngine
14
15
  def source
15
16
  @source ||= (
16
17
  case kind
17
- when :orginal then File.read(file_path)
18
+ when :orginal then file_repo.read(file_path)
18
19
  when :template
19
- ERB.new(File.read(file_path_as_erb)).result(
20
+ ERB.new(file_repo.read(file_path_as_erb)).result(
20
21
  helper(base_folder_path, data).instance_eval { binding }
21
22
  )
22
23
  else ''
@@ -49,7 +50,7 @@ module RenderingEngine
49
50
  end
50
51
 
51
52
  def base_folder_path
52
- @base_folder_path ||= File.dirname(file_path)
53
+ @base_folder_path ||= file_repo.file_dirname(file_path)
53
54
  end
54
55
 
55
56
  private
@@ -57,15 +58,17 @@ module RenderingEngine
57
58
  attr_reader :custom_helper
58
59
 
59
60
  def helper(path, content_data)
60
- (custom_helper || ContentHelpers).new(base_path: path, data: content_data)
61
+ (custom_helper || ContentHelpers).new(file_repo,
62
+ base_path: path,
63
+ data: content_data)
61
64
  end
62
65
 
63
66
  def orginal_file_present?
64
- File.exist?(file_path)
67
+ file_repo.exist?(file_path)
65
68
  end
66
69
 
67
70
  def file_as_erb_present?
68
- File.exist?(file_path_as_erb)
71
+ file_repo.exist?(file_path_as_erb)
69
72
  end
70
73
 
71
74
  def file_path_as_erb
@@ -1,21 +1,22 @@
1
1
  module RenderingEngine
2
2
  class ContentHelpers
3
- def initialize(opts={})
3
+ def initialize(file_repo, opts = {})
4
+ @file_repo = file_repo
4
5
  @base_path = opts.fetch(:base_path)
5
6
  @data = opts[:data]
6
7
  end
7
8
 
8
- def render(file_relative_path, optional_data=nil)
9
+ def render(file_relative_path, optional_data = nil)
9
10
  file_path = File.join(base_path, file_relative_path)
10
- renering_data = optional_data || data
11
+ rendering_data = optional_data || data
11
12
 
12
- RenderingEngine::Content.new(file_path, data: renering_data).source
13
+ RenderingEngine::Content.new(file_repo, file_path, data: rendering_data).source
13
14
  end
14
15
 
15
16
  attr_reader :data
16
17
 
17
18
  private
18
19
 
19
- attr_reader :base_path
20
+ attr_reader :base_path, :file_repo
20
21
  end
21
22
  end
@@ -0,0 +1,27 @@
1
+ module RenderingEngine
2
+ class FileRepo
3
+ attr_reader :base_path
4
+
5
+ def initialize(base_path)
6
+ @base_path = base_path
7
+ end
8
+
9
+ def read(file_path)
10
+ File.read(full_file_path(file_path))
11
+ end
12
+
13
+ def exist?(file_path)
14
+ File.exist?(full_file_path(file_path))
15
+ end
16
+
17
+ def file_dirname(file_path)
18
+ File.dirname(file_path)
19
+ end
20
+
21
+ private
22
+
23
+ def full_file_path(file_path)
24
+ File.join(base_path, file_path)
25
+ end
26
+ end
27
+ end
@@ -1,18 +1,17 @@
1
1
  module RenderingEngine
2
2
  class Provider
3
- def initialize(base_path, base_opts={})
4
- @base_path = base_path
3
+ def initialize(file_repo, base_opts = {})
4
+ @file_repo = file_repo
5
5
  @base_opts = base_opts
6
6
  end
7
7
 
8
- def get(relative_path, opts={})
9
- file_path = File.join(base_path, relative_path)
8
+ def get(file_path, opts = {})
10
9
  content_opts = base_opts.merge(opts)
11
- Content.new(file_path, content_opts)
10
+ Content.new(file_repo, file_path, content_opts)
12
11
  end
13
12
 
14
13
  private
15
14
 
16
- attr_reader :base_path, :base_opts
15
+ attr_reader :file_repo, :base_opts
17
16
  end
18
17
  end
@@ -1,3 +1,3 @@
1
1
  module RenderingEngine
2
- VERSION = "0.1.1"
2
+ VERSION = '0.2.0'
3
3
  end
@@ -4,21 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'rendering_engine/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "rendering_engine"
7
+ spec.name = 'rendering_engine'
8
8
  spec.version = RenderingEngine::VERSION
9
- spec.authors = ["Paweł Niemczyk"]
10
- spec.email = ["pniemczyk@o2.pl"]
9
+ spec.authors = ['Paweł Niemczyk']
10
+ spec.email = ['pniemczyk@o2.pl']
11
11
  spec.description = %q{ Rendering engine based on ERB }
12
12
  spec.summary = %q{ Rendering engine based on ERB }
13
- spec.homepage = "https://github.com/pniemczyk/rendering_engine"
14
- spec.license = "MIT"
13
+ spec.homepage = 'https://github.com/pniemczyk/rendering_engine'
14
+ spec.license = 'MIT'
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake', '~> 0'
23
+ spec.add_development_dependency 'rspec', '~> 3.1'
24
+ spec.add_development_dependency 'guard-rspec', '~> 0'
25
+ spec.add_development_dependency 'coveralls', '~> 0'
24
26
  end
@@ -1,19 +1,22 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe RenderingEngine::ContentHelpers do
4
+ let(:file_repo) { double('RenderingEngine::FileRepo') }
4
5
  let(:base_path) { 'root/path' }
5
6
  let(:file_relative_path) { 'login.haml' }
6
7
  let(:file_path) { File.join(base_path, file_relative_path) }
7
8
  let(:content) { double('content_object', source: source) }
8
9
  let(:source) { 'file_source' }
9
- let(:content_data) {{ name: 'pawel' }}
10
- subject { described_class.new(base_path: base_path, data: content_data) }
10
+ let(:content_data) { { name: 'pawel' } }
11
+ subject { described_class.new(file_repo, base_path: base_path, data: content_data) }
11
12
 
12
13
  it '#render' do
13
- RenderingEngine::Content.should_receive(:new)
14
- .with(file_path, data: content_data)
15
- .and_return(content)
14
+ expect(RenderingEngine::Content).to receive(:new)
15
+ .with(file_repo,
16
+ file_path,
17
+ data: content_data)
18
+ .and_return(content)
16
19
 
17
- subject.render(file_relative_path).should eq source
20
+ expect(subject.render(file_relative_path)).to eq(source)
18
21
  end
19
22
  end
@@ -1,13 +1,13 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe RenderingEngine::Content do
4
- let(:test_base_path){ nil }
5
- let(:base_path) { 'root/contract/files' }
6
- let(:relative_path) { 'login/form.html' }
7
- let(:file_path) { File.join(base_path, relative_path) }
8
- let(:content) { double('ContentObject') }
9
- let(:content_data) { nil }
10
- let(:custom_helper) { nil }
4
+ let(:file_repo) { double('RenderingEngine::FileRepo') }
5
+ let(:test_base_path) { nil }
6
+ let(:relative_path) { 'login' }
7
+ let(:file_path) { "#{relative_path}/form.html" }
8
+ let(:content) { double('ContentObject') }
9
+ let(:content_data) { nil }
10
+ let(:custom_helper) { nil }
11
11
  let(:opts) do
12
12
  {
13
13
  base_folder_path: test_base_path,
@@ -16,27 +16,27 @@ describe RenderingEngine::Content do
16
16
  }
17
17
  end
18
18
 
19
- subject { described_class.new(file_path, opts) }
19
+ subject { described_class.new(file_repo, file_path, opts) }
20
20
 
21
21
  context '#source' do
22
22
 
23
- before(:each) { subject.should_receive(:kind).and_return(kind) }
23
+ before(:each) { expect(subject).to receive(:kind).and_return(kind) }
24
24
 
25
25
  context 'when file is not found' do
26
26
  let(:kind) { :unknown }
27
27
 
28
28
  it 'returns empty string' do
29
- subject.source.should eq ''
29
+ expect(subject.source).to eq ''
30
30
  end
31
31
  end
32
32
 
33
33
  context 'when orginal file is found' do
34
34
  let(:kind) { :orginal }
35
35
  let(:source) { 'file_source' }
36
- before { File.should_receive(:read).with(file_path).and_return(source) }
36
+ before { expect(file_repo).to receive(:read).with(file_path).and_return(source) }
37
37
 
38
38
  it 'returns source of file' do
39
- subject.source.should eq source
39
+ expect(subject.source).to eq source
40
40
  end
41
41
  end
42
42
 
@@ -45,24 +45,30 @@ describe RenderingEngine::Content do
45
45
  let(:source) { 'calc 1+1=<%= 1+1 %>' }
46
46
  let(:rendered_source) { 'calc 1+1=2' }
47
47
  let(:erb_file_path) { "#{file_path}.erb" }
48
- before { File.should_receive(:read).with(erb_file_path).and_return(source) }
48
+ before do
49
+ expect(file_repo).to receive(:file_dirname)
50
+ .with(file_path)
51
+ .and_return(relative_path)
52
+ expect(file_repo).to receive(:read)
53
+ .with(erb_file_path)
54
+ .and_return(source)
55
+ end
49
56
 
50
57
  it 'returns rendered source' do
51
- subject.source.should eq rendered_source
58
+ expect(subject.source).to eq rendered_source
52
59
  end
53
60
 
54
61
  context 'erb result' do
55
- let(:erb_instance) { double('erb_instance') }
56
- let(:base_folder_path) { 'root/contract/files/login' }
62
+ let(:erb_instance) { double('erb_instance') }
57
63
  before do
58
- ERB.should_receive(:new).with(source).and_return(erb_instance)
59
- subject.should_receive(:helper).with(base_folder_path, content_data)
64
+ expect(ERB).to receive(:new).with(source).and_return(erb_instance)
65
+ expect(subject).to receive(:helper).with(relative_path, content_data)
60
66
  .and_return(double)
61
- erb_instance.should_receive(:result).with(an_instance_of(Binding))
67
+ expect(erb_instance).to receive(:result).with(an_instance_of(Binding))
62
68
  .and_return(rendered_source)
63
69
  end
64
70
  it 'receives helper' do
65
- subject.source.should eq rendered_source
71
+ expect(subject.source).to eq rendered_source
66
72
  end
67
73
  end
68
74
  end
@@ -70,53 +76,53 @@ describe RenderingEngine::Content do
70
76
 
71
77
  context '#kind' do
72
78
  context 'when orginal_file_present' do
73
- before { subject.should_receive(:orginal_file_present?).and_return(true) }
79
+ before { expect(subject).to receive(:orginal_file_present?).and_return(true) }
74
80
  it 'returns :orginal' do
75
- subject.kind.should eq :orginal
81
+ expect(subject.kind).to eq :orginal
76
82
  end
77
83
  end
78
84
 
79
85
  context 'when orginal_file_present is missing but template file is present' do
80
86
 
81
87
  before do
82
- subject.should_receive(:orginal_file_present?).and_return(false)
83
- subject.should_receive(:file_as_erb_present?).and_return(true)
88
+ expect(subject).to receive(:orginal_file_present?).and_return(false)
89
+ expect(subject).to receive(:file_as_erb_present?).and_return(true)
84
90
  end
85
91
 
86
92
  it 'returns :template' do
87
- subject.kind.should eq :template
93
+ expect(subject.kind).to eq :template
88
94
  end
89
95
  end
90
96
 
91
97
  context 'when orginal and template file is missing' do
92
98
 
93
99
  before do
94
- subject.should_receive(:orginal_file_present?).and_return(false)
95
- subject.should_receive(:file_as_erb_present?).and_return(false)
100
+ expect(subject).to receive(:orginal_file_present?).and_return(false)
101
+ expect(subject).to receive(:file_as_erb_present?).and_return(false)
96
102
  end
97
103
 
98
104
  it 'returns :unknown' do
99
- subject.kind.should eq :unknown
105
+ expect(subject.kind).to eq :unknown
100
106
  end
101
107
  end
102
108
  end
103
109
 
104
110
  %w{template orginal unknown}.each do |method_name|
105
111
  it "##{method_name}? returns true when content kind is :#{method_name}" do
106
- subject.should_receive(:kind).and_return(method_name.to_sym)
107
- subject.public_send("#{method_name}?").should be_true
112
+ expect(subject).to receive(:kind).and_return(method_name.to_sym)
113
+ expect(subject.public_send("#{method_name}?")).to eq true
108
114
  end
109
115
 
110
116
  it "##{method_name}? returns false when content kind is not :#{method_name}" do
111
- subject.should_receive(:kind).and_return(:bad)
112
- subject.public_send("#{method_name}?").should be_false
117
+ expect(subject).to receive(:kind).and_return(:bad)
118
+ expect(subject.public_send("#{method_name}?")).to eq false
113
119
  end
114
120
  end
115
121
 
116
122
  it '#base_folder_path' do
117
- subject.should_receive(:file_path).and_return(relative_path)
118
- subject.base_folder_path.should eq 'login'
123
+ expect(file_repo).to receive(:file_dirname)
124
+ .with(file_path)
125
+ .and_return(relative_path)
126
+ expect(subject.base_folder_path).to eq(relative_path)
119
127
  end
120
128
  end
121
-
122
-
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+
3
+ describe RenderingEngine::FileRepo do
4
+ let(:file_path) { 'some/file.erb' }
5
+ let(:base_path) { '/root/home/user' }
6
+ let(:full_path) { "#{base_path}/#{file_path}"}
7
+ subject { described_class.new(base_path) }
8
+
9
+ context '#exist?' do
10
+ it 'returns true when file exist' do
11
+ expect(File).to receive(:exist?).with(full_path).and_return(true)
12
+ expect(subject.exist?(file_path)).to eq(true)
13
+ end
14
+
15
+ it 'returns false when file missing' do
16
+ expect(File).to receive(:exist?).with(full_path).and_return(false)
17
+ expect(subject.exist?(file_path)).to eq(false)
18
+ end
19
+ end
20
+
21
+ context '#read' do
22
+ let(:file_source) { 'test_source' }
23
+
24
+ it 'get file source when file exist' do
25
+ expect(File).to receive(:read).with(full_path).and_return(file_source)
26
+ expect(subject.read(file_path)).to eq(file_source)
27
+ end
28
+
29
+ it 'raise error when file missing' do
30
+ expect(File).to receive(:read).with(full_path).and_raise(Exception)
31
+ expect {subject.read(file_path)}.to raise_error
32
+ end
33
+ end
34
+
35
+ it '#file_dirname returns dirname from file_path' do
36
+ expect(subject.file_dirname('/root/index.html')).to eq('/root')
37
+ end
38
+ end
@@ -1,19 +1,18 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe RenderingEngine::Provider do
4
- let(:base_path) { 'root/contract/files' }
5
- let(:relative_path) { 'login/form.html' }
6
- let(:file_path) { File.join(base_path, relative_path) }
4
+ let(:file_repo) { double('RenderingEngine::FileRepo') }
5
+ let(:file_path) { 'login/form.html' }
7
6
  let(:content) { double('ContentObject') }
8
7
  let(:data) { double('data') }
9
8
  let(:custom_helper) { double('custom_helper') }
10
- let(:opts) {{ data: data, custom_helper: custom_helper }}
11
- subject { described_class.new(base_path) }
9
+ let(:opts) { { data: data, custom_helper: custom_helper } }
10
+ subject { described_class.new(file_repo) }
12
11
 
13
12
  it '#get' do
14
- RenderingEngine::Content.should_receive(:new)
15
- .with(file_path, opts)
13
+ expect(RenderingEngine::Content).to receive(:new)
14
+ .with(file_repo, file_path, opts)
16
15
  .and_return(content)
17
- subject.get(relative_path, opts).should be content
16
+ expect(subject.get(file_path, opts)).to be content
18
17
  end
19
18
  end
@@ -1,22 +1,26 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # Require this file using `require "spec_helper"` to ensure that it is only
4
- # loaded once.
5
- #
6
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
-
8
1
  require File.expand_path(File.dirname(__FILE__) + '/../lib/rendering_engine')
9
2
  require 'rspec'
10
3
  require 'ostruct'
4
+ require 'coveralls'
5
+ Coveralls.wear!
11
6
 
12
7
  RSpec.configure do |config|
13
- config.treat_symbols_as_metadata_keys_with_true_values = true
14
- config.run_all_when_everything_filtered = true
15
8
  config.filter_run :focus
9
+ config.run_all_when_everything_filtered = true
10
+
11
+ config.default_formatter = 'doc' if config.files_to_run.one?
12
+
13
+ config.profile_examples = 10
14
+ config.order = :random
15
+
16
+ Kernel.srand config.seed
17
+
18
+ config.expect_with :rspec do |expectations|
19
+ expectations.syntax = :expect
20
+ end
16
21
 
17
- # Run specs in random order to surface order dependencies. If you find an
18
- # order dependency and want to debug it, you can fix the order by providing
19
- # the seed, which is printed after each run.
20
- # --seed 1234
21
- config.order = 'random'
22
+ config.mock_with :rspec do |mocks|
23
+ mocks.syntax = :expect
24
+ mocks.verify_partial_doubles = true
25
+ end
22
26
  end
metadata CHANGED
@@ -1,78 +1,110 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rendering_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Niemczyk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
46
74
  - !ruby/object:Gem::Version
47
75
  version: '0'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
- - - ! '>='
80
+ - - "~>"
53
81
  - !ruby/object:Gem::Version
54
82
  version: '0'
55
- description: ! ' Rendering engine based on ERB '
83
+ description: " Rendering engine based on ERB "
56
84
  email:
57
85
  - pniemczyk@o2.pl
58
86
  executables: []
59
87
  extensions: []
60
88
  extra_rdoc_files: []
61
89
  files:
62
- - .gitignore
63
- - .rspec
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
64
93
  - Gemfile
94
+ - Guardfile
65
95
  - LICENSE.txt
66
96
  - README.md
67
97
  - Rakefile
68
98
  - lib/rendering_engine.rb
69
99
  - lib/rendering_engine/content.rb
70
100
  - lib/rendering_engine/content_helpers.rb
101
+ - lib/rendering_engine/file_repo.rb
71
102
  - lib/rendering_engine/provider.rb
72
103
  - lib/rendering_engine/version.rb
73
104
  - rendering_engine.gemspec
74
105
  - spec/rendering_engine/content_helpers_spec.rb
75
106
  - spec/rendering_engine/content_spec.rb
107
+ - spec/rendering_engine/file_repo_spec.rb
76
108
  - spec/rendering_engine/provider_spec.rb
77
109
  - spec/spec_helper.rb
78
110
  homepage: https://github.com/pniemczyk/rendering_engine
@@ -85,22 +117,24 @@ require_paths:
85
117
  - lib
86
118
  required_ruby_version: !ruby/object:Gem::Requirement
87
119
  requirements:
88
- - - ! '>='
120
+ - - ">="
89
121
  - !ruby/object:Gem::Version
90
122
  version: '0'
91
123
  required_rubygems_version: !ruby/object:Gem::Requirement
92
124
  requirements:
93
- - - ! '>='
125
+ - - ">="
94
126
  - !ruby/object:Gem::Version
95
127
  version: '0'
96
128
  requirements: []
97
129
  rubyforge_project:
98
- rubygems_version: 2.1.10
130
+ rubygems_version: 2.2.2
99
131
  signing_key:
100
132
  specification_version: 4
101
133
  summary: Rendering engine based on ERB
102
134
  test_files:
103
135
  - spec/rendering_engine/content_helpers_spec.rb
104
136
  - spec/rendering_engine/content_spec.rb
137
+ - spec/rendering_engine/file_repo_spec.rb
105
138
  - spec/rendering_engine/provider_spec.rb
106
139
  - spec/spec_helper.rb
140
+ has_rdoc: