nanoant-setlocale 0.0.2

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,20 @@
1
+ Copyright (c) 2009 Adam Strzelecki
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,26 @@
1
+ setlocale
2
+ ===========
3
+ *setlocale* is POSIX locale natural language formatting for Ruby. Let's you override current Ruby process locale as simple as:
4
+
5
+ Locale::all = 'en_US.UTF-8'
6
+
7
+ Or when you want to ensure that *Iconv* extensions will work fine:
8
+
9
+ Locale::ctype = ''
10
+
11
+ Setup
12
+ =====
13
+ ### 1. Install
14
+ sudo gem install nanoant-setlocale -s http://gems.github.com/
15
+
16
+ Or from source:
17
+
18
+ git clone git://github.com/nanoant/setlocale.git
19
+ cd setlocale && rake install
20
+
21
+ Author
22
+ ======
23
+ [Adam Strzelecki](http://www.nanoant.com/)
24
+ ono@java.pl
25
+
26
+ Released under MIT license, see `MIT-LICENSE` for details.
@@ -0,0 +1,59 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "setlocale"
8
+ gem.description = "POSIX locale natural language formatting for Ruby"
9
+ gem.summary = "POSIX locale natural language formatting for Ruby"
10
+ gem.email = "ono@java.pl"
11
+ gem.homepage = "http://github.com/nanoant/setlocale"
12
+ gem.authors = ["Adam Strzelecki"]
13
+ gem.extensions = ["lib/extconf.rb"]
14
+ gem.files = FileList['lib/**/*.rb', 'lib/**/*.c', 'bin/*', '[A-Z]*', 'test/**/*'].to_a
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
+ end
21
+
22
+ require 'rake/testtask'
23
+ Rake::TestTask.new(:test) do |test|
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/*_test.rb'
26
+ test.verbose = true
27
+ end
28
+
29
+ begin
30
+ require 'rcov/rcovtask'
31
+ Rcov::RcovTask.new do |test|
32
+ test.libs << 'test'
33
+ test.pattern = 'test/**/*_test.rb'
34
+ test.verbose = true
35
+ end
36
+ rescue LoadError
37
+ task :rcov do
38
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
+ end
40
+ end
41
+
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ if File.exist?('VERSION.yml')
48
+ config = YAML.load(File.read('VERSION.yml'))
49
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
50
+ else
51
+ version = ""
52
+ end
53
+
54
+ rdoc.rdoc_dir = 'rdoc'
55
+ rdoc.title = "setlocale #{version}"
56
+ rdoc.rdoc_files.include('README*')
57
+ rdoc.rdoc_files.include('lib/**/*.rb')
58
+ end
59
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # extconf.rb
3
+ require 'mkmf'
4
+ extension_name = 'setlocale_ext'
5
+ header = "locale.h"
6
+ dir_config(extension_name)
7
+ if have_header(header)
8
+ lc = %w[CTYPE NUMERIC TIME COLLATE MONETARY MESSAGES ALL]
9
+ lc = lc.delete_if {|n| !have_macro("LC_#{n}", header)}.
10
+ collect {|n| "def(#{n.downcase}, LC_#{n})"}.
11
+ join(' ')
12
+ $defs << "-Dforeach_categories(def)=\"#{lc}\""
13
+ create_header
14
+ create_makefile(extension_name)
15
+ end
@@ -0,0 +1,41 @@
1
+ #include <locale.h>
2
+ #include "ruby.h"
3
+
4
+ static VALUE
5
+ rb_setlocale(int category, const char *locale)
6
+ {
7
+ char *r = setlocale(category, locale);
8
+ if (!r) rb_raise(rb_eRuntimeError, "setlocale");
9
+ return rb_str_new2(r);
10
+ }
11
+
12
+ static inline VALUE
13
+ locale_set(int category, VALUE locale)
14
+ {
15
+ return rb_setlocale(category, StringValueCStr(locale));
16
+ }
17
+
18
+ static inline VALUE
19
+ locale_get(int category)
20
+ {
21
+ return rb_setlocale(category, NULL);
22
+ }
23
+
24
+ #define funcs(n, c) \
25
+ static VALUE rb_getlocale_##n(VALUE self) {return locale_get(c);} \
26
+ static VALUE rb_setlocale_##n(VALUE self, VALUE val) {return locale_set(c, val);} \
27
+ /* end of funcs */
28
+
29
+ foreach_categories(funcs)
30
+
31
+ void
32
+ Init_setlocale_ext(void)
33
+ {
34
+ VALUE locale = rb_define_module("Locale");
35
+ #define methods(n, c) \
36
+ rb_define_singleton_method(locale, #n, rb_getlocale_##n, 0); \
37
+ rb_define_singleton_method(locale, #n"=", rb_setlocale_##n, 1); \
38
+ /* end of methods */
39
+
40
+ foreach_categories(methods);
41
+ }
@@ -0,0 +1 @@
1
+ require 'setlocale_ext'
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class SetlocaleTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'setlocale'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nanoant-setlocale
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Adam Strzelecki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-09 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: POSIX locale natural language formatting for Ruby
17
+ email: ono@java.pl
18
+ executables: []
19
+
20
+ extensions:
21
+ - lib/extconf.rb
22
+ extra_rdoc_files:
23
+ - README.markdown
24
+ files:
25
+ - MIT-LICENSE
26
+ - README.markdown
27
+ - Rakefile
28
+ - VERSION
29
+ - lib/extconf.rb
30
+ - lib/setlocale.c
31
+ - lib/setlocale.rb
32
+ - test/setlocale_test.rb
33
+ - test/test_helper.rb
34
+ has_rdoc: false
35
+ homepage: http://github.com/nanoant/setlocale
36
+ post_install_message:
37
+ rdoc_options:
38
+ - --charset=UTF-8
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ requirements: []
54
+
55
+ rubyforge_project:
56
+ rubygems_version: 1.2.0
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: POSIX locale natural language formatting for Ruby
60
+ test_files:
61
+ - test/setlocale_test.rb
62
+ - test/test_helper.rb