gisture 0.0.9 → 0.0.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e52baa276ec4cdd5ce67c5c285cbd5dcab39c3de
4
- data.tar.gz: 41bbf46ab40cf0b4bd60fc3b7fb03a16d31e0948
3
+ metadata.gz: 5046586f68d4e3fc48763e84ca611fcefacaa09b
4
+ data.tar.gz: 176944e2861cdbad46bf0646acc7cb67ee229826
5
5
  SHA512:
6
- metadata.gz: 8e33bc194e759fb6d54d151dc9c1f45b1c0c114ccd88a14d6fc6fe7456aac2ed66b8a3d8005ddf06e41caaad318018037fab19d026155c40185ef464135a8440
7
- data.tar.gz: d73d1e039f6d4cf8b597ca2567262926345347f4bd9a618200777a04ac03cbce1d14b47ad0640c4b359e77ca69a4ff0089d3835efff2135bb481d26e43f355c4
6
+ metadata.gz: e936a72c5a01526ccc17e82d914386c5ed1c75787beb8d556e895d04a778210fd05f88dc6530cdd289df9e69015598650e6664317d75a15133a690d4d442a1b0
7
+ data.tar.gz: 47d16ac5491f8369dabc7ae4ad6bd7fddd75ae113941e2d23720952c7bf1eda1a0328cd14251695ddef0ba46f6ec1c09013f4acbcd70b0ed67838082a1081226
data/lib/gisture/file.rb CHANGED
@@ -11,18 +11,21 @@ module Gisture
11
11
  end
12
12
 
13
13
  def require!(&block)
14
+ Gisture.logger.info "[gisture] Running #{basename}/#{file.path || file.filename} via the :require strategy"
14
15
  required = require tempfile.path
15
16
  unlink_tempfile
16
17
  block_given? ? yield : required
17
18
  end
18
19
 
19
20
  def load!(&block)
21
+ Gisture.logger.info "[gisture] Running #{basename}/#{file.path || file.filename} via the :load strategy"
20
22
  loaded = load tempfile.path
21
23
  unlink_tempfile
22
24
  block_given? ? yield : loaded
23
25
  end
24
26
 
25
27
  def eval!(&block)
28
+ Gisture.logger.info "[gisture] Running #{basename}/#{file.path || file.filename} via the :eval strategy"
26
29
  clean_room = Evaluator.new(file.content)
27
30
  clean_room.instance_eval &block if block_given?
28
31
  clean_room
@@ -35,7 +38,7 @@ module Gisture
35
38
 
36
39
  def tempfile
37
40
  @tempfile ||= begin
38
- tmpfile = Tempfile.new([basename, file.filename, ::File.extname(file.filename)].compact, Gisture.configuration.tmpdir)
41
+ tmpfile = Tempfile.new([basename.to_s.gsub(/\//, '-'), file.filename, ::File.extname(file.filename)].compact, Gisture.configuration.tmpdir)
39
42
  tmpfile.write(file.content)
40
43
  tmpfile.close
41
44
  tmpfile
data/lib/gisture/gist.rb CHANGED
@@ -49,10 +49,10 @@ module Gisture
49
49
  return @file unless @file.nil?
50
50
 
51
51
  if gist.files.count > 1 && !filename.nil?
52
- @file = Gisture::File.new(gist.files[filename], basename: gist_id, strategy: strategy)
52
+ @file = Gisture::File.new(gist.files[filename], basename: "#{gist.owner.login}/#{gist_id}", strategy: strategy)
53
53
  raise ArgumentError, "The filename '#{filename}' was not found in the list of files for the gist '#{gist_id}'" if @file.nil?
54
54
  else
55
- @file = Gisture::File.new(gist.files.first[1], basename: gist_id, strategy: strategy)
55
+ @file = Gisture::File.new(gist.files.first[1], basename: "#{gist.owner.login}/#{gist_id}", strategy: strategy)
56
56
  end
57
57
 
58
58
  @file
@@ -1,5 +1,11 @@
1
1
  module Gisture
2
2
  class Railtie < Rails::Railtie
3
+ initializer "gisture.configure_rails_logger" do
4
+ Gisture.configure do |config|
5
+ config.logger = Rails.logger
6
+ end
7
+ end
8
+
3
9
  rake_tasks do
4
10
  Dir[::File.join(::File.dirname(__FILE__),'../tasks/*.rake')].each { |f| load f }
5
11
  end
data/lib/gisture/repo.rb CHANGED
@@ -41,7 +41,7 @@ module Gisture
41
41
  file = github.repos.contents.get(user: owner, repo: project, path: path).body
42
42
  file['filename'] = ::File.basename(file['path'])
43
43
  file['content'] = Base64.decode64(file['content'])
44
- Gisture::File.new(file, basename: "#{owner}-#{project}", strategy: strategy)
44
+ Gisture::File.new(file, basename: "#{owner}/#{project}", strategy: strategy)
45
45
  end
46
46
 
47
47
  def run!(path, strategy: nil, &block)
@@ -1,3 +1,3 @@
1
1
  module Gisture
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.10'
3
3
  end
data/lib/gisture.rb CHANGED
@@ -23,6 +23,7 @@ module Gisture
23
23
  config.user = nil # global user used in requets if none provided
24
24
  config.org = nil # global organization used in request if none provided
25
25
 
26
+ config.logger = nil # defaults to STDOUT but will use Rails.logger in a rails environment
26
27
  config.strategy = :eval # default execution strategy
27
28
  config.tmpdir = Dir.tmpdir # location to store gist tempfiles
28
29
  config.owners = nil # only allow gists/repos/etc. from whitelisted owners (str/sym/arr)
@@ -32,6 +33,10 @@ module Gisture
32
33
  end
33
34
  end
34
35
 
36
+ def self.logger
37
+ configuration.logger || Logger.new(STDOUT)
38
+ end
39
+
35
40
  def self.new(gist, strategy: nil, filename: nil, version: nil)
36
41
  Gisture::Gist.new(gist, strategy: strategy, filename: filename, version: version)
37
42
  end
data/spec/gisture_spec.rb CHANGED
@@ -1,6 +1,32 @@
1
1
  require "spec_helper"
2
2
 
3
3
  RSpec.describe Gisture do
4
+ describe '.logger' do
5
+ context 'when no logger is configured' do
6
+ it 'returns an instance of the base logger class' do
7
+ expect(Gisture.logger).to be_an_instance_of(Logger)
8
+ end
9
+ end
10
+
11
+ context 'when a logger is configured' do
12
+ it 'returns the configured logger' do
13
+ begin
14
+ Gisture.configure do |config|
15
+ config.logger = Logger.new(STDERR)
16
+ end
17
+
18
+ expect(Gisture.logger).to eql(Gisture.configuration.logger)
19
+ rescue => e
20
+ raise e
21
+ ensure
22
+ Gisture.configure do |config|
23
+ config.logger = nil
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
4
30
  describe '.new' do
5
31
  it 'returns a new Gisture::Gist' do
6
32
  expect(Gisture.new(TEST_GIST_ID)).to be_a(Gisture::Gist)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gisture
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Rebec
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: canfig