fixtures 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.*~
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in fixtures.gemspec
4
+ gemspec
data/README.markdown ADDED
@@ -0,0 +1,14 @@
1
+ How to use
2
+ ======
3
+
4
+ need add line
5
+ **require 'fixtures/fixtures'**
6
+ in your environment.rb
7
+
8
+ **active_record_object.to_hash**
9
+ will convert object to hash
10
+
11
+
12
+
13
+ **active_record_object.to_fixtures**
14
+ will add fixtures to test/fixtures/table_name.yml
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/fixtures.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "fixtures/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "fixtures"
7
+ s.version = Fixtures::VERSION
8
+ s.authors = ["Dmitry Gruzd"]
9
+ s.email = ["donotsendhere@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{dump your model object to fixtures}
12
+ s.description = %q{now you can do object.to_fixtures and use in tests}
13
+
14
+ s.rubyforge_project = "fixtures"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
@@ -0,0 +1,28 @@
1
+ class ActiveRecord::Base
2
+
3
+ #require 'yaml'
4
+ require 'digest/md5'
5
+
6
+
7
+ def to_hash
8
+ hash = {}; self.attributes.each { |k,v| hash[k.to_sym] = v }
9
+ return hash
10
+ end
11
+
12
+ def to_fixtures
13
+ hash = self.to_hash
14
+ md5 = Digest::MD5.hexdigest(hash.to_s)
15
+ string = "#{md5}:\n"
16
+ hash.each do |key,value|
17
+ string += " #{key.to_s}: #{value}\n" unless value.nil?
18
+ end
19
+ string += "\n"
20
+ table_name = self.class.table_name
21
+ file_name = table_name + ".yml"
22
+ File.open("test/fixtures/#{file_name}", 'a') do |out|
23
+ out.write(string)
24
+ end
25
+ end
26
+
27
+
28
+ end
@@ -0,0 +1,3 @@
1
+ module Fixtures
2
+ VERSION = "0.0.1"
3
+ end
data/lib/fixtures.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "fixtures/version"
2
+
3
+ module Fixtures
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fixtures
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dmitry Gruzd
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-02 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: now you can do object.to_fixtures and use in tests
15
+ email:
16
+ - donotsendhere@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - README.markdown
24
+ - Rakefile
25
+ - fixtures.gemspec
26
+ - lib/fixtures.rb
27
+ - lib/fixtures/fixtures.rb
28
+ - lib/fixtures/version.rb
29
+ homepage: ''
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project: fixtures
49
+ rubygems_version: 1.8.17
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: dump your model object to fixtures
53
+ test_files: []