[script] user helper

This commit is contained in:
Travis CI 2016-05-16 10:29:04 -07:00
parent 4908b2a77a
commit 1fcfdc240b
6 changed files with 51 additions and 51 deletions

View File

@ -1,8 +1,6 @@
require 'json'
c = File.read 'contents.json'
j = JSON.parse c
require_relative 'osia_helper'
j = get_json
c = j['categories']
c.sort_by { |h| h['title']}

View File

@ -1,45 +1,11 @@
require_relative 'osia_helper'
require 'date'
require 'json'
README = 'README.md'
ARCHIVE = 'ARCHIVE.md'
ARCHIVE_TAG = 'archive'
def output_stars(number)
case number
when 100...200
'🔥'
when 200...500
'🔥🔥'
when 500...1000
'🔥🔥🔥'
when 1000...2000
'🔥🔥🔥🔥'
when 2000...100000
'🔥🔥🔥🔥🔥'
else
''
end
end
def output_flag(lang)
case lang
when 'jpn'
'🇯🇵'
when 'ltz'
'🇱🇺'
when 'por'
'🇧🇷'
when 'spa'
'🇪🇸'
when 'zho'
'🇨🇳'
else
''
end
end
def apps_archived(apps)
a = apps.select {|a| a['tags'] != nil }.select {|b| b['tags'].include?ARCHIVE_TAG}
a.sort_by { |k, v| k['title'] }
@ -103,6 +69,40 @@ def output_apps(apps)
o
end
def output_flag(lang)
case lang
when 'jpn'
'🇯🇵'
when 'ltz'
'🇱🇺'
when 'por'
'🇧🇷'
when 'spa'
'🇪🇸'
when 'zho'
'🇨🇳'
else
''
end
end
def output_stars(number)
case number
when 100...200
'🔥'
when 200...500
'🔥🔥'
when 500...1000
'🔥🔥🔥'
when 1000...2000
'🔥🔥🔥🔥'
when 2000...100000
'🔥🔥🔥🔥🔥'
else
''
end
end
def write_readme(j)
t = j['title']
desc = j['description']
@ -178,8 +178,7 @@ def write_archive(j)
puts "wrote #{file}"
end
c = File.read 'contents.json'
j = JSON.parse c
j = get_json
write_readme(j)
write_archive(j)

7
.github/osia_helper.rb vendored Normal file
View File

@ -0,0 +1,7 @@
require 'json'
FILE = 'contents.json'
def get_json
JSON.parse(File.read FILE)
end

View File

@ -1,15 +1,11 @@
require 'json'
require_relative 'osia_helper'
require 'octokit'
require 'netrc'
FILE = 'contents.json'
c = File.read FILE
j = JSON.parse c
client = Octokit::Client.new(:netrc => true)
j = get_json
apps = j['projects']
updated = []

View File

@ -1,6 +1,6 @@
require 'json'
require_relative 'osia_helper'
j = JSON.parse(File.read 'contents.json')
j = get_json
c = j['categories']
a = j['projects']

View File

@ -8,7 +8,7 @@ test:
override:
- awesome_bot contents.json --white-list developer.apple
- json validate --schema-file=.github/schema.json --document-file=contents.json
- ruby .github/validate_categories.rb
- ruby .github/osia_validate_categories.rb
general:
artifacts:
- "ab-results.json"
@ -16,5 +16,5 @@ deployment:
master:
branch: master
commands:
- ruby .github/convert.rb
- ruby .github/osia_convert.rb
- ./.github/deploy.sh