firebrew 0.1.0 → 0.1.1

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: ee0908cafa9dc7f91a605e060ed0e023b63cb9a4
4
- data.tar.gz: 88e3a156dfba8e25ed0f3dab12e6a6418a6a5f93
3
+ metadata.gz: 5a542b1a8f741b5c1e6def0a8086d9c79d68f67e
4
+ data.tar.gz: a029dfe002d81c711026d3ea9df4fbe2f2d9fe0c
5
5
  SHA512:
6
- metadata.gz: 9258b7043880fe71cf3259f7b4d065694e8936d3a69f88bf63705d2d98cd77223dfdbeb3ca0de5bca35768e605c9e6d0e7562494818d06eab1247839eddb95d3
7
- data.tar.gz: 5b7b4e143d90517b87eeb16938b51171356970b91d105f8be5d5f62874ae8caf118c9f7a8cf3dfccf1b841b2f5401669ae67631535617f9610858940a5661e12
6
+ metadata.gz: c46210782bdf747211f0f9a18c86ea35dcacd99d831ead9817dfcb8870f0598aa41894a5a4d9c5f1778cb743b484a249b019d586bd82a6ce4698bea436a2155a
7
+ data.tar.gz: 59ad9eef3e13be8c5f4f21926374464d2f7ad0b34c5e02e73dd42f409d0487f457fcc64c777f2560a85a42e8740b3fd76bcbb44a0ea591cf8770d22d96a7e392
data/README.md CHANGED
@@ -16,6 +16,9 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install firebrew
18
18
 
19
+
20
+ _NOTE: This program execution requires the OpenSSL._
21
+
19
22
  ## Usage
20
23
 
21
24
  The structure of the command line is shown below:
@@ -80,11 +83,11 @@ The Firefox profiles.ini directory:
80
83
 
81
84
  The default value is listed below:
82
85
 
83
- | platform | path |
84
- | -------- | ---- |
85
- | Mac OS X | ~/Library/Application Support/Firefox |
86
- | Linux | ~/.mozilla/firefox |
87
- | Windows 7 x86\_64 | %UserProfile%\AppData\Roming\Mozilla\Firefox |
86
+ | platform | value |
87
+ | -------- | ----- |
88
+ | Mac OS X | `~/Library/Application Support/Firefox` |
89
+ | Linux | `~/.mozilla/firefox` |
90
+ | Windows | `%APPDATA%\Mozilla\Firefox` |
88
91
 
89
92
  It's able to overridden by the `FIREBREW_FIREFOX_PROFILE_BASE_DIR` environment variable.
90
93
 
@@ -108,11 +111,11 @@ The Firefox command path:
108
111
 
109
112
  The default value is listed below:
110
113
 
111
- | platform | path |
112
- | -------- | ---- |
113
- | Mac OS X | /Applications/Firefox.app/Contents/MacOS/firefox-bin |
114
- | Linux | /usr/bin/firefox |
115
- | Windows 7 x86\_64 | C:\Program Files (x86)\Mozilla Firefox\firefox.exe |
114
+ | platform | value |
115
+ | -------- | ----- |
116
+ | Mac OS X | `/Applications/Firefox.app/Contents/MacOS/firefox-bin` |
117
+ | Linux | `/usr/bin/firefox` |
118
+ | Windows | `%PROGRAMFILES%\Mozilla Firefox\firefox.exe` or `%PROGRAMFILES(X86)%\Mozilla Firefox\firefox.exe` |
116
119
 
117
120
  It's able to overridden by the `FIREBREW_FIREFOX` environment variable.
118
121
 
@@ -4,11 +4,10 @@ module Firebrew
4
4
  class Error < StandardError; def status; 1 end end
5
5
  class ProfilesFileNotFoundError < Error; def status; 2 end end
6
6
  class ProfileNotFoundError < Error; def status; 3 end end
7
- class ExtensionsFileNotFoundError < Error; def status; 4 end end
8
- class ExtensionNotFoundError < Error; def status; 5 end end
9
- class FirefoxCommandError < Error; def status; 6 end end
10
- class CommandLineError < Error; def status; 7 end end
11
- class OperationAlreadyCompletedError < Error; def status; 8 end end
7
+ class ExtensionNotFoundError < Error; def status; 4 end end
8
+ class FirefoxCommandError < Error; def status; 5 end end
9
+ class CommandLineError < Error; def status; 6 end end
10
+ class OperationAlreadyCompletedError < Error; def status; 7 end end
12
11
  end
13
12
 
14
13
  require 'firebrew/entity'
@@ -10,7 +10,7 @@ module Firebrew::Firefox
10
10
  @config = config
11
11
  @executer = executer
12
12
  begin
