kofi 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_DISABLE_SHARED_GEMS: "1"
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ # A sample Gemfile
2
+ source "http://rubygems.org"
3
+
4
+ gem 'trollop'
5
+ group :development, :test do
6
+ gem 'rspec'
7
+ end
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ rspec (2.1.0)
6
+ rspec-core (~> 2.1.0)
7
+ rspec-expectations (~> 2.1.0)
8
+ rspec-mocks (~> 2.1.0)
9
+ rspec-core (2.1.0)
10
+ rspec-expectations (2.1.0)
11
+ diff-lcs (~> 1.1.2)
12
+ rspec-mocks (2.1.0)
13
+ trollop (1.16.2)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ rspec
20
+ trollop
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 T.J. VanSlyke
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ = kofi
2
+
3
+ A command line utility for setting and retrieving Rails I18n strings.
4
+
5
+ == Usage
6
+
7
+ >> kofi en.log_in "Log in"
8
+ >> kofi en.passwords.reset_message "Reset your password"
9
+
10
+ == Note on Patches/Pull Requests
11
+
12
+ * Fork the project.
13
+ * Make your feature addition or bug fix.
14
+ * Add tests for it. This is important so I don't break it in a
15
+ future version unintentionally.
16
+ * Commit, do not mess with rakefile, version, or history.
17
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
18
+ * Send me a pull request. Bonus points for topic branches.
19
+
20
+ == Copyright
21
+
22
+ Copyright (c) 2010 T.J. VanSlyke. See LICENSE for details.
@@ -0,0 +1,40 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "kofi"
8
+ gem.summary = %Q{Rails I18n command line interface}
9
+ gem.description = %Q{A utility for setting and retrieving Rails I18n strings from the command line}
10
+ gem.email = "teejay.vanslyke@gmail.com"
11
+ gem.homepage = "http://github.com/teejayvanslyke/kofi"
12
+ gem.authors = ["T.J. VanSlyke"]
13
+ gem.add_dependency 'trollop'
14
+ gem.add_development_dependency "rspec", ">= 1.2.9"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'rspec/core/rake_task'
23
+
24
+ RSpec::Core::RakeTask.new do |t|
25
+ t.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
26
+ t.pattern = 'spec/**/*_spec.rb'
27
+ end
28
+ task :spec => :check_dependencies
29
+
30
+ task :default => :spec
31
+
32
+ require 'rake/rdoctask'
33
+ Rake::RDocTask.new do |rdoc|
34
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
35
+
36
+ rdoc.rdoc_dir = 'rdoc'
37
+ rdoc.title = "kofi #{version}"
38
+ rdoc.rdoc_files.include('README*')
39
+ rdoc.rdoc_files.include('lib/**/*.rb')
40
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__),'..','lib')
4
+
5
+ require 'rubygems'
6
+ require 'kofi'
7
+ require 'trollop'
8
+
9
+ opts = Trollop::options do
10
+ opt :locale_path, "Path to your locale YAML files", :default => File.join(Dir.pwd, 'config', 'locales')
11
+ end
12
+
13
+ Kofi.run(opts, ARGV)
@@ -0,0 +1,64 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{kofi}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["T.J. VanSlyke"]
12
+ s.date = %q{2010-11-09}
13
+ s.default_executable = %q{kofi}
14
+ s.description = %q{A utility for setting and retrieving Rails I18n strings from the command line}
15
+ s.email = %q{teejay.vanslyke@gmail.com}
16
+ s.executables = ["kofi"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".bundle/config",
23
+ ".document",
24
+ ".gitignore",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE",
28
+ "README.rdoc",
29
+ "Rakefile",
30
+ "VERSION",
31
+ "bin/kofi",
32
+ "kofi.gemspec",
33
+ "lib/kofi.rb",
34
+ "spec/kofi_spec.rb",
35
+ "spec/spec.opts",
36
+ "spec/spec_helper.rb"
37
+ ]
38
+ s.homepage = %q{http://github.com/teejayvanslyke/kofi}
39
+ s.rdoc_options = ["--charset=UTF-8"]
40
+ s.require_paths = ["lib"]
41
+ s.rubygems_version = %q{1.3.7}
42
+ s.summary = %q{Rails I18n command line interface}
43
+ s.test_files = [
44
+ "spec/kofi_spec.rb",
45
+ "spec/spec_helper.rb"
46
+ ]
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 3
51
+
52
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
+ s.add_runtime_dependency(%q<trollop>, [">= 0"])
54
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
55
+ else
56
+ s.add_dependency(%q<trollop>, [">= 0"])
57
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<trollop>, [">= 0"])
61
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
62
+ end
63
+ end
64
+
@@ -0,0 +1,68 @@
1
+ require 'yaml'
2
+
3
+ module Kofi
4
+
5
+ class << self
6
+
7
+ attr_reader :trail
8
+
9
+ def run(opts, args)
10
+ @locale_path = opts[:locale_path]
11
+ @trail = args.shift.split('.')
12
+ @locale = trail.first
13
+ @value = args.shift
14
+
15
+ if @value
16
+ data = set YAML::load_file(filename), trail, @value
17
+ File.open(filename, 'w') do |file|
18
+ YAML::dump(data, file)
19
+ end
20
+ end
21
+
22
+ puts "#{trail.join('.')} => #{get(trail).inspect}"
23
+ end
24
+
25
+ def filename
26
+ File.join(@locale_path, "#{@locale}.yml")
27
+ end
28
+
29
+ def get(key)
30
+ current = YAML::load_file(filename)
31
+ key.each do |part|
32
+ current = current[part]
33
+ end
34
+
35
+ return current
36
+ end
37
+
38
+ def set(data, key, value)
39
+ deep_merge(data, hash_to_be_merged(key, value))
40
+ end
41
+
42
+ def hash_to_be_merged(trail, value)
43
+ trail = trail.dup
44
+ if trail.size > 0
45
+ key = trail.shift
46
+ { key => hash_to_be_merged(trail, value) }
47
+ else
48
+ value
49
+ end
50
+ end
51
+
52
+ def deep_merge(lhs, rhs)
53
+ target = lhs.dup
54
+
55
+ rhs.keys.each do |key|
56
+ if rhs[key].is_a? Hash and lhs[key].is_a? Hash
57
+ target[key] = deep_merge(target[key], rhs[key])
58
+ next
59
+ end
60
+
61
+ target[key] = rhs[key]
62
+ end
63
+
64
+ target
65
+ end
66
+ end
67
+
68
+ end
@@ -0,0 +1,5 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Kofi do
4
+
5
+ end
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'kofi'
4
+ require 'rspec'
5
+ require 'rspec/autorun'
6
+
7
+ RSpec.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kofi
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - T.J. VanSlyke
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-11-09 00:00:00 -08:00
18
+ default_executable: kofi
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: trollop
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ version: "0"
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ - !ruby/object:Gem::Dependency
34
+ name: rspec
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 2
44
+ - 9
45
+ version: 1.2.9
46
+ type: :development
47
+ version_requirements: *id002
48
+ description: A utility for setting and retrieving Rails I18n strings from the command line
49
+ email: teejay.vanslyke@gmail.com
50
+ executables:
51
+ - kofi
52
+ extensions: []
53
+
54
+ extra_rdoc_files:
55
+ - LICENSE
56
+ - README.rdoc
57
+ files:
58
+ - .bundle/config
59
+ - .document
60
+ - .gitignore
61
+ - Gemfile
62
+ - Gemfile.lock
63
+ - LICENSE
64
+ - README.rdoc
65
+ - Rakefile
66
+ - VERSION
67
+ - bin/kofi
68
+ - kofi.gemspec
69
+ - lib/kofi.rb
70
+ - spec/kofi_spec.rb
71
+ - spec/spec.opts
72
+ - spec/spec_helper.rb
73
+ has_rdoc: true
74
+ homepage: http://github.com/teejayvanslyke/kofi
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options:
79
+ - --charset=UTF-8
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ segments:
96
+ - 0
97
+ version: "0"
98
+ requirements: []
99
+
100
+ rubyforge_project:
101
+ rubygems_version: 1.3.7
102
+ signing_key:
103
+ specification_version: 3
104
+ summary: Rails I18n command line interface
105
+ test_files:
106
+ - spec/kofi_spec.rb
107
+ - spec/spec_helper.rb