local_pac 0.1.6 → 0.1.7

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/.rdebugrc ADDED
@@ -0,0 +1,7 @@
1
+ set listsize 30
2
+ set history save on
3
+ set history size 99999
4
+ set history filename ~/.rdebug_history
5
+ set autolist
6
+ set autoeval
7
+ set autoreload
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format Fuubar
2
+ --order rand
3
+ --color
data/.simplecov ADDED
@@ -0,0 +1,8 @@
1
+ SimpleCov.start do
2
+ add_filter "/features/"
3
+ add_filter "/spec/"
4
+ add_filter "/tmp"
5
+ add_filter "/vendor"
6
+
7
+ add_group "lib", "lib"
8
+ end
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ bundler_args: --without development
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.0
7
+ script: bundle exec rake test:coveralls
data/.yardopts ADDED
@@ -0,0 +1,5 @@
1
+ -o doc/yard
2
+ --verbose
3
+ -
4
+ LICENSE.md
5
+ README.md
@@ -1,5 +1,6 @@
1
1
  # encoding: utf-8
2
2
  module LocalPac
3
+
3
4
  class Config
4
5
  private
5
6
 
@@ -12,9 +13,7 @@ module LocalPac
12
13
 
13
14
  def option(option, default_value)
14
15
  define_method option.to_sym do
15
- config.transaction do
16
- config.fetch(option.to_sym, default_value)
17
- end
16
+ config.fetch(option.to_sym, default_value)
18
17
  end
19
18
 
20
19
  @options << option
@@ -23,8 +22,19 @@ module LocalPac
23
22
 
24
23
  public
25
24
 
26
- def initialize(file = available_config_file, config_engine = YAML::Store)
27
- @config = config_engine.new(file)
25
+ def initialize(file = available_config_file, config_engine = Psych)
26
+ config_mutex = Mutex.new
27
+ config_mutex.synchronize do
28
+ yaml = Psych.load_file(file)
29
+
30
+ if yaml.respond_to? :[]
31
+ @config = yaml.freeze
32
+ else
33
+ @config = {}.freeze
34
+ end
35
+ end
36
+ rescue => e
37
+ fail Exceptions::ConfigFileNotReadable, "Sorry, but there was a problem reading the config file: #{e.message}."
28
38
  end
29
39
 
30
40
  option :log_sink, File.join(ENV['HOME'], '.local', 'share', 'local_pac', 'log')
@@ -5,5 +5,8 @@ module LocalPac
5
5
 
6
6
  # raised if Template does not exist
7
7
  class ErbTemplateIsUnknown < Exception; end
8
+
9
+ # raised if Template does not exist
10
+ class ConfigFileNotReadable < Exception; end
8
11
  end
9
12
  end
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
  module LocalPac
3
-
4
3
  @config_semaphore = Mutex.new
5
4
  @logger_semaphore = Mutex.new
6
5
 
@@ -1,4 +1,4 @@
1
1
  #main LocalPac
2
2
  module LocalPac
3
- VERSION = '0.1.6'
3
+ VERSION = '0.1.7'
4
4
  end
data/lib/local_pac.rb CHANGED
@@ -3,7 +3,8 @@ require 'fileutils'
3
3
  require 'logger'
4
4
  require 'uglifier'
5
5
  require 'pac'
6
- require 'yaml/store'
6
+ require 'ostruct'
7
+ require 'psych'
7
8
  require 'erb'
8
9
  require 'thread'
9
10
  require 'open3'
@@ -0,0 +1,5 @@
1
+ .PHONY: clean
2
+ clean:
3
+ rm -f *.src.tar.gz
4
+ rm -f *.pkg.tar.xz
5
+ rm -f *.gem
@@ -10,7 +10,7 @@ depends=(ruby)
10
10
  makedepends=(rubygems filegen)
11
11
  source=(http://gems.rubyforge.org/gems/$pkgname-$pkgver.gem)
12
12
  noextract=($pkgname-$pkgver.gem)
13
- sha256sums=('66a8c53ab984ee3d3bedafeefc195e0c43d33a23da204f1987624ee67c2fb9f6')
13
+ sha256sums=('1141ef7b1eafd1b67fe210ae3dde9d72b397b48842ae6b3f377a093af56a9094')
14
14
 
15
15
  package() {
16
16
  cd "$srcdir"
data/spec/config_spec.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe LocalPac::Config do
5
- let(:config_file) { File.join(working_directory, 'config.yaml') }
5
+ let(:config_file) { create_file('config_.yaml') }
6
6
 
7
7
  context '#initialize' do
8
8
  it 'requires a file name' do
@@ -9,6 +9,8 @@ describe 'Fetch proxy pac' do
9
9
  EOS
10
10
  end
11
11
 
12
+ let(:compressed_valid_pac_file) { "function FindProxyForURL(){return\"DIRECT\"}" }
13
+
12
14
  let(:git_repo) { 'git_repo' }
13
15
 
14
16
  before(:each) do
@@ -37,7 +39,7 @@ describe 'Fetch proxy pac' do
37
39
 
38
40
  it 'finds an existing proxy pac' do
39
41
  response = get('/v1/pac/file.pac')
40
- expect(response.body).to eq(valid_pac_file)
42
+ expect(response.body).to eq(compressed_valid_pac_file)
41
43
  end
42
44
 
43
45
  it 'exits with 404 if file does not exist' do
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,9 @@ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
5
5
  # Set the rack environment to `test`
6
6
  ENV["RACK_ENV"] = "test"
7
7
 
8
+ require 'simplecov'
9
+ SimpleCov.start
10
+
8
11
  # Pull in all of the gems including those in the `test` group
9
12
  require 'bundler'
10
13
  Bundler.require :default, :test, :development
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: local_pac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -150,6 +150,11 @@ extensions: []
150
150
  extra_rdoc_files: []
151
151
  files:
152
152
  - .gitignore
153
+ - .rdebugrc
154
+ - .rspec
155
+ - .simplecov
156
+ - .travis.yml
157
+ - .yardopts
153
158
  - Gemfile
154
159
  - LICENSE.txt
155
160
  - Procfile
@@ -193,6 +198,7 @@ files:
193
198
  - lib/local_pac/ui_logger.rb
194
199
  - lib/local_pac/version.rb
195
200
  - local_pac.gemspec
201
+ - share/archlinux/Makefile
196
202
  - share/archlinux/PKGBUILD
197
203
  - share/archlinux/startup.erb
198
204
  - share/examples/config.yaml