adyen-admin 0.0.11 → 0.0.12

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -6,11 +6,12 @@
6
6
  * add CLI binaries (to compile + upload) -> read from .adyenrc file
7
7
  * make compatible with Live system
8
8
 
9
- ## v0.0.11 - 23-04-2012
9
+ ## v0.0.12 - 23-04-2012
10
10
  * renamed `compile` to `compress`
11
11
  * added `compile` which splits any given input to the inc/* file according to given pattern
12
12
  * parse metafile
13
13
  * log out on AuthError
14
+ * cache all skins, only load remote when authorized
14
15
 
15
16
  ## v0.0.7
16
17
  * fix download issue
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.0.12
@@ -21,7 +21,7 @@ module Adyen
21
21
  send("#{key}=", value)
22
22
  end
23
23
 
24
- self.path ||= File.join(Skin.default_path, [name,code].compact.join("-"))
24
+ self.path ||= File.expand_path File.join(Skin.default_path, [name,code].compact.join("-"))
25
25
 
26
26
  raise ArgumentError, "No Code given" unless code
27
27
  end
@@ -36,12 +36,14 @@ module Adyen
36
36
 
37
37
  # union remote and local skins. Local skins are frozen to
38
38
  # indicate no availble remote counter part which avoid update
39
- def self.all(path = Skin.default_path)
40
- {}.tap do |hash|
41
- self.all_remote.each do |skin|
42
- hash[skin.code] = skin unless hash[skin.code]
39
+ def self.all
40
+ @all ||= {}.tap do |hash|
41
+ if Adyen::Admin.authenticated?
42
+ self.all_remote.each do |skin|
43
+ hash[skin.code] = skin unless hash[skin.code]
44
+ end
43
45
  end
44
- self.all_local(path).each do |skin|
46
+ self.all_local.each do |skin|
45
47
  hash[skin.code] = skin unless hash[skin.code]
46
48
  end
47
49
  end.values
@@ -49,20 +51,18 @@ module Adyen
49
51
 
50
52
  # fetch all remote skins
51
53
  def self.all_remote
52
- @skins_remote ||= begin
53
- page = Adyen::Admin.get(SKINS)
54
- page.search(".data tbody tr").map do |node|
55
- Skin.new({
56
- :code => node.search("a")[0].content.strip,
57
- :name => node.search("td")[1].content.strip,
58
- })
59
- end
54
+ page = Adyen::Admin.get(SKINS)
55
+ page.search(".data tbody tr").map do |node|
56
+ Skin.new({
57
+ :code => node.search("a")[0].content.strip,
58
+ :name => node.search("td")[1].content.strip,
59
+ })
60
60
  end
61
61
  end
62
62
 
63
63
  # fetch all local skins
64
- def self.all_local(path = Skin.default_path)
65
- Dir[File.join(path.to_s, "*")].map do |path|
64
+ def self.all_local
65
+ Dir[File.join(default_path.to_s, "*")].map do |path|
66
66
  Skin.new(:path => path).freeze rescue nil
67
67
  end.compact
68
68
  end
@@ -75,7 +75,7 @@ module Adyen
75
75
  end
76
76
 
77
77
  def self.purge_cache
78
- @skins_remote = nil
78
+ @all = nil
79
79
  end
80
80
 
81
81
  ##################################
@@ -31,9 +31,11 @@ describe Adyen::Admin::Client, :vcr do
31
31
  end
32
32
 
33
33
  it 'sets authenticated to false on error' do
34
+ Adyen::Admin.instance_variable_set(:@authenticated, true)
35
+
34
36
  expect do
35
37
  Adyen::Admin.get(Adyen::Admin::Skin::SKINS) rescue nil
36
- end.to change { Adyen::Admin.authenticated? }.from(nil).to(false)
38
+ end.to change { Adyen::Admin.authenticated? }.from(true).to(false)
37
39
  end
38
40
  end
39
41
  end
@@ -5,10 +5,16 @@ require "adyen-admin/skin"
5
5
 
6
6
  module Adyen::Admin
7
7
  describe Skin, :vcr do
8
- let(:skin_fixtures) { 'spec/fixtures/skins' }
8
+ let(:skin_fixtures) { File.expand_path 'spec/fixtures/skins' }
9
9
  let(:skin_code) { "7hFAQnmt" }
10
10
  let(:skin) { Skin.new(:code => skin_code, :name => "example") }
11
11
 
12
+ describe ".all" do
13
+ it 'returns all local skins' do
14
+ Skin.all.should == Skin.all_local
15
+ end
16
+ end
17
+
12
18
  context "authenticated" do
13
19
  before(:all) do
14
20
  VCR.use_cassette("login") do
@@ -38,7 +44,7 @@ module Adyen::Admin
38
44
 
39
45
  describe ".all_local" do
40
46
  it 'returns the skins' do
41
- Skin.all_local(skin_fixtures).should == [
47
+ Skin.all_local.should == [
42
48
  Skin.new(:code => "base"),
43
49
  Skin.new(:code => "DV3tf95f"),
44
50
  skin,
@@ -49,7 +55,7 @@ module Adyen::Admin
49
55
 
50
56
  describe ".all" do
51
57
  it 'returns the skins' do
52
- Skin.all(skin_fixtures).should == [
58
+ Skin.all.should == [
53
59
  skin,
54
60
  Skin.new(:code => "Kx9axnRf", :name => "demo"),
55
61
  Skin.new(:code => "vQW0fEo8", :name => "test"),
@@ -60,11 +66,10 @@ module Adyen::Admin
60
66
  end
61
67
 
62
68
  it 'freezes local skins' do
63
- Skin.all(skin_fixtures).last.should be_frozen
69
+ Skin.all.last.should be_frozen
64
70
  end
65
71
  end
66
72
 
67
-
68
73
  describe ".find" do
69
74
  it 'returns the skin' do
70
75
  Skin.find(skin_code).should == skin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adyen-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize
16
- requirement: &70115439116500 !ruby/object:Gem::Requirement
16
+ requirement: &70207780752880 !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: :runtime
23
23
  prerelease: false
24
- version_requirements: *70115439116500
24
+ version_requirements: *70207780752880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rubyzip
27
- requirement: &70115439116020 !ruby/object:Gem::Requirement
27
+ requirement: &70207780752400 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70115439116020
35
+ version_requirements: *70207780752400
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70115439115440 !ruby/object:Gem::Requirement
38
+ requirement: &70207780751820 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70115439115440
46
+ version_requirements: *70207780751820
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &70115439114980 !ruby/object:Gem::Requirement
49
+ requirement: &70207780751360 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70115439114980
57
+ version_requirements: *70207780751360
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: vcr
60
- requirement: &70115439114520 !ruby/object:Gem::Requirement
60
+ requirement: &70207780750900 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70115439114520
68
+ version_requirements: *70207780750900
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
- requirement: &70115439114060 !ruby/object:Gem::Requirement
71
+ requirement: &70207780750440 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70115439114060
79
+ version_requirements: *70207780750440
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: debugger
82
- requirement: &70115439113600 !ruby/object:Gem::Requirement
82
+ requirement: &70207780749980 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70115439113600
90
+ version_requirements: *70207780749980
91
91
  description: A little Gem to make your life easier when dealing with Adyen skins
92
92
  email:
93
93
  - tobi@soundcloud.com