php_ruby 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5bc272150babc2d9b23d9cf862492c0a031519c4
4
+ data.tar.gz: 48dc99d04104b98b1b80fcb83038ca8dac6bde2e
5
+ SHA512:
6
+ metadata.gz: 88b461f4c2a5d6e36c2d9a6411cec5d9094b881ae5134c316f401d87c4bce5fed60a5d00bb5b7014805dc1a24a6efed167743da43967956cb1381346cb276540
7
+ data.tar.gz: 8270fedba35c85bae59eff0c29970105a328cd0d19dffc1d0bb32ca6c021417e840684dfbdac2c8419d062c8fb6934a2d63a95cd32700dcbce8a5a9512555a55
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.1.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in php.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Romeu Fonseca
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # PhpRuby
2
+ [![Build Status](https://travis-ci.org/romeuhcf/php-ruby-gem.svg?branch=master)](https://travis-ci.org/romeuhcf/php-ruby-gem)
3
+
4
+ TODO: Write a gem description
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'php_ruby'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install php_ruby
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+ soon
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it ( https://github.com/[my-github-username]/php/fork )
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+ RSpec::Core::RakeTask.new(:spec)
4
+ task :default => :spec
@@ -0,0 +1,26 @@
1
+ module PhpRuby
2
+ module Array
3
+ module Functions
4
+ extend self
5
+ def array_merge(*php_arrays)
6
+ result = Hash.new
7
+
8
+ php_arrays.each do |pa|
9
+ if pa.class == ::Hash
10
+ pa.each{ |index, item| result[index] = item}
11
+ elsif pa.class == ::Array
12
+ pa.each_with_index { |item, index| result[result.count] = item }
13
+ else
14
+ fail(ArgumentError.new("#{__method__} can't handle argument of type #{pa.class}"))
15
+ end
16
+ end
17
+
18
+ result
19
+ end
20
+
21
+ def explode(string, sep, count = 0)
22
+ string.split(sep, count)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,2 @@
1
+ require 'php_ruby/array/functions'
2
+ Kernel.send :include, PhpRuby::Array::Functions
@@ -0,0 +1,23 @@
1
+ module PhpRuby
2
+ module Io
3
+ module Functions
4
+ extend self
5
+ def echo(*args)
6
+ $stdout.write(args)
7
+ end
8
+
9
+ def print_r(*args)
10
+ pp(*args)
11
+ end
12
+
13
+ def sprintf(*args)
14
+ format, *tokens = *args
15
+ format % tokens
16
+ end
17
+
18
+ def file(fname)
19
+ IO.read(fname)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ require 'php_ruby/io/functions'
2
+ Kernel.send :include, PhpRuby::Io::Functions
3
+
@@ -0,0 +1,3 @@
1
+ module PhpRuby
2
+ VERSION = "0.0.2"
3
+ end
data/lib/php_ruby.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "php_ruby/version"
2
+
3
+ module PhpRuby
4
+ # Your code goes here...
5
+ end
data/php_ruby.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'php_ruby/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "php_ruby"
8
+ spec.version = PhpRuby::VERSION
9
+ spec.authors = ["Romeu Fonseca"]
10
+ spec.email = ["romeu.hcf@gmail.com"]
11
+ spec.summary = %q{PHP methods/function in pure Ruby.}
12
+ spec.description = %q{A port of main php functions to ruby methods to easy php to ruby code migration}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", ">= 1.6.0"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "simplecov"
24
+ spec.add_development_dependency "respec"
25
+ end
@@ -0,0 +1,251 @@
1
+ require 'spec_helper'
2
+ require 'php_ruby/array/functions'
3
+
4
+ describe PhpRuby::Array::Functions do
5
+
6
+ let (:integer_array) { [1,2,3,4] }
7
+ let (:string_array) { ['1','2','3','4'] }
8
+
9
+ describe '#array_change_key_case' do
10
+ end
11
+
12
+ describe '#array_chunk' do
13
+ end
14
+
15
+ describe '#array_column' do
16
+ end
17
+
18
+ describe '#array_combine' do
19
+ end
20
+
21
+ describe '#array_count_values' do
22
+ end
23
+
24
+ describe '#array_diff_assoc' do
25
+ end
26
+
27
+ describe '#array_diff_key' do
28
+ end
29
+
30
+ describe '#array_diff_uassoc' do
31
+ end
32
+
33
+ describe '#array_diff_ukey' do
34
+ end
35
+
36
+ describe '#array_diff' do
37
+ end
38
+
39
+ describe '#array_fill_keys' do
40
+ end
41
+
42
+ describe '#array_fill' do
43
+ end
44
+
45
+ describe '#array_filter' do
46
+ end
47
+
48
+ describe '#array_flip' do
49
+ end
50
+
51
+ describe '#array_intersect_assoc' do
52
+ end
53
+
54
+ describe '#array_intersect_key' do
55
+ end
56
+
57
+ describe '#array_intersect_uassoc' do
58
+ end
59
+
60
+ describe '#array_intersect_ukey' do
61
+ end
62
+
63
+ describe '#array_intersect' do
64
+ end
65
+
66
+ describe '#array_key_exists' do
67
+ end
68
+
69
+ describe '#array_keys' do
70
+ end
71
+
72
+ describe '#array_map' do
73
+ end
74
+
75
+ describe '#array_merge_recursive' do
76
+ end
77
+
78
+ describe '#array_merge' do
79
+ it { expect(subject.array_merge(integer_array, string_array)).to be_instance_of Hash}
80
+ it { expect(subject.array_merge(integer_array, string_array).keys).to eq [0,1,2,3,4,5,6,7]}
81
+ it { expect(subject.array_merge(integer_array, string_array).values).to eq [1, 2, 3, 4, '1', '2', '3', '4'] }
82
+ end
83
+
84
+ describe '#array_multisort' do
85
+ end
86
+
87
+ describe '#array_pad' do
88
+ end
89
+
90
+ describe '#array_pop' do
91
+ end
92
+
93
+ describe '#array_product' do
94
+ end
95
+
96
+ describe '#array_push' do
97
+ end
98
+
99
+ describe '#array_rand' do
100
+ end
101
+
102
+ describe '#array_reduce' do
103
+ end
104
+
105
+ describe '#array_replace_recursive' do
106
+ end
107
+
108
+ describe '#array_replace' do
109
+ end
110
+
111
+ describe '#array_reverse' do
112
+ end
113
+
114
+ describe '#array_search' do
115
+ end
116
+
117
+ describe '#array_shift' do
118
+ end
119
+
120
+ describe '#array_slice' do
121
+ end
122
+
123
+ describe '#array_splice' do
124
+ end
125
+
126
+ describe '#array_sum' do
127
+ end
128
+
129
+ describe '#array_udiff_assoc' do
130
+ end
131
+
132
+ describe '#array_udiff_uassoc' do
133
+ end
134
+
135
+ describe '#array_udiff' do
136
+ end
137
+
138
+ describe '#array_uintersect_assoc' do
139
+ end
140
+
141
+ describe '#array_uintersect_uassoc' do
142
+ end
143
+
144
+ describe '#array_uintersect' do
145
+ end
146
+
147
+ describe '#array_unique' do
148
+ end
149
+
150
+ describe '#array_unshift' do
151
+ end
152
+
153
+ describe '#array_values' do
154
+ end
155
+
156
+ describe '#array_walk_recursive' do
157
+ end
158
+
159
+ describe '#array_walk' do
160
+ end
161
+
162
+ describe '#array' do
163
+ end
164
+
165
+ describe '#arsort' do
166
+ end
167
+
168
+ describe '#asort' do
169
+ end
170
+
171
+ describe '#compact' do
172
+ end
173
+
174
+ describe '#count' do
175
+ end
176
+
177
+ describe '#current' do
178
+ end
179
+
180
+ describe '#each' do
181
+ end
182
+
183
+ describe '#extract' do
184
+ end
185
+
186
+ describe '#in_array' do
187
+ end
188
+
189
+ describe '#key_exists' do
190
+ end
191
+
192
+ describe '#key' do
193
+ end
194
+
195
+ describe '#krsort' do
196
+ end
197
+
198
+ describe '#ksort' do
199
+ end
200
+
201
+ describe '#list' do
202
+ end
203
+
204
+ describe '#natcasesort' do
205
+ end
206
+
207
+ describe '#natsort' do
208
+ end
209
+
210
+ describe '#next' do
211
+ end
212
+
213
+ describe '#pos' do
214
+ end
215
+
216
+ describe '#prev' do
217
+ end
218
+
219
+ describe '#range' do
220
+ end
221
+
222
+ describe '#reset' do
223
+ end
224
+
225
+ describe '#rsort' do
226
+ end
227
+
228
+ describe '#shuffle' do
229
+ end
230
+
231
+ describe '#sizeof' do
232
+ end
233
+
234
+ describe '#sort' do
235
+ end
236
+
237
+ describe '#uasort' do
238
+ end
239
+
240
+ describe '#uksort' do
241
+ end
242
+
243
+ describe '#usort' do
244
+ end
245
+
246
+ describe '#explode' do
247
+ it { expect(subject.explode('a:b:c:d:e', ':')).to be_instance_of Array }
248
+ it { expect(subject.explode('a:b:c:d:e', ':')).to eq %w{a b c d e} }
249
+ it { expect(subject.explode('a:b:c:d:e', ':', 3 )).to eq %w{a b c:d:e} }
250
+ end
251
+ end
@@ -0,0 +1,2 @@
1
+ i am
2
+ a simple file
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require 'php_ruby/io/functions'
3
+
4
+ describe PhpRuby::Io::Functions do
5
+
6
+ describe '#echo' do
7
+ it { expect{subject.echo(1,2,[])}.to_not raise_error }
8
+ end
9
+
10
+ describe '#print_r' do
11
+ it { expect{subject.print_r(1,2,[])}.to_not raise_error }
12
+ end
13
+
14
+ describe '#sprintf' do
15
+ it { expect(subject.sprintf("%0.3f %s", 0.0009, 'sec')).to eq "0.001 sec" }
16
+ end
17
+
18
+ describe '#file' do
19
+ it { expect(subject.file(fixture_file_path('simple.txt'))).to eq "i am \na simple file\n" }
20
+ end
21
+ end
@@ -0,0 +1,95 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
4
+ # file to always be loaded, without a need to explicitly require it in any files.
5
+ #
6
+ # Given that it is always loaded, you are encouraged to keep this file as
7
+ # light-weight as possible. Requiring heavyweight dependencies from this file
8
+ # will add to the boot time of your test suite on EVERY test run, even for an
9
+ # individual file that may not need all of that loaded. Instead, consider making
10
+ # a separate helper file that requires the additional dependencies and performs
11
+ # the additional setup, and require it from the spec files that actually need it.
12
+ #
13
+ require 'simplecov'
14
+ SimpleCov.start
15
+
16
+ # The `.rspec` file also contains a few flags that are not defaults but that
17
+ # users commonly want.
18
+ #
19
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
20
+ RSpec.configure do |config|
21
+ # rspec-expectations config goes here. You can use an alternate
22
+ # assertion/expectation library such as wrong or the stdlib/minitest
23
+ # assertions if you prefer.
24
+ config.expect_with :rspec do |expectations|
25
+ # This option will default to `true` in RSpec 4. It makes the `description`
26
+ # and `failure_message` of custom matchers include text for helper methods
27
+ # defined using `chain`, e.g.:
28
+ # be_bigger_than(2).and_smaller_than(4).description
29
+ # # => "be bigger than 2 and smaller than 4"
30
+ # ...rather than:
31
+ # # => "be bigger than 2"
32
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
33
+ end
34
+
35
+ # rspec-mocks config goes here. You can use an alternate test double
36
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
37
+ config.mock_with :rspec do |mocks|
38
+ # Prevents you from mocking or stubbing a method that does not exist on
39
+ # a real object. This is generally recommended, and will default to
40
+ # `true` in RSpec 4.
41
+ mocks.verify_partial_doubles = true
42
+ end
43
+
44
+ # The settings below are suggested to provide a good initial experience
45
+ # with RSpec, but feel free to customize to your heart's content.
46
+ =begin
47
+ # These two settings work together to allow you to limit a spec run
48
+ # to individual examples or groups you care about by tagging them with
49
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
50
+ # get run.
51
+ config.filter_run :focus
52
+ config.run_all_when_everything_filtered = true
53
+
54
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
55
+ # For more details, see:
56
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
57
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
58
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
59
+ config.disable_monkey_patching!
60
+
61
+ # This setting enables warnings. It's recommended, but in some cases may
62
+ # be too noisy due to issues in dependencies.
63
+ config.warnings = true
64
+
65
+ # Many RSpec users commonly either run the entire suite or an individual
66
+ # file, and it's useful to allow more verbose output when running an
67
+ # individual spec file.
68
+ if config.files_to_run.one?
69
+ # Use the documentation formatter for detailed output,
70
+ # unless a formatter has already been configured
71
+ # (e.g. via a command-line flag).
72
+ config.default_formatter = 'doc'
73
+ end
74
+
75
+ # Print the 10 slowest examples and example groups at the
76
+ # end of the spec run, to help surface which specs are running
77
+ # particularly slow.
78
+ config.profile_examples = 10
79
+
80
+ # Run specs in random order to surface order dependencies. If you find an
81
+ # order dependency and want to debug it, you can fix the order by providing
82
+ # the seed, which is printed after each run.
83
+ # --seed 1234
84
+ config.order = :random
85
+
86
+ # Seed global randomization in this process using the `--seed` CLI option.
87
+ # Setting this allows you to use `--seed` to deterministically reproduce
88
+ # test failures related to randomization by passing the same `--seed` value
89
+ # as the one that triggered the failure.
90
+ Kernel.srand config.seed
91
+ =end
92
+ end
93
+ def fixture_file_path(fname)
94
+ File.join(File.dirname(__FILE__), 'fixtures', fname)
95
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: php_ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Romeu Fonseca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: respec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: A port of main php functions to ruby methods to easy php to ruby code
70
+ migration
71
+ email:
72
+ - romeu.hcf@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE
82
+ - README.md
83
+ - Rakefile
84
+ - lib/php_ruby.rb
85
+ - lib/php_ruby/array.rb
86
+ - lib/php_ruby/array/functions.rb
87
+ - lib/php_ruby/io.rb
88
+ - lib/php_ruby/io/functions.rb
89
+ - lib/php_ruby/version.rb
90
+ - php_ruby.gemspec
91
+ - spec/array_functions_spec.rb
92
+ - spec/fixtures/simple.txt
93
+ - spec/io_functions_spec.rb
94
+ - spec/spec_helper.rb
95
+ homepage: ''
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.2.2
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: PHP methods/function in pure Ruby.
119
+ test_files:
120
+ - spec/array_functions_spec.rb
121
+ - spec/fixtures/simple.txt
122
+ - spec/io_functions_spec.rb
123
+ - spec/spec_helper.rb