13
- result = @executer.exec('%{firefox} --version' % @config)
13
+ result = @executer.exec('"%{firefox}" --version' % @config)
14
14
  raise Firebrew::FirefoxCommandError unless result[0] =~ /Mozilla Firefox/
15
15
  raise Firebrew::FirefoxCommandError unless result[1] == 0
16
16
  rescue SystemCallError
@@ -20,7 +20,7 @@ module Firebrew::Firefox
20
20
 
21
21
  def version
22
22
  return @version if @version.present?
23
- result = @executer.exec('%{firefox} --version' % @config)[0]
23
+ result = @executer.exec('"%{firefox}" --version' % @config)[0]
24
24
  @version = result.match(/[0-9.]+/)[0]
25
25
  end
26
26
  end
@@ -62,7 +62,9 @@ module Firebrew::Firefox
62
62
 
63
63
  def data_path
64
64
  path = File.join(self.profile.path, 'extensions.json')
65
- raise Firebrew::ExtensionsFileNotFoundError unless File.exists? path
65
+ unless File.exists?(path) then
66
+ File.write(path, %({"schemaVersion": 16, "addons": []}))
67
+ end
66
68
  path
67
69
  end
68
70
 
@@ -23,8 +23,10 @@ module Firebrew
23
23
  result[:firefox] ||= '/usr/bin/firefox'
24
24
 
25
25
  when /mswin(?!ce)|mingw|cygwin|bccwin/ then
26
- result[:base_dir] ||= '~/AppData/Roming/Mozilla/Firefox'
27
- result[:firefox] ||= 'C:/Program Files (x86)/Mozilla Firefox/firefox.exe'
26
+ appdata = ENV['APPDATA'].to_s.gsub('\\','/')
27
+ programfiles = (ENV['PROGRAMFILES(X86)'] || ENV['PROGRAMFILES']).to_s.gsub('\\','/')
28
+ result[:base_dir] ||= File.join(appdata, 'Mozilla/Firefox')
29
+ result[:firefox] ||= File.join(programfiles, 'Mozilla Firefox/firefox.exe')
28
30
  end
29
31
 
30
32
  result
@@ -1,3 +1,3 @@
1
1
  module Firebrew
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -0,0 +1,2 @@
1
+ @echo off
2
+ ruby ./spec/double/firefox.rb
@@ -130,7 +130,7 @@ module Firebrew
130
130
 
131
131
  context 'when the `Firebrew::Error` was thrown' do
132
132
  let(:exeption){raise Firebrew::CommandLineError, 'CommandLineError message'}
133
- it { expect(subject[0]).to eq(7) }
133
+ it { expect(subject[0]).to eq(6) }
134
134
  it { expect(subject[1]).to eq('CommandLineError message') }
135
135
  end
136
136
 
@@ -46,8 +46,14 @@ module Firebrew::Firefox
46
46
  end
47
47
 
48
48
  context 'when not existed `extension.json`' do
49
- before {FileUtils.rm_f './tmp/extensions.json'}
50
- it { expect{subject}.to raise_error(Firebrew::ExtensionsFileNotFoundError) }
49
+ before do
50
+ FileUtils.rm_f './tmp/extensions.json'
51
+ subject
52
+ end
53
+
54
+ it 'should create that' do
55
+ expect(File.exists? './tmp/extensions.json').to be_truthy
56
+ end
51
57
  end
52
58
  end
53
59
 
@@ -33,7 +33,7 @@ module Firebrew::Firefox
33
33
  expect(subject[1].is_default).to be_falsey
34
34
 
35
35
  expect(subject[2].name).to eq('abs_profile')
36
- expect(subject[2].path).to eq('/path/to/abs_profile')
36
+ expect(subject[2].path).to eq(File.expand_path('/path/to/abs_profile'))
37
37
  expect(subject[2].is_default).to be_falsey
38
38
  end
39
39
 
@@ -15,6 +15,12 @@ module Firebrew
15
15
  ENV['FIREBREW_FIREFOX'] = nil
16
16
  end
17
17
 
18
+ after do
19
+ ENV['FIREBREW_FIREFOX_PROFILE_BASE_DIR'] = nil
20
+ ENV['FIREBREW_FIREFOX_PROFILE'] = nil
21
+ ENV['FIREBREW_FIREFOX'] = nil
22
+ end
23
+
18
24
  context 'when the `platform` was "MacOS"' do
19
25
  let(:platform){'x86_64-darwin13.0'}
20
26
  it do
@@ -37,14 +43,71 @@ module Firebrew
37
43
  end
38
44
  end
39
45
 
40
- context 'when the `platform` was "Windows 7 x86_64"' do
46
+ context 'when the `platform` was "Windows"' do
41
47
  let(:platform){'x64-mingw32'}
