Module: Nailed
- Extended by:
- Nailed
- Included in:
- 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"))
Instance Method Summary
collapse
Instance Method Details
#fill_db_after_migration(github_client) ⇒ Object
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/nailed.rb', line 155
def fill_db_after_migration(github_client)
get_config["products"].each do |product,values|
organization = values["organization"]
values["versions"].each do |version|
db_handler = Product.first_or_create(:name => version)
save_state(db_handler)
end unless values["versions"].nil?
unless organization.nil?
db_handler = Organization.first_or_create(:oname => organization)
save_state(db_handler)
org_repos_github = 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)
save_state(db_handler)
end
end
end
end
end
|
#get_config ⇒ Object
145
146
147
148
|
# File 'lib/nailed.rb', line 145
def get_config
conf = File.join(File.expand_path("..", File.dirname(__FILE__)),"config","config.yml")
YAML.load_file(conf)
end
|
#get_org_repos(github_client, org) ⇒ Object
150
151
152
153
|
# File 'lib/nailed.rb', line 150
def 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
177
178
179
180
|
# File 'lib/nailed.rb', line 177
def list_org_repos(github_client, org)
repos = get_org_repos(github_client, org)
repos.each {|r| puts "- #{r}"}
end
|
#log(level, msg) ⇒ Object
137
138
139
140
141
142
143
|
# File 'lib/nailed.rb', line 137
def log(level,msg)
if level == "error"
LOGGER.error(msg)
else
LOGGER.info(msg)
end
end
|
#save_state(db_handler) ⇒ Object
182
183
184
185
186
187
|
# File 'lib/nailed.rb', line 182
def save_state(db_handler)
unless db_handler.save
puts("ERROR: see logfile")
log("error", db_handler.errors.inspect)
end
end
|