Module: Nailed
- Defined in:
- lib/nailed.rb
Defined Under Namespace
Classes: Bugzilla, Github
Constant Summary
collapse
- LOGGER =
Logger.new(File.join(File.expand_path("..", File.dirname(__FILE__)),"log","nailed.log"))
- CONFIG_FILE =
File.join(File.expand_path("..", File.dirname(__FILE__)),"config","products.yml")
- PRODUCTS =
YAML.load_file(CONFIG_FILE)
Class Method Summary
collapse
Class Method Details
.fill_db_after_migration(github_client) ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/nailed.rb', line 141
def Nailed.fill_db_after_migration(github_client)
Nailed::PRODUCTS["products"].each do |product,values|
organization = values["organization"]
values["versions"].each do |version|
db_handler = Product.first_or_create(:name => version)
Nailed.save_state(db_handler)
end unless values["versions"].nil?
unless organization.nil?
db_handler = Organization.first_or_create(:oname => organization)
Nailed.save_state(db_handler)
org_repos_github = Nailed.get_org_repos(github_client, organization)
org_repos_yml = values["repos"]
org_repos_yml.each do |org_repo|
if org_repos_github.include?(org_repo)
db_handler = Repository.first_or_create(:rname => org_repo, :organization_oname => organization)
Nailed.save_state(db_handler)
end
end
end
end
end
|
.get_org_repos(github_client, org) ⇒ Object
136
137
138
139
|
# File 'lib/nailed.rb', line 136
def Nailed.get_org_repos(github_client, org)
all_repos = github_client.org_repos(org)
all_repos.map(&:name)
end
|
.list_org_repos(github_client, org) ⇒ Object
163
164
165
166
|
# File 'lib/nailed.rb', line 163
def Nailed.list_org_repos(github_client, org)
repos = Nailed.get_org_repos(github_client, org)
repos.each {|r| puts "- #{r}"}
end
|
.log(level, msg) ⇒ Object
128
129
130
131
132
133
134
|
# File 'lib/nailed.rb', line 128
def Nailed.log(level,msg)
if level == "error"
Nailed::LOGGER.error(msg)
else
Nailed::LOGGER.info(msg)
end
end
|
.save_state(db_handler) ⇒ Object
168
169
170
171
172
173
|
# File 'lib/nailed.rb', line 168
def Nailed.save_state(db_handler)
unless db_handler.save
puts("ERROR: see logfile")
log("error", db_handler.errors.inspect)
end
end
|