42
- it do
43
- is_expected.to eq(
44
- base_dir: '~/AppData/Roming/Mozilla/Firefox',
45
- firefox: 'C:/Program Files (x86)/Mozilla Firefox/firefox.exe',
46
- profile: 'default'
47
- )
48
+
49
+ before do
50
+ ENV['APPDATA'] = nil
51
+ ENV['PROGRAMFILES'] = nil
52
+ ENV['PROGRAMFILES(X86)'] = nil
53
+ end
54
+
55
+ after do
56
+ ENV['APPDATA'] = nil
57
+ ENV['PROGRAMFILES'] = nil
58
+ ENV['PROGRAMFILES(X86)'] = nil
59
+ end
60
+
61
+ context 'when the ruby architecture was "x86"' do
62
+ context 'when the `platform` was "Windows 7 x86_64"' do
63
+ before do
64
+ ENV['APPDATA'] = 'C:\Users\admin\AppData\Roaming'
65
+ ENV['PROGRAMFILES'] = 'C:\Program Files (x86)'
66
+ ENV['PROGRAMFILES(X86)'] = 'C:\Program Files (x86)'
67
+ end
68
+
69
+ it do
70
+ is_expected.to eq(
71
+ base_dir: 'C:/Users/admin/AppData/Roaming/Mozilla/Firefox',
72
+ firefox: 'C:/Program Files (x86)/Mozilla Firefox/firefox.exe',
73
+ profile: 'default'
74
+ )
75
+ end
76
+ end
77
+
78
+ context 'when the `platform` was "Windows XP x86"' do
79
+ before do
80
+ ENV['APPDATA'] = 'C:\Documents and Settings\Administrator\Application Data'
81
+ ENV['PROGRAMFILES'] = 'C:\Program Files'
82
+ ENV['PROGRAMFILES(X86)'] = nil
83
+ end
84
+
85
+ it do
86
+ is_expected.to eq(
87
+ base_dir: 'C:/Documents and Settings/Administrator/Application Data/Mozilla/Firefox',
88
+ firefox: 'C:/Program Files/Mozilla Firefox/firefox.exe',
89
+ profile: 'default'
90
+ )
91
+ end
92
+ end
93
+ end
94
+
95
+ context 'when the ruby architecture was "X86_64"' do
96
+ context 'when the `platform` was "Windows 7 x86_64"' do
97
+ before do
98
+ ENV['APPDATA'] = 'C:\Users\admin\AppData\Roaming'
99
+ ENV['PROGRAMFILES'] = 'C:\Program Files'
100
+ ENV['PROGRAMFILES(X86)'] = 'C:\Program Files (x86)'
101
+ end
102
+
103
+ it do
104
+ is_expected.to eq(
105
+ base_dir: 'C:/Users/admin/AppData/Roaming/Mozilla/Firefox',
106
+ firefox: 'C:/Program Files (x86)/Mozilla Firefox/firefox.exe',
107
+ profile: 'default'
108
+ )
109
+ end
110
+ end
48
111
  end
49
112
  end
50
113
 
@@ -55,12 +118,6 @@ module Firebrew
55
118
  ENV['FIREBREW_FIREFOX'] = 'path/to/firefox'
56
119
  end
57
120
 
58
- after do
59
- ENV['FIREBREW_FIREFOX_PROFILE_BASE_DIR'] = nil
60
- ENV['FIREBREW_FIREFOX_PROFILE'] = nil
61
- ENV['FIREBREW_FIREFOX'] = nil
62
- end
63
-
64
121
  it do
65
122
  is_expected.to eq(
66
123
  base_dir: 'path/to/profile_base_directory',
@@ -78,7 +135,7 @@ module Firebrew
78
135
  Runner.new(
79
136
  base_dir: './tmp',
80
137
  data_file: 'profiles.ini',
81
- firefox: './spec/double/firefox.rb'
138
+ firefox: ENV['OS'].nil? ? './spec/double/firefox.rb' : './spec/double/firefox.bat'
82
139
  )
83
140
  end
84
141
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: firebrew
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuichi Murata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-14 00:00:00.000000000 Z
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -135,6 +135,7 @@ files:
135
135
  - lib/firebrew/firefox/profile.rb
136
136
  - lib/firebrew/runner.rb
137
137
  - lib/firebrew/version.rb
138
+ - spec/double/firefox.bat
138
139
  - spec/double/firefox.rb
139
140
  - spec/firebrew/amo_api/search_spec.rb
140
141
  - spec/firebrew/command_line_spec.rb
@@ -177,6 +178,7 @@ signing_key:
177
178
  specification_version: 4
178
179
  summary: Firefox add-ons manager for CUI.
179
180
  test_files:
181
+ - spec/double/firefox.bat
180
182
  - spec/double/firefox.rb
181
183
  - spec/firebrew/amo_api/search_spec.rb
182
184
  - spec/firebrew/command_line_spec.rb