railstar 0.0.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.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 [name of plugin creator]
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.
data/README.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ = Railstar
2
+
3
+ 2009/06/24 svnから最低限のものだけコピー
4
+
5
+ Copyright (c) 2009 [RAWHIDE.], released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the railstar plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the railstar plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'Railstar'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
24
+
25
+
26
+ begin
27
+ require 'jeweler'
28
+ Jeweler::Tasks.new do |gemspec|
29
+ gemspec.name = "railstar"
30
+ gemspec.summary = "railstar is a core plugin for RAWHIDE."
31
+ gemspec.email = "yoshimi@raw-hide.co.jp"
32
+ gemspec.homepage = "http://github.com/yosm/railstar"
33
+ # gemspec.description = "TODO"
34
+ gemspec.authors = ["Kazuya Yoshimi"]
35
+ end
36
+ rescue LoadError
37
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
38
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,16 @@
1
+ class DbmasterGenerator < Rails::Generator::Base
2
+ def initialize(runtime_args, runtime_options = {})
3
+ Dir.mkdir("lib/tasks") unless File.directory?("lib/tasks")
4
+ super
5
+ end
6
+
7
+ def manifest
8
+ record do |m|
9
+ m.directory 'lib/tasks'
10
+ m.file 'dbmaster.rake', 'lib/tasks/dbmaster.rake'
11
+
12
+ m.directory 'lib'
13
+ m.file 'load_masters.rb', 'lib/load_masters.rb'
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ namespace :db do
2
+ namespace :master do
3
+ desc "Load master data from/master/*.yml"
4
+ task :load => :environment do |t, arg|
5
+ puts "\n=== Loading YAML ..."
6
+ require "load_masters.rb"
7
+ MasterLoader.run
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- coding: utf-8 -*-
3
+
4
+ unless defined? __DIR__
5
+ def __DIR__
6
+ filename = caller[0][/^(.*):/, 1]
7
+ File.expand_path(File.dirname(filename))
8
+ end
9
+ end
10
+ #puts fixture_dir
11
+ def fixture_dir
12
+ File.expand_path("../db/master", __DIR__)
13
+ end
14
+
15
+ class MasterLoader
16
+ class << self
17
+ def run
18
+ Dir::glob(fixture_dir + "/*.yml").each do |file|
19
+ klass_name = File::basename(file, '.yml')
20
+ run_class(klass_name)
21
+ end
22
+ end
23
+
24
+ def run_class(klass_name)
25
+ file = File.join(fixture_dir, klass_name + '.yml')
26
+ klass_name = klass_name.classify
27
+
28
+ puts "\t loading from #{File::basename(file)} via #{klass_name}"
29
+ klass = eval(klass_name)
30
+ rawdata = File.read(file)
31
+ records = YAML::load(rawdata)
32
+ klass.delete_all
33
+ records.each do |rec|
34
+ copied = klass.new(rec[1])
35
+ copied.id = rec[1]["id"]
36
+ copied.save
37
+ end
38
+ end
39
+ end
40
+
41
+ end
@@ -0,0 +1,44 @@
1
+ class Twitter < ActiveResource::Base
2
+ self.user = ''
3
+ self.password = ''
4
+
5
+ self.site = "http://#{self.user}:#{self.password}@twitter.com/"
6
+ self.logger = Logger.new($stdout)
7
+
8
+ class Status < Twitter
9
+ end
10
+
11
+ class Follower < Twitter
12
+ def self.ids(id=self.user)
13
+ # 5000件しか取得しないので、それ以上のFollowersも考慮するならpageオプションを仕様すること。
14
+ # 詳細はTwitterAPI参照
15
+ begin
16
+ followers = self.get(:ids, :id => id)
17
+ followers.blank? ? followers : followers.first.second.map{|id| id.to_i}
18
+ rescue ActiveResource::ResourceNotFound
19
+ []
20
+ end
21
+ end
22
+ end
23
+
24
+ class User < Twitter
25
+ attr_accessor :name, :icon, :location, :url, :description, :screen_name, :friends_count, :followers_count, :created_at
26
+
27
+ def initialize(id=self.user)
28
+ result = User.get(:show, :id => id)
29
+ @name = result["name"]
30
+ @icon = result["profile_image_url"]
31
+ @location = result["location"]
32
+ @url = result["url"]
33
+ @description = result["description"]
34
+ @screen_name = result["screen_name"]
35
+ @followers_count = result["followers_count"]
36
+ @friends_count = result["friends_count"]
37
+ begin
38
+ @created_at = Date.strptime(result["created_at"], "%a %b %d %T %z %Y")
39
+ rescue
40
+ @created_at = nil
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,13 @@
1
+ class TwitterGenerator < Rails::Generator::Base
2
+ def initialize(runtime_args, runtime_options = {})
3
+ Dir.mkdir("app/models") unless File.directory?("app/models")
4
+ super
5
+ end
6
+
7
+ def manifest
8
+ record do |m|
9
+ m.directory 'app/models'
10
+ m.file 'twitter.rb', 'app/models/twitter.rb'
11
+ end
12
+ end
13
+ end
data/init.rb ADDED
@@ -0,0 +1,5 @@
1
+ require File.dirname(__FILE__) + '/lib/railstar'
2
+
3
+ require 'railstar_helper'
4
+ ActionView::Base.send(:include, RailstarHelper)
5
+
data/install.rb ADDED
@@ -0,0 +1,3 @@
1
+ FileUtils.copy(File.join(RAILS_ROOT, 'vendor', 'plugins', 'railstar', 'railstar_config.yml'), File.join(RAILS_ROOT, 'config'))
2
+
3
+ puts "set config/railstar_config.yml"
data/lib/railstar.rb ADDED
@@ -0,0 +1 @@
1
+ RAILSTAR_ENV = YAML.load_file(File.join(RAILS_ROOT, 'config', 'railstar_config.yml'))[RAILS_ENV]
@@ -0,0 +1,47 @@
1
+ module RailstarHelper
2
+ def title(page_title)
3
+ content_for(:title) { page_title }
4
+ end
5
+
6
+ def stylesheet(*css)
7
+ content_for(:head) { stylesheet_link_tag(*css) }
8
+ end
9
+
10
+ def javascript(*js)
11
+ content_for(:head) { javascript_include_tag(*js) }
12
+ end
13
+
14
+ def auto_discovery_rss(rss)
15
+ content_for(:head) do
16
+ %Q(<link rel="alternate" type="application/rss+xml" href="#{rss}" title="RSS 2.0" />)
17
+ end
18
+ end
19
+
20
+ def hbr(str)
21
+ str = html_escape(str)
22
+ br(str)
23
+ end
24
+
25
+ def br(str)
26
+ str.gsub(/\r\n|\r|\n/, "<br />")
27
+ end
28
+
29
+ def url2link(str)
30
+ str.gsub(/(https?:\/\/[-_.!~*'()a-zA-Z0-9;\/?:@&=+$,%#]+)/){"<a href='#{$1}'>#{$1}</a>"}
31
+ end
32
+
33
+ def params_to_hidden_tag(object, options={})
34
+ p = params[object]
35
+ str = ""
36
+ str << hidden_field_tag('back', 1) if options[:back]
37
+ return str unless p
38
+ p.each do |method,value|
39
+ if options[:except] && options[:except].include?(method.to_sym)
40
+ else
41
+ str << hidden_field(object,method, :value => p[method])
42
+ end
43
+ end
44
+ str
45
+ end
46
+ end
47
+
@@ -0,0 +1,14 @@
1
+ common: &common
2
+ product_name: railstar
3
+
4
+ development:
5
+ <<: *common
6
+ base_url: "http://localhost:3000"
7
+
8
+ test:
9
+ <<: *common
10
+ base_url: "http://localhost:3000"
11
+
12
+ production:
13
+ <<: *common
14
+ base_url: "http://railstar.org"
@@ -0,0 +1,16 @@
1
+ require './lib/railstar_helper'
2
+ require 'erb'
3
+ include RailstarHelper
4
+ include ERB::Util
5
+
6
+
7
+ describe RailstarHelper do
8
+ it '改行コードをBRタグに変換できること' do
9
+ text = <<-EOF
10
+ abcd
11
+ efghi
12
+ jklm
13
+ EOF
14
+ hbr(text).should == "abcd<br />efghi<br />jklm<br />"
15
+ end
16
+ end
File without changes
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :railstar do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class RailstarTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railstar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Kazuya Yoshimi
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-02-11 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: yoshimi@raw-hide.co.jp
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - MIT-LICENSE
26
+ - README.rdoc
27
+ - Rakefile
28
+ - VERSION
29
+ - generators/dbmaster/dbmaster_generator.rb
30
+ - generators/dbmaster/templates/dbmaster.rake
31
+ - generators/dbmaster/templates/load_masters.rb
32
+ - generators/twitter/templates/twitter.rb
33
+ - generators/twitter/twitter_generator.rb
34
+ - init.rb
35
+ - install.rb
36
+ - lib/railstar.rb
37
+ - lib/railstar_helper.rb
38
+ - railstar_config.yml
39
+ - spec/railstar_helper_spec.rb
40
+ - spec/spec_helper.rb
41
+ - tasks/railstar_tasks.rake
42
+ - test/railstar_test.rb
43
+ - test/test_helper.rb
44
+ - uninstall.rb
45
+ has_rdoc: true
46
+ homepage: http://github.com/yosm/railstar
47
+ licenses: []
48
+
49
+ post_install_message:
50
+ rdoc_options:
51
+ - --charset=UTF-8
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project:
69
+ rubygems_version: 1.3.5
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: railstar is a core plugin for RAWHIDE.
73
+ test_files:
74
+ - spec/railstar_helper_spec.rb
75
+ - spec/spec_helper.rb
76
+ - test/railstar_test.rb
77
+ - test/test_helper.rb