Permalink
Browse files

fix some code

  • Loading branch information...
1 parent 0af8e34 commit 109ab2fccf509bd04640636e2bedeb6c2f079af2 @txus committed Apr 28, 2012
Showing with 25 additions and 7 deletions.
  1. +7 −0 Rakefile
  2. +9 −3 lib/mayl/commands/cd.rb
  3. +4 −2 lib/mayl/commands/edit.rb
  4. +3 −2 lib/mayl/commands/get.rb
  5. +2 −0 mayl.gemspec
View
@@ -14,5 +14,12 @@ Rake::TestTask.new do |t|
t.test_files = FileList['./test/**/*_test.rb']
end
+require 'reek/rake/task'
+Reek::Rake::Task.new do |t|
+ t.fail_on_error = true
+ t.verbose = false
+ t.source_files = 'lib/**/*.rb'
+end
+
task :doc => :yard
task :default => :test
View
@@ -22,17 +22,19 @@ def initialize(env, path)
#
# Returns nil.
def execute
+ namespace = @env.namespace
+
case @path
when ".."
- ns = @env.namespace.split('.')
+ ns = namespace.split('.')
ns.pop
@env.namespace = ns.join('.')
when "."
@env.namespace = ""
else
check_namespace!
- if @env.namespace.empty?
+ if namespace.empty?
@env.namespace = @path
else
@env.namespace += '.' << @path
@@ -41,7 +43,11 @@ def execute
nil
end
- # Public: Checks that you're not trying to enter a leaf.
+ #######
+ private
+ #######
+
+ # Internal: Checks that you're not trying to enter a leaf.
#
# Raises an ArgumentError if you are.
def check_namespace!
@@ -28,11 +28,13 @@ def initialize(env, locale, value)
#
# Returns the key.
def execute
+ key = qualified_key
locale = locales.detect do |locale|
locale.name.to_s == @locale.to_s
end
- locale.set @key, @value
- @key
+
+ locale.set key, @value
+ key
end
#######
View
@@ -31,10 +31,11 @@ def initialize(env, key)
def execute
locales.each do |locale|
result = locale.get qualified_key
+ name = locale.to_s
if result.is_a? String
- print " #{locale.to_s}: #{result}\n"
+ print " #{name}: #{result}\n"
else
- print " #{locale.to_s}: (empty)\n"
+ print " #{name}: (empty)\n"
end
end
@key
View
@@ -19,6 +19,8 @@ Gem::Specification.new do |gem|
gem.add_development_dependency 'yard-tomdoc'
gem.add_development_dependency 'redcarpet'
+ gem.add_development_dependency 'reek'
+
gem.add_development_dependency 'minitest'
gem.add_development_dependency 'mocha'
end

0 comments on commit 109ab2f

Please sign in to comment.