policy 1.1.0 → 1.2.0

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
  SHA1:
3
- metadata.gz: c43acc2f25d6b3056f4702697e77e317b6aca3e2
4
- data.tar.gz: b79816c8eb97f48bfab2e17269942b88bec0f3f2
3
+ metadata.gz: 11f8a87bec42ea9a04af224a56604ff2d690a8da
4
+ data.tar.gz: f8d9626c4298248ef86f91c7720afb8c26f976d0
5
5
  SHA512:
6
- metadata.gz: de03f24c1ef2c65f67e6ad2a1f10c62da9e9cb31e47fa4860ed4e38fa02b887777bea518a885cd5a5ddd447e5292990b422fb8740344f79a1d66f2bee82b8ce4
7
- data.tar.gz: 0903e3428ce0f25221340ff9f9ea7919f32f811204448da80cbd31f697e75b7f846e2116a4d2bc7be7a8d1759d9df0bc7de1b82216c52ca75d908677ee5a4544
6
+ metadata.gz: 4a76b932814bdbf8a70eb7e5ac55dc9ad1d82f93ae8c9d6151ebdceeeea0979e616c8f70637b7a777f50ee1e7ad30013f039d33fd5329665d0e128a06f8af8bd
7
+ data.tar.gz: 532d978cd83c62e7374d46a00f44c6c4034f9df1e3cccbe386d4f43a1cf60fc926580dc33996bd2892a2e4ca13accd265e256bfabf828c855ac7ad4472be8bb9
@@ -68,6 +68,10 @@ module Policy
68
68
 
69
69
  private
70
70
 
71
+ def project
72
+ @project ||= Hexx::CLI::Name.new ::File.basename(destination_root)
73
+ end
74
+
71
75
  def policy
72
76
  @policy ||= Hexx::CLI::Name.new [options[:namespace], name].join("/")
73
77
  end
@@ -6,7 +6,7 @@
6
6
  # activemodel:
7
7
  # errors:
8
8
  # models:
9
- # <%= policy.path %>:
9
+ # <%= project.path %>/<%= policy.path %>:
10
10
  # attributes:
11
11
  # base:
12
12
  <% attributes.each do |item| -%>
@@ -1,5 +1,13 @@
1
1
  # encoding: utf-8
2
2
  <% tabs = 0 -%>
3
+ <% project.namespaces.each do |item| -%>
4
+
5
+ <%= " " * tabs %>module <%= item %>
6
+ <% tabs += 1 -%>
7
+ <% end -%>
8
+
9
+ <%= " " * tabs %>module <%= project.const %>
10
+ <% tabs += 1 -%>
3
11
  <% policy.namespaces.each do |item| -%>
4
12
 
5
13
  <%= " " * tabs %>module <%= item %>
@@ -27,3 +35,11 @@
27
35
  <% tabs -= 1 -%>
28
36
  <%= " " * tabs %>end # module <%= item %>
29
37
  <% end -%>
38
+
39
+ <% tabs -= 1 -%>
40
+ <%= " " * tabs %>end # module <%= project.const %>
41
+ <% project.namespaces.reverse.each do |item| -%>
42
+
43
+ <% tabs -= 1 -%>
44
+ <%= " " * tabs %>end # module <%= item %>
45
+ <% end -%>
@@ -1,6 +1,6 @@
1
1
  # encoding: utf-8
2
2
 
3
- describe <%= policy.type %> do
3
+ describe <%= project.type %>::<%= policy.type %> do
4
4
 
5
5
  # The specification checks whether the policy object is valid or not,
6
6
  # depending on values of its attributes.
@@ -4,6 +4,6 @@ module Policy
4
4
 
5
5
  # The semantic version of the module.
6
6
  # @see http://semver.org/ Semantic versioning 2.0
7
- VERSION = "1.1.0".freeze
7
+ VERSION = "1.2.0".freeze
8
8
 
9
9
  end # module Hexx
@@ -7,7 +7,7 @@ describe Policy::CLI, :sandbox, :capture do
7
7
 
8
8
  subject { try_in_sandbox { described_class.start options } }
9
9
 
10
- shared_examples "adding a policy" do |folder:|
10
+ shared_examples "adding a policy" do |folder: nil|
11
11
 
12
12
  let(:filename) { File.join("app", folder, "foo.rb") }
13
13
 
@@ -17,7 +17,7 @@ describe Policy::CLI, :sandbox, :capture do
17
17
 
18
18
  end # examples
19
19
 
20
- shared_examples "adding a spec" do |folder:|
20
+ shared_examples "adding a spec" do |folder: nil|
21
21
 
22
22
  let(:filename) { File.join("spec/tests", folder, "foo_spec.rb") }
23
23
 
@@ -27,7 +27,7 @@ describe Policy::CLI, :sandbox, :capture do
27
27
 
28
28
  end # examples
29
29
 
30
- shared_examples "adding locales" do |locales, folder:|
30
+ shared_examples "adding locales" do |locales, folder: nil|
31
31
 
32
32
  let(:dirname) { File.join("config/locales", folder, "foo") }
33
33
 
@@ -83,19 +83,20 @@ describe Policy::CLI, :sandbox, :capture do
83
83
 
84
84
  it "adds namespace to the policy" do
85
85
  content = read_in_sandbox "app/bar/baz/foo.rb"
86
- expect(content).to include "module Bar"
87
- expect(content).to include " module Baz"
86
+ expect(content).to include "module Sandbox"
87
+ expect(content).to include " module Bar"
88
+ expect(content).to include " module Baz"
88
89
  end
89
90
 
90
91
  it "describes the specification" do
91
92
  content = read_in_sandbox "spec/tests/bar/baz/foo_spec.rb"
92
- expect(content).to include "describe Bar::Baz::Foo do"
93
+ expect(content).to include "describe Sandbox::Bar::Baz::Foo do"
93
94
  end
94
95
 
95
96
  it "creates the proper locale" do
96
97
  content = read_in_sandbox "config/locales/bar/baz/foo/en.yml"
97
98
  expect(content).to include "# en:"
98
- expect(content).to include " bar/baz/foo:"
99
+ expect(content).to include " sandbox/bar/baz/foo:"
99
100
  end
100
101
 
101
102
  end # context
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: policy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kozin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-17 00:00:00.000000000 Z
11
+ date: 2015-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel