This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Strech (Sergey Fedorov)
committed
Aug 27, 2013
1 parent
c88eca4
commit 865b814
Showing
16 changed files
with
252 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
*.gem | ||
.ruby-* | ||
.bundle | ||
Gemfile.lock | ||
pkg/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
#!/usr/bin/env ruby | ||
# coding: utf-8 | ||
require 'abak-flow' | ||
require "abak-flow/request" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
module Abak | ||
module Flow | ||
autoload :Git, "abak-flow/git" | ||
autoload :Configuration, "abak-flow/configuration" | ||
autoload :Messages, "abak-flow/messages" | ||
autoload :Project, "abak-flow/project" | ||
autoload :System, "abak-flow/system" | ||
autoload :GithubClient, "abak-flow/github_client" | ||
autoload :Branches, "abak-flow/branches" | ||
autoload :Branch, "abak-flow/branch" | ||
autoload :PullRequest, "abak-flow/pull_request" | ||
end | ||
module Flow; end | ||
end | ||
|
||
require "abak-flow/version" | ||
require "abak-flow/version" # ✔ | ||
require "abak-flow/manager" | ||
require "abak-flow/configuration" | ||
require "abak-flow/repository" | ||
require "abak-flow/request" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,68 @@ | ||
# coding: utf-8 | ||
# | ||
# Module for access to global abak-flow gem config | ||
# recieved from .git config and environment | ||
# | ||
# Auto generated methods: oauth_user, oauth_token, proxy_server | ||
# | ||
# TODO : Проверять что атрибут из конфига валиден | ||
# TODO : Переименовать модуль | ||
# | ||
# Example | ||
# | ||
# Abak::Flow::Configuration.oauth_user #=> Strech | ||
# | ||
require "singleton" | ||
require "i18n" | ||
require "ruler" | ||
require "forwardable" | ||
require "ostruct" | ||
|
||
module Abak::Flow | ||
class Configuration | ||
include Singleton | ||
include Ruler | ||
extend Forwardable | ||
|
||
def_delegator "Abak::Flow::Git.instance", :git | ||
OPTIONS = [:oauth_user, :oauth_token, :locale, :http_proxy].freeze | ||
LOCALE_FILES = File.join(File.dirname(__FILE__), "locales/*.{rb,yml}").freeze | ||
|
||
attr_reader :params | ||
def_delegators :@manager, :git | ||
|
||
def initialize | ||
load_git_configuration | ||
setup_locale | ||
attr_reader :errors | ||
|
||
def initialize(manager) | ||
@manager = manager | ||
@errors = [] | ||
|
||
configure! | ||
end | ||
|
||
private | ||
def load_git_configuration | ||
git_config = git.config.select { |k, _| k.include? "abak-flow." } | ||
.map { |k,v| [convert_param_name_to_method_name(k), v] } | ||
def ready? | ||
@errors = [] | ||
|
||
@params = Params.new(Hash[git_config]).tap do |p| | ||
p.locale ||= "en" | ||
p.proxy_server ||= environment_http_proxy | ||
multi_ruleset do | ||
fact(:oauth_user_not_setup) { oauth_user.nil? } | ||
fact(:oauth_token_not_setup) { oauth_token.nil? } | ||
|
||
rule([:oauth_user_not_setup]) { @errors << I18n.t("configuration.errors.oauth_user_not_setup") } | ||
rule([:oauth_token_not_setup]) { @errors << I18n.t("configuration.errors.oauth_token_not_setup") } | ||
end | ||
|
||
@errors.empty? ? true : false | ||
end | ||
|
||
def setup_locale | ||
I18n.load_path += Dir.glob(File.join File.dirname(__FILE__), "locales/*.{rb,yml}") | ||
I18n.locale = params.locale | ||
def configure! | ||
load_gitconfig | ||
setup_locale | ||
end | ||
|
||
def environment_http_proxy | ||
ENV["http_proxy"] || ENV["HTTP_PROXY"] | ||
private | ||
def setup_locale | ||
I18n.load_path += Dir.glob(LOCALE_FILES) | ||
I18n.locale = locale | ||
end | ||
|
||
def convert_param_name_to_method_name(name) | ||
name.sub(/abak-flow./, "").gsub(/\W/, "_") | ||
def load_gitconfig | ||
git_config = git.config.select { |k, _| k.include? "abak-flow." } | ||
.map { |k,v| [to_method_name(k), v] } | ||
|
||
|
||
config = Hash[git_config] | ||
config[:locale] ||= "en" | ||
config[:http_proxy] ||= ENV["http_proxy"] || ENV["HTTP_PROXY"] | ||
|
||
OPTIONS.each do |name| | ||
define_singleton_method(name) { config[name] } | ||
end | ||
end | ||
|
||
class Params < OpenStruct; end | ||
def to_method_name(name) | ||
name.sub(/abak-flow./, "").gsub(/\W/, "_").to_sym | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,19 @@ | ||
en: | ||
commands: | ||
checkup: &command_checkup | ||
you_are_ready: "Yaw, you are ready!" | ||
you_are_not_prepared: "You are not prepared!" | ||
publish: | ||
<<: *command_checkup | ||
lets_do_it: "Let's do it!" | ||
request_published: "Yaw, your request published!" | ||
something_goes_wrong: "Goddamned, something goes wrong ..." | ||
garbage: | ||
searching_for_garbage: "Searching for garbage ..." | ||
garbage_detected: "Some part of garbage detected" | ||
no_garbage_detected: "Yaw, no garbage detected!" | ||
configuration: | ||
name: Configuration | ||
errors: | ||
oauth_user_not_setup: Options oauth_user not setted | ||
oauth_token_not_setup: Options oauth_token not setted | ||
recommendations: "Check [abak-flow] section in ~/.gitcofig file" | ||
|
||
system: | ||
recommendations: | ||
header: "== System recommendations ==" | ||
set_up_origin: "Set up your origin" | ||
set_up_upstream: "Set up your upstream" | ||
set_up_oauth_user: "Set up your abak-flow.oauth-user" | ||
set_up_oauth_token: "Set up your abak-flow.oauth-token" | ||
information: | ||
header: "== System information ==" | ||
proxy_server_set_up: "You set up the custom proxy server" | ||
repository: | ||
name: Repository | ||
errors: | ||
origin_not_setup: Repository with name 'origin' not found | ||
upstream_not_setup: Repository with name 'upstream' not found | ||
recommendations: "Check .git/cofig file" | ||
|
||
pull_request: | ||
publish: | ||
forgot_task: "Sorry, i forgot my task number. Ask me personally if you have any questions" | ||
garbage: | ||
collected_branches: "Branches collected: %{count}" | ||
deletion_allowed: "%{index}. %{branch_name} → deletion allowed" | ||
deletion_possibly: "%{index}. %{branch_name} → deletion possibly\n%{diagnoses}" | ||
deletion_restricted: "%{index}. %{branch_name} → deletion restricted\n%{diagnoses}" | ||
branch_unused: "Branch is unused in upstream" | ||
branch_differ: "Branch is differ than origin" | ||
branch_missing: "Branch is missing in local repo" | ||
commands: | ||
checkup: | ||
fail: "You are not prepared!" | ||
success: "Congratulations, you are ready to ROCK :)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
ru: | ||
configuration: | ||
name: Корфигурация | ||
errors: | ||
oauth_user_not_setup: Не установлена опция oauth_user | ||
oauth_token_not_setup: Не установлена опция oauth_token | ||
recommendations: "Проверьте секцию [abak-flow] в файле ~/.gitcofig" | ||
|
||
repository: | ||
name: Репозиторий | ||
errors: | ||
origin_not_setup: Репозиторий с именем 'origin' не найден | ||
upstream_not_setup: Репозиторий с именем 'upstream' не найден | ||
recommendations: Проверьте файл .git/cofig | ||
|
||
commands: | ||
checkup: &command_checkup | ||
you_are_ready: "Ура, все готово!" | ||
you_are_not_prepared: "Кажется вы все еще не готовы!" | ||
publish: | ||
<<: *command_checkup | ||
lets_do_it: "Начинаю публиковать пул реквест" | ||
request_published: "Ура, пул реквест опубликован!" | ||
something_goes_wrong: "Так, кажется что-то пошло не так ..." | ||
system: | ||
recommendations: | ||
header: "== Рекомендации по конфигурации ==" | ||
set_up_origin: "Укажите origin репозиторий" | ||
set_up_upstream: "Укажите upstream репозиторий" | ||
set_up_oauth_user: "Пропишите git конфигурацию abak-flow.oauth-user" | ||
set_up_oauth_token: "Пропишите git конфигурацию abak-flow.oauth-token" | ||
information: | ||
header: "== Информация по конфигурации ==" | ||
proxy_server_set_up: "Вы указали свой proxy server" | ||
checkup: | ||
fail: "Вы не готовы!" | ||
success: "Поздравляем, вы готовы чтобы жечь :)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# coding: utf-8 | ||
require "git" | ||
|
||
module Abak::Flow | ||
class Manager | ||
|
||
def initialize | ||
# preload dependencies | ||
configuration | ||
repository | ||
|
||
yield self if block_given? | ||
end | ||
|
||
def configuration | ||
@configuration ||= Configuration.new(self) | ||
end | ||
|
||
def repository | ||
@repository ||= Repository.new(self) | ||
end | ||
|
||
def git | ||
@git ||= Git.open(".") | ||
end | ||
|
||
end | ||
end |
Oops, something went wrong.