Skip to content

Commit

Permalink
Update to latest active_support
Browse files Browse the repository at this point in the history
This works around the bizarre bundler/feedzirra/hashie problem where you
can't pass a Hashie::Mash to JSON.pretty_generate.
     https://github.com/bronson/whose-bug
  • Loading branch information
bronson committed Jun 8, 2011
1 parent 1805e76 commit 84ed3a8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
source 'http://rubygems.org'

# some weird interaction between a bunch of gems... Locking activesupport
# seems to fix it. If you can run 'JSON.pretty_generate(Hashie::Mash.new)'
# on the vim-script console then this is not a problem.
gem 'activesupport' ,'= 3.0.1'

# the pdf magic in mimemagic 0.1.8 is far too loose (recognizes textfiles and zipfiles as pdf)
# see comments on https://github.com/minad/mimemagic/commit/50078a4d52bb80f525784f6a4cb874fc7d2a03a0#commitcomment-280266
gem 'mimemagic' ,'= 0.1.7'
Expand Down
11 changes: 5 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
GIT
remote: git://github.com/bronson/retryable.git
revision: bb5b5796cf9cf6e04161f39920888a9fc1c86ef1
revision: a21655fa16330382e54a9ddba583a566399ab3b1
specs:
retryable (0.2.0)
retryable (0.9.0)

GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
activesupport (3.0.1)
activesupport (3.0.8)
builder (3.0.0)
bzip2-ruby (0.2.7)
crack (0.1.6)
curb (0.7.10)
curb (0.7.15)
erubis (2.6.6)
abstract (>= 1.0.0)
feedzirra (0.0.24)
Expand All @@ -32,7 +32,7 @@ GEM
json (1.4.6)
loofah (1.0.0)
nokogiri (>= 1.3.3)
mail (2.2.15)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
Expand All @@ -54,7 +54,6 @@ PLATFORMS
ruby

DEPENDENCIES
activesupport (= 3.0.1)
bzip2-ruby (~> 0.2.6)
erubis (~> 2.6.6)
feedzirra (~> 0.0.24)
Expand Down
27 changes: 24 additions & 3 deletions scraper
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,27 @@ module Hpricot
end


# Recursively convert a Hashie::Mash back to a plain hash
#def convert_hash arg
#if arg.kind_of? Hashie::Mash
#hash = arg.to_hash
#hash.each { |k,v| hash[k] = convert_hash v }
#hash
#else
#arg
#end
#end


# There's a bizarre bug when passing a Hashie::Mash to JSON.pretty_generate.
# See https://github.com/bronson/whose-bug for an attempt to track it down.
# This routine just converts to plain hashes before generating.
def json_pretty arg
arg = arg.to_hash if arg.kind_of? Hashie::Mash
JSON.pretty_generate(arg) + "\n"
end


# When running normally, we can be in one of two states: rss and full.
# rss is when the rss is synced and we can update only the scripts that have changed.
# full is when we're just starting or we have lost the rss sync.
Expand All @@ -238,7 +259,7 @@ end


def write_state state
File.open($state_file, 'w') { |f| f.write(JSON.pretty_generate(state)+"\n") }
File.open($state_file, 'w') { |f| f.write json_pretty(state) }
end


Expand Down Expand Up @@ -722,7 +743,7 @@ def write_script script
File.open(filename, 'w') do |f|
farg = fix_encoding(script)
# check_encoding(farg)
f.write(JSON.pretty_generate(farg)+"\n")
f.write json_pretty(farg)
end
filename
end
Expand Down Expand Up @@ -1382,7 +1403,7 @@ def perform_download script_file

# store the script file in the repo it creates
File.open(File.join(repo.path, $git_script_file), 'w') { |f|
f.write JSON.pretty_generate(script) + "\n"
f.write json_pretty(script)
}

count = store_versions_in_repo(repo, script)
Expand Down

0 comments on commit 84ed3a8

Please sign in to comment.