x 0.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of x might be problematic. Click here for more details.

Files changed (8) hide show
  1. data/.gitignore +2 -0
  2. data/README.md +27 -0
  3. data/Rakefile +12 -0
  4. data/VERSION +1 -0
  5. data/lib/x.rb +33 -0
  6. data/test/x_test.rb +18 -0
  7. data/x.gemspec +46 -0
  8. metadata +61 -0
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.swp
2
+ pkg
data/README.md ADDED
@@ -0,0 +1,27 @@
1
+ X
2
+ =
3
+
4
+ Ruby utilities.
5
+
6
+ sudo gem install x -s http://gemcutter.org
7
+
8
+ Converting
9
+ ----------
10
+
11
+ 'coca cola'.camel_case # 'CocaCola'
12
+ 'http://snake-case.com'.snake_case # 'http_snake_case_com'
13
+
14
+ Filing
15
+ ------
16
+
17
+ File.here # 'test'
18
+ File.up / 'lib' / 'x' # 'test/../lib/x'
19
+ File.up(2) / 'x' / 'README' # 'test/../../x/README'
20
+
21
+ Testing
22
+ -------
23
+
24
+ should "name" do
25
+ assert true
26
+ end
27
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require 'jeweler'
2
+
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "x"
5
+ gemspec.summary = "Ruby utilities."
6
+ gemspec.description = "Ruby utilities."
7
+ gemspec.email = "dcroak@thoughtbot.com"
8
+ gemspec.homepage = "http://github.com/dancroak/x"
9
+ gemspec.authors = ["Dan Croak"]
10
+ end
11
+
12
+ Jeweler::GemcutterTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
data/lib/x.rb ADDED
@@ -0,0 +1,33 @@
1
+ class String
2
+ def /(path)
3
+ File.join(self, path)
4
+ end
5
+
6
+ def camel_case
7
+ gsub(' ', '_').gsub(/(?:^|_)(.)/) { $1.upcase }
8
+ end
9
+
10
+ def snake_case
11
+ sub(/\W+/, "_").gsub('-', '_').gsub('.', '_').downcase
12
+ end
13
+ end
14
+
15
+ if defined?(Test::Unit::TestCase)
16
+ class Test::Unit::TestCase
17
+ def self.should(name, &block)
18
+ define_method("test_#{name.snake_case}", &block)
19
+ end
20
+ end
21
+ end
22
+
23
+ class File
24
+ def self.here
25
+ dirname(caller[0].split(':').first)
26
+ end
27
+
28
+ def self.up(dir_count = 1)
29
+ path = dirname(caller[0].split(':').first)
30
+ dir_count.times { path = path / '..' }
31
+ path
32
+ end
33
+ end
data/test/x_test.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'x')
3
+
4
+ class XTest < Test::Unit::TestCase
5
+ should "convert to camel case" do
6
+ assert_equal 'CocaCola', 'coca cola'.camel_case
7
+ end
8
+
9
+ should "convert to snake case" do
10
+ assert_equal 'http_snake_case_com', 'http://snake-case.com'.snake_case
11
+ end
12
+
13
+ should "join file paths" do
14
+ assert_equal 'test', File.here
15
+ assert_equal 'test/../lib/x', File.up / 'lib' / 'x'
16
+ assert_equal 'test/../../x/README', File.up(2) / 'x' / 'README'
17
+ end
18
+ end
data/x.gemspec ADDED
@@ -0,0 +1,46 @@
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{x}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dan Croak"]
12
+ s.date = %q{2009-11-08}
13
+ s.description = %q{Ruby utilities.}
14
+ s.email = %q{dcroak@thoughtbot.com}
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "README.md",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "lib/x.rb",
24
+ "test/x_test.rb",
25
+ "x.gemspec"
26
+ ]
27
+ s.homepage = %q{http://github.com/dancroak/x}
28
+ s.rdoc_options = ["--charset=UTF-8"]
29
+ s.require_paths = ["lib"]
30
+ s.rubygems_version = %q{1.3.5}
31
+ s.summary = %q{Ruby utilities.}
32
+ s.test_files = [
33
+ "test/x_test.rb"
34
+ ]
35
+
36
+ if s.respond_to? :specification_version then
37
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
41
+ else
42
+ end
43
+ else
44
+ end
45
+ end
46
+
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: x
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Dan Croak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-08 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Ruby utilities.
17
+ email: dcroak@thoughtbot.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.md
24
+ files:
25
+ - .gitignore
26
+ - README.md
27
+ - Rakefile
28
+ - VERSION
29
+ - lib/x.rb
30
+ - test/x_test.rb
31
+ - x.gemspec
32
+ has_rdoc: true
33
+ homepage: http://github.com/dancroak/x
34
+ licenses: []
35
+
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.3.5
57
+ signing_key:
58
+ specification_version: 3
59
+ summary: Ruby utilities.
60
+ test_files:
61
+ - test/x_test.rb