Module: Railsquest
- Extended by:
- Commands, DateHelpers, GravatarHelpers
- Defined in:
- lib/railsquest.rb,
lib/railsquest/badge.rb,
lib/railsquest/quest.rb,
lib/railsquest/helpers.rb,
lib/railsquest/version.rb
Defined Under Namespace
Modules: Bonjour, Commands, DateHelpers, GravatarHelpers
Classes: Badge, Quest
Constant Summary
collapse
- VERSION =
'0.1'
Class Method Summary
collapse
Methods included from Commands
add!, advertise!, init_success_message, plain_init_success_message, serve_web!
gravatar, gravatar_uri
distance_of_time_in_words, time_ago_in_words
Class Method Details
.badges ⇒ Object
99
100
101
|
# File 'lib/railsquest.rb', line 99
def badges
badges_path.children.reject{ |b| b.to_s =~ /DS_Store/}.map {|b| Badge.new(b).to_hash }
end
|
.badges_path ⇒ Object
43
44
45
|
# File 'lib/railsquest.rb', line 43
def badges_path
path + "badges"
end
|
.config ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/railsquest.rb', line 51
def config
@config ||= begin
OpenStruct.new({
:name => get_git_global_config("user.name"),
:email => get_git_global_config("user.email")
})
end
end
|
.get_git_global_config(key) ⇒ Object
47
48
49
|
# File 'lib/railsquest.rb', line 47
def get_git_global_config(key)
`git config --global #{key}`.strip
end
|
.host_name ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/railsquest.rb', line 68
def host_name
hn = get_git_global_config("railsquest.hostname")
unless hn.nil? or hn.empty?
return hn
end
hn = Socket.gethostname
return hn if hn.count('.') > 1
if hn =~ /\.local$/
hn
else
hn + ".local"
end
end
|
.path ⇒ Object
35
36
37
|
# File 'lib/railsquest.rb', line 35
def path
Pathname("~/.railsquest").expand_path
end
|
.quest(name) ⇒ Object
95
96
97
|
# File 'lib/railsquest.rb', line 95
def quest(name)
quests.find {|r| r.name == name}
end
|
.quest_uri ⇒ Object
87
88
89
|
# File 'lib/railsquest.rb', line 87
def quest_uri
"http://#{host_name}/"
end
|
.quests ⇒ Object
91
92
93
|
# File 'lib/railsquest.rb', line 91
def quests
quests_path.children.reject{ |b| b.to_s =~ /DS_Store/}.map {|q| Quest.new(q) }
end
|
.quests_path ⇒ Object
39
40
41
|
# File 'lib/railsquest.rb', line 39
def quests_path
path + "quests"
end
|
.setup! ⇒ Object
30
31
32
33
|
# File 'lib/railsquest.rb', line 30
def setup!
quests_path.mkpath
badges_path.mkpath
end
|
.setup? ⇒ Boolean
25
26
27
28
|
# File 'lib/railsquest.rb', line 25
def setup?
quests_path.exist?
badges_path.exist?
end
|
.to_hash ⇒ Object
103
104
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/railsquest.rb', line 103
def to_hash
{
"name" => config.name,
"email" => config.email,
"uri" => web_uri,
"git-uri" => quest_uri,
"gravatar" => Railsquest.gravatar,
"version" => Railsquest::VERSION,
"quests" => quests.collect do |r|
{"name" => r.name, "uri" => r.uri}
end
}
end
|
.web_port ⇒ Object
60
61
62
|
# File 'lib/railsquest.rb', line 60
def web_port
9876
end
|
.web_uri ⇒ Object
64
65
66
|
# File 'lib/railsquest.rb', line 64
def web_uri
"http://#{host_name}:#{web_port}/"
end
|