acts_as_authoritah 2.0.3 → 2.0.4

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.
data/Gemfile CHANGED
@@ -2,5 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in acts_as_authoritah.gemspec
4
4
  gemspec
5
- gem 'spreadsheet'
6
5
 
@@ -5,7 +5,7 @@ class ActsAsAuthoritah::AclLoader
5
5
  @path = path
6
6
  @files = []
7
7
  @contexts = []
8
- Dir.glob(File.join(@path,"*.xls")).each{ |x|
8
+ Dir.glob(File.join(@path,"*.csv")).each{ |x|
9
9
  @files << x
10
10
  @contexts << File.split(x).last.split('.').first
11
11
  }
@@ -1,8 +1,7 @@
1
1
  class ActsAsAuthoritah::SpreadsheetReader
2
2
  def initialize(path)
3
3
  if File.exists?(path)
4
- @book = Spreadsheet.open path
5
- @sheet = @book.worksheets.first
4
+ @sheet = CSV.parse open(path).read.strip
6
5
  else
7
6
  @error = "File not found"
8
7
  end
@@ -1,3 +1,3 @@
1
1
  module ActsAsAuthoritah
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
@@ -13,8 +13,7 @@ require "acts_as_authoritah/acl_loader"
13
13
  require "acts_as_authoritah/identifier_parser"
14
14
  require "acts_as_authoritah/errors.rb"
15
15
 
16
- require 'spreadsheet'
17
- Spreadsheet.client_encoding = 'UTF-8'
16
+ require 'csv'
18
17
 
19
18
  require "acts_as_authoritah/spreadsheets/access_rights_mapper"
20
19
  require "acts_as_authoritah/spreadsheets/spreadsheet_wrapper"
@@ -2,20 +2,20 @@ require 'spec_helper'
2
2
 
3
3
  describe ActsAsAuthoritah::SpreadsheetReader do
4
4
  it "should be able to open a spreadsheet give a valid path" do
5
- ActsAsAuthoritah::SpreadsheetReader.new("spec/data/default.xls").valid?.should eq true
5
+ ActsAsAuthoritah::SpreadsheetReader.new("spec/data/default.csv").valid?.should eq true
6
6
  end
7
7
 
8
8
  it "should be invalid if file not found" do
9
- ActsAsAuthoritah::SpreadsheetReader.new("spec/data/no_such_file.xls").valid?.should eq false
9
+ ActsAsAuthoritah::SpreadsheetReader.new("spec/data/no_such_file.csv").valid?.should eq false
10
10
  end
11
11
 
12
12
  it "should return all valid rows (skip first row and other empty rows)" do
13
- reader = ActsAsAuthoritah::SpreadsheetReader.new("spec/data/default.xls")
13
+ reader = ActsAsAuthoritah::SpreadsheetReader.new("spec/data/default.csv")
14
14
  reader.valid_rows.count.should eq 2
15
15
  end
16
16
 
17
17
  it "should returns rows in the expected format" do
18
- reader = ActsAsAuthoritah::SpreadsheetReader.new("spec/data/default.xls")
18
+ reader = ActsAsAuthoritah::SpreadsheetReader.new("spec/data/default.csv")
19
19
  reader.valid_rows.should eq [
20
20
  ["scope1::scope2", "Dummy", "edit", "test", "x", nil, "x"],
21
21
  ["scope3::scope4", "Another", "update", "test", nil, "x", "x"]
@@ -23,7 +23,7 @@ describe ActsAsAuthoritah::SpreadsheetReader do
23
23
  end
24
24
 
25
25
  it "should return the header row" do
26
- reader = ActsAsAuthoritah::SpreadsheetReader.new("spec/data/default.xls")
26
+ reader = ActsAsAuthoritah::SpreadsheetReader.new("spec/data/default.csv")
27
27
  reader.header.should eq ["scope", "controller", "action", "description", "admin", "anonymous", "super_admin"]
28
28
  end
29
29
  end
@@ -2,11 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe ActsAsAuthoritah::SpreadsheetWrapper do
4
4
  it "should be able to open a spreadsheet and convert to an array of AccessRules" do
5
- ActsAsAuthoritah::SpreadsheetWrapper.new("spec/data/default.xls").to_access_rules.first.class.should eq ActsAsAuthoritah::AccessRule
5
+ ActsAsAuthoritah::SpreadsheetWrapper.new("spec/data/default.csv").to_access_rules.first.class.should eq ActsAsAuthoritah::AccessRule
6
6
  end
7
7
 
8
8
  it "should load the spreadsheet to ACL correctly" do
9
- access_rules = ActsAsAuthoritah::SpreadsheetWrapper.new("spec/data/default.xls").to_access_rules
9
+ access_rules = ActsAsAuthoritah::SpreadsheetWrapper.new("spec/data/default.csv").to_access_rules
10
10
  ActsAsAuthoritah::AccessControlList.new(access_rules).store.should eq({
11
11
  "scope1::scope2::DummyController#edit"=>{"admin"=>true, "anonymous"=>false, "super_admin"=>true},
12
12
  "scope3::scope4::AnotherController#update"=>{"admin"=>false, "anonymous"=>true, "super_admin"=>true}
@@ -0,0 +1 @@
1
+ scope,controller,action,description,admin,anonymous,super_admin
@@ -0,0 +1 @@
1
+ scope,controller,action,description,admin,anonymous,super_admin
@@ -0,0 +1 @@
1
+ scope,controller,action,description,admin,anonymous,super_admin,,,,,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_authoritah
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-16 00:00:00.000000000 Z
12
+ date: 2012-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2152579320 !ruby/object:Gem::Requirement
16
+ requirement: &2156287840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2152579320
24
+ version_requirements: *2156287840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &2152578820 !ruby/object:Gem::Requirement
27
+ requirement: &2156287200 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2152578820
35
+ version_requirements: *2156287200
36
36
  description: Define user capabilities in your app
37
37
  email:
38
38
  - unni.tallman@gmail.com
@@ -77,9 +77,9 @@ files:
77
77
  - spec/acts_as_authoritah/spreadsheets/spreadsheet_reader_spec.rb
78
78
  - spec/acts_as_authoritah/spreadsheets/spreadsheet_row_parser_spec.rb
79
79
  - spec/acts_as_authoritah/spreadsheets/spreadsheet_wrapper_spec.rb
80
- - spec/data/archived.xls
81
- - spec/data/default.xls
82
- - spec/data/unpublished.xls
80
+ - spec/data/archived.csv
81
+ - spec/data/default.csv
82
+ - spec/data/unpublished.csv
83
83
  - spec/spec_helper.rb
84
84
  homepage: ''
85
85
  licenses: []
@@ -119,7 +119,7 @@ test_files:
119
119
  - spec/acts_as_authoritah/spreadsheets/spreadsheet_reader_spec.rb
120
120
  - spec/acts_as_authoritah/spreadsheets/spreadsheet_row_parser_spec.rb
121
121
  - spec/acts_as_authoritah/spreadsheets/spreadsheet_wrapper_spec.rb
122
- - spec/data/archived.xls
123
- - spec/data/default.xls
124
- - spec/data/unpublished.xls
122
+ - spec/data/archived.csv
123
+ - spec/data/default.csv
124
+ - spec/data/unpublished.csv
125
125
  - spec/spec_helper.rb
Binary file
Binary file
Binary file