mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 09:40:21 +00:00
Use yajl since it is already a dependency
Both JSON and Yajl were listed as dependencies. Pygments.rb already requires yajl, so let's just use that instead of using both.
This commit is contained in:
18
Rakefile
18
Rakefile
@@ -1,7 +1,7 @@
|
||||
require 'json'
|
||||
require 'rake/clean'
|
||||
require 'rake/testtask'
|
||||
require 'yaml'
|
||||
require 'yajl'
|
||||
|
||||
task :default => :test
|
||||
|
||||
@@ -19,15 +19,13 @@ end
|
||||
|
||||
task :samples do
|
||||
require 'linguist/samples'
|
||||
require 'yajl'
|
||||
data = Linguist::Samples.data
|
||||
json = Yajl::Encoder.encode(data, :pretty => true)
|
||||
File.open('lib/linguist/samples.json', 'w') { |io| io.write json }
|
||||
json = Yajl.dump(Linguist::Samples.data, :pretty => true)
|
||||
File.write 'lib/linguist/samples.json', json
|
||||
end
|
||||
|
||||
task :build_gem => :samples do
|
||||
languages = YAML.load_file("lib/linguist/languages.yml")
|
||||
File.write("lib/linguist/languages.json", JSON.dump(languages))
|
||||
File.write("lib/linguist/languages.json", Yajl.dump(languages))
|
||||
`gem build github-linguist.gemspec`
|
||||
File.delete("lib/linguist/languages.json")
|
||||
end
|
||||
@@ -71,11 +69,11 @@ namespace :benchmark do
|
||||
reference_file = ENV["REFERENCE"]
|
||||
candidate_file = ENV["CANDIDATE"]
|
||||
|
||||
reference = JSON.parse(File.read(reference_file))
|
||||
reference = Yajl.load(File.read(reference_file))
|
||||
reference_counts = Hash.new(0)
|
||||
reference.each { |filename, language| reference_counts[language] += 1 }
|
||||
|
||||
candidate = JSON.parse(File.read(candidate_file))
|
||||
candidate = Yajl.load(File.read(candidate_file))
|
||||
candidate_counts = Hash.new(0)
|
||||
candidate.each { |filename, language| candidate_counts[language] += 1 }
|
||||
|
||||
@@ -125,14 +123,12 @@ namespace :classifier do
|
||||
|
||||
def each_public_gist
|
||||
require 'open-uri'
|
||||
require 'json'
|
||||
|
||||
url = "https://api.github.com/gists/public"
|
||||
|
||||
loop do
|
||||
resp = open(url)
|
||||
url = resp.meta['link'][/<([^>]+)>; rel="next"/, 1]
|
||||
gists = JSON.parse(resp.read)
|
||||
gists = Yajl.load(resp.read)
|
||||
|
||||
for gist in gists
|
||||
for filename, attrs in gist['files']
|
||||
|
||||
Reference in New Issue
Block a user