swing 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ log
21
+ .idea
22
+ .bundle
23
+
24
+ ## PROJECT::SPECIFIC
data/HISTORY ADDED
@@ -0,0 +1,7 @@
1
+ == 0.0.0 / 2011-05-21
2
+
3
+ * Birthday!
4
+
5
+ == 0.0.1 / 2011-05-21
6
+
7
+ * Initial draft
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Arvicco
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,34 @@
1
+ = swing
2
+ by: Arvicco
3
+ url: http://github.com/arvicco/swing
4
+
5
+ == DESCRIPTION:
6
+
7
+ Straightforward wrappers for javax.swing Components that simplify Swing code in
8
+ JRuby-based GUI applications.
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * Library defines Ruby wrapper classes for Swing components that do NOT shadow original
13
+ javax.swing classes. So, javax.swing.JButton class is wrapped by Swing::Button class,
14
+ and you need to <b> require 'swing/button' </b> to use it.
15
+ * Ruby wrappers define properties that are settable in constructor options, as well
16
+ as (optional) defaults for them that may be different from swing's original defaults:
17
+ Swing::Button.new 'Title', :enabled => false
18
+ *
19
+
20
+ == SYNOPSIS:
21
+
22
+ FIXME (code sample of usage)
23
+
24
+ == REQUIREMENTS:
25
+
26
+ * FIXME (list of requirements)
27
+
28
+ == INSTALL:
29
+
30
+ $ sudo gem install swing
31
+
32
+ == LICENSE:
33
+
34
+ Copyright (c) 2011 Arvicco. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ begin
2
+ require 'rake'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ gem 'rake', '~> 0.8.3.1'
6
+ require 'rake'
7
+ end
8
+
9
+ require 'pathname'
10
+
11
+ BASE_PATH = Pathname.new(__FILE__).dirname
12
+ LIB_PATH = BASE_PATH + 'lib'
13
+ PKG_PATH = BASE_PATH + 'pkg'
14
+ DOC_PATH = BASE_PATH + 'rdoc'
15
+
16
+ $LOAD_PATH.unshift LIB_PATH.to_s
17
+ require 'version'
18
+
19
+ NAME = 'swing'
20
+ CLASS_NAME = Swing
21
+
22
+ # Load rakefile tasks
23
+ Dir['tasks/*.rake'].sort.each { |file| load file }
24
+
25
+ # Project-specific tasks
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/swing ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+
4
+ require 'pathname'
5
+ lib = (Pathname.new(__FILE__).dirname + '../lib').expand_path.to_s
6
+ $:.unshift lib unless $:.include?(lib)
7
+
8
+ require 'swing'
9
+
10
+ # Put your code here
11
+
12
+
13
+
File without changes
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+
3
+ require 'pathname'
4
+ require 'bundler'
5
+ Bundler.setup
6
+ Bundler.require :cucumber
7
+
8
+ require 'swing'
9
+
10
+ BASE_PATH = Pathname.new(__FILE__).dirname + '../..'
@@ -0,0 +1,12 @@
1
+ module SystemHelper
2
+
3
+ def windows?
4
+ RUBY_PLATFORM =~ /mswin|windows|mingw/ || cygwin?
5
+ end
6
+
7
+ def cygwin?
8
+ RUBY_PLATFORM =~ /cygwin/
9
+ end
10
+ end
11
+
12
+ World(WinGui, SystemHelper)
@@ -0,0 +1,9 @@
1
+ Feature: something something
2
+ In order to something something
3
+ A user something something
4
+ something something something
5
+
6
+ Scenario: something something
7
+ Given inspiration
8
+ When I create a sweet new gem
9
+ Then everyone should see how awesome I am
@@ -0,0 +1,22 @@
1
+ include Java
2
+
3
+ module Clients
4
+
5
+ module SwingGui
6
+ # Class that implements ActionListener interface around a given block
7
+ class ActionListener
8
+ java_implements java.awt.event.ActionListener
9
+
10
+ def initialize &block
11
+ @action_block = block
12
+ end
13
+
14
+ java_signature 'public void actionPerformed(ActionEvent event)'
15
+ # from ActionListener interface: Invoked when an action event occurs.
16
+ def actionPerformed event
17
+ @action_block.call event
18
+ end
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,73 @@
1
+ include Java
2
+
3
+ import java.awt.Dimension
4
+
5
+ # Module allows including classes to receive attribute values in an *opts* Hash
6
+ # and sets those attributes after object initialization
7
+ module AttrSetter
8
+ def self.dim_proc default = nil
9
+ proc do |*args|
10
+ case args.size
11
+ when 2
12
+ Dimension.new *args
13
+ when 1
14
+ case args.first
15
+ when Dimension
16
+ args.first
17
+ when String
18
+ Dimension.new *args.first.split(/x|-|:/, 2)
19
+ end
20
+ when 0
21
+ Dimension.new *default unless default.nil?
22
+ end
23
+ end
24
+ end
25
+
26
+ def self.included host
27
+ host.send :extend, ClassMethods
28
+ host.attr_setter :font,
29
+ :tool_tip_text,
30
+ :preferred_size => dim_proc,
31
+ :minimum_size => dim_proc,
32
+ :maximum_size => dim_proc
33
+ end
34
+
35
+ module ClassMethods
36
+ def attributes
37
+ @attributes ||= (superclass.attributes.dup rescue {})
38
+ end
39
+
40
+ # Adds settable attributes for a given class, possibly with defaults
41
+ # If defaults are given for attributes, they should be put at the end (as opts)
42
+ def attr_setter *new_attributes
43
+ if new_attributes.last.is_a? Hash
44
+ # Some attributes are given with defaults
45
+ new_attributes_with_defaults = new_attributes.pop
46
+ new_attributes_with_defaults.each { |name, default| attributes[name] = default }
47
+ end
48
+ new_attributes.each { |name| attributes[name] = nil }
49
+ end
50
+ end
51
+
52
+ # Sets attributes after yielding to a given block (usually to call super).
53
+ # Use this method to wrap super call to *ORIGINAL* J... object, exactly
54
+ # once per each derived view hierarchy. TODO: better way?
55
+ #
56
+ def set_attributes opts
57
+ # Extract known attributes given in opts, to be set after object initialization
58
+ attributes = self.class.attributes.map do |name, default|
59
+ value = opts.delete name
60
+ result = if default.nil? # No default, return whatever value
61
+ value
62
+ elsif default.respond_to? :call # Default is callable, call it with whatever value
63
+ default.call *value
64
+ else # Return either non-nil value or default
65
+ value.nil? ? default : value
66
+ end
67
+ [name, result] if result
68
+ end.compact
69
+ yield opts if block_given?
70
+ attributes.each { |(name, value)| send "#{name}=", *value }
71
+ end
72
+ end
73
+
@@ -0,0 +1,47 @@
1
+ require 'swing/action_listener'
2
+ require 'swing/attr_setter'
3
+
4
+ module Clients
5
+
6
+ # Swing-based GUI controls
7
+ module SwingGui
8
+
9
+ class Button < javax.swing.JButton
10
+ include AttrSetter
11
+
12
+ attr_setter :enabled
13
+
14
+ def initialize text, opts = {}, &block
15
+ set_attributes(opts) { super(text) }
16
+
17
+ self.addActionListener ActionListener.new &block
18
+
19
+ opts[:parent].add self if opts[:parent]
20
+ end
21
+ end # class Button
22
+
23
+ class CheckBox < javax.swing.JCheckBox
24
+ include AttrSetter
25
+
26
+ attr_setter :selected
27
+
28
+ def initialize text, opts = {}, &block
29
+ set_attributes(opts) { super(text) }
30
+
31
+ # TODO: Probably need to implement ItemListener as well?
32
+ self.addActionListener ActionListener.new &block
33
+
34
+ opts[:parent].add self if opts[:parent]
35
+ end
36
+ end # class CheckBox
37
+
38
+ class Label < javax.swing.JLabel
39
+ include AttrSetter
40
+
41
+ def initialize text, opts = {}, &block
42
+ set_attributes(opts) { super(text) }
43
+ opts[:parent].add self if opts[:parent]
44
+ end
45
+ end # class Label
46
+ end
47
+ end
@@ -0,0 +1,33 @@
1
+ require 'swing/attr_setter'
2
+
3
+ import javax.swing.JFrame
4
+
5
+ module Clients
6
+
7
+ # Swing-based GUI controls
8
+ module SwingGui
9
+
10
+ class Frame < JFrame
11
+ include AttrSetter
12
+
13
+ attr_setter :layout, :background, :size, :title,
14
+ :default_close_operation => JFrame::EXIT_ON_CLOSE #DISPOSE_ON_CLOSE, HIDE_ON_CLOSE
15
+
16
+ def initialize name, opts = {}
17
+
18
+ set_attributes(opts) { super(name) }
19
+
20
+ setup opts
21
+
22
+ self.location_relative_to = nil
23
+ self.visible = true
24
+ end
25
+
26
+ # Method that subclasses should override to set up their contents before
27
+ # Frame is made visible
28
+ def setup opts
29
+ end
30
+ end
31
+ end
32
+ end
33
+
data/lib/swing/list.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'swing/attr_setter'
2
+
3
+ module Clients
4
+
5
+ # Swing-based GUI controls
6
+ module SwingGui
7
+
8
+ class List < javax.swing.JList
9
+ include AttrSetter
10
+
11
+ def initialize model, opts = {}
12
+ set_attributes(opts) {super(model)}
13
+
14
+ opts[:parent].add self if opts[:parent]
15
+ end
16
+ end # class List
17
+
18
+ end
19
+ end
@@ -0,0 +1,55 @@
1
+ require 'swing/action_listener'
2
+ require 'swing/attr_setter'
3
+
4
+ module Clients
5
+
6
+ # Swing-based Menu elements
7
+ module SwingGui
8
+
9
+ class MenuBar < javax.swing.JMenuBar
10
+ include AttrSetter
11
+
12
+ def initialize opts = {}
13
+ set_attributes(opts) { super() }
14
+
15
+ if opts[:structure]
16
+ [opts[:structure]].flatten.each do |element|
17
+ case element
18
+ when Hash # Hash defines menu structure
19
+ element.each do |menu_name, menu_structure|
20
+ menu = Menu.new menu_name.to_s, :parent => self
21
+ menu_structure.each do |item_name, item_action|
22
+ MenuItem.new item_name.to_s, :parent => menu, &item_action
23
+ end
24
+ end
25
+ else
26
+ self.add element
27
+ end
28
+ end
29
+ end
30
+ opts[:parent].setJMenuBar self if opts[:parent]
31
+ end
32
+ end
33
+
34
+ class Menu < javax.swing.JMenu
35
+ include AttrSetter
36
+
37
+ def initialize text, opts = {}
38
+ set_attributes(opts) { super text }
39
+ opts[:parent].add self if opts[:parent]
40
+ end
41
+ end
42
+
43
+ class MenuItem < javax.swing.JMenuItem
44
+ include AttrSetter
45
+
46
+ def initialize text, opts = {}, &block
47
+ set_attributes(opts) { super text }
48
+ self.addActionListener ActionListener.new &block
49
+ opts[:parent].add self if opts[:parent]
50
+ end
51
+ end
52
+
53
+ end
54
+ end
55
+
@@ -0,0 +1,21 @@
1
+ require 'swing/attr_setter'
2
+
3
+ module Clients
4
+
5
+ # Swing-based GUI controls
6
+ module SwingGui
7
+
8
+ class Panel < javax.swing.JPanel
9
+ include AttrSetter
10
+
11
+ attr_setter :layout, :background
12
+
13
+ def initialize opts = {}
14
+ set_attributes(opts) {super()}
15
+
16
+ opts[:parent].add self if opts[:parent]
17
+ end
18
+ end # class Panel
19
+
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ require 'swing/attr_setter'
2
+
3
+ module Clients
4
+
5
+ # Swing-based GUI controls
6
+ module SwingGui
7
+
8
+ # Scroll Pane around given scrollable component
9
+ class ScrollPane < javax.swing.JScrollPane
10
+ include AttrSetter
11
+
12
+ attr_setter :horizontal_scroll_bar_policy, :vertical_scroll_bar_policy
13
+
14
+ def initialize component, opts = {}
15
+ set_attributes(opts) { super(component) }
16
+
17
+ opts[:parent].add self if opts[:parent]
18
+ end
19
+ end # class Panel
20
+
21
+ end
22
+ end
@@ -0,0 +1,23 @@
1
+ require 'swing/attr_setter'
2
+ import javax.swing.JSplitPane
3
+
4
+ module Clients
5
+
6
+ # Swing-based GUI controls
7
+ module SwingGui
8
+
9
+ class SplitPane < JSplitPane
10
+ include AttrSetter
11
+
12
+ attr_setter :one_touch_expandable, :orientation, :continuous_layout,
13
+ :divider_size, :divider_location, :resize_weight
14
+
15
+ def initialize first, second, opts = {}
16
+ set_attributes(opts) { super(JSplitPane::HORIZONTAL_SPLIT, first, second) }
17
+
18
+ opts[:parent].add self if opts[:parent]
19
+ end
20
+ end # class Panel
21
+
22
+ end
23
+ end
@@ -0,0 +1,65 @@
1
+ require 'swing/attr_setter'
2
+
3
+ module Clients
4
+
5
+ # Swing-based GUI controls
6
+ module SwingGui
7
+
8
+ class Table < javax.swing.JTable
9
+ include AttrSetter
10
+
11
+ # autoCreateColumnsFromModel boolean � � false
12
+ # autoResizeMode int � � AUTO_RESIZE_ALL_COLUMNS
13
+ # columnModel TableColumnModel � � DefaultTableColumnModel( )
14
+ # model TableModel � � DefaultTableModel( )
15
+ # rowHeight int � � 16
16
+ # cellSelectionEnabled boolean � � false
17
+ # columnSelectionAllowed boolean � � false
18
+ # rowSelectionAllowed boolean � � true
19
+ # selectionMode int � MULTIPLE_INTERVAL_SELECTION
20
+ # selectionModel ListSelectionModel � � DefaultListSelectionModel
21
+ # cellEditor TableCellEditor � � null
22
+ # dragEnabled boolean � � false
23
+ # gridColor Color � � From L&F
24
+ # intercellSpacing Dimension � � Dimension(1, 1)
25
+ # preferredScrollableViewportSize Dimension � � Dimension(450, 400)
26
+ # rowMargin int � � 1
27
+ # selectionBackground Color � � From L&F
28
+ # selectionForeground Color � � From L&F
29
+ # showGrid boolean � true
30
+ # showHorizontalLines boolean � � true
31
+ # showVerticalLines boolean � � true
32
+ # tableHeader JTableHeader � � JTableHeader(column-Model)
33
+ # ----Getters only - NO Setters!
34
+ # columnCount int � 0
35
+ # rowCount int � 0
36
+ # selectedColumn int � -1
37
+ # selectedColumnCount int � 0
38
+ # selectedColumns int[] � int[0]
39
+ # selectedRow int � -1
40
+ # selectedRowCount int � 0
41
+ # selectedRows int[] � int[0]
42
+ # accessibleContext AccessibleContext � JTable.AccessibleJTable
43
+ # scrollableTracksViewportHeighto boolean � false
44
+ # scrollableTracksViewportWidtho boolean � false
45
+
46
+ attr_setter :auto_create_columns_from_model, :auto_resize_mode, :row_height,
47
+ :model, :column_model, :selection_model,
48
+ :drag_enabled, :cell_editor, :grid_color, :intercell_spacing,
49
+ :preferred_scrollable_viewport_size, :row_margin,
50
+ :selection_background, :selection_foreground, :show_grid,
51
+ :show_horizontal_lines, :show_vertical_lines, :table_header,
52
+ :selection_mode => javax.swing.ListSelectionModel::SINGLE_SELECTION,
53
+ :cell_selection_enabled => true,
54
+ :row_selection_allowed => false,
55
+ :column_selection_allowed => false
56
+
57
+ def initialize rows, columns, opts = {}
58
+ set_attributes(opts) { super rows, columns }
59
+
60
+ opts[:parent].add self if opts[:parent]
61
+ end
62
+ end # class Table
63
+
64
+ end
65
+ end
data/lib/swing.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'version'
2
+ require 'rubygems'
3
+
4
+ module Swing
5
+
6
+ # Requires ruby source file(s), given as single filename/glob or Array of filenames/globs.
7
+ # Accepts following options:
8
+ # :*file*:: Lib(s) required relative to this file - defaults to __FILE__
9
+ # :*dir*:: Required lib(s) located under this dir name - defaults to gem name
10
+ #
11
+ def self.require_libs( libs, opts={} )
12
+ file = Pathname.new(opts[:file] || __FILE__)
13
+ [libs].flatten.each do |lib|
14
+ name = file.dirname + (opts[:dir] || file.basename('.*')) + lib.gsub(/(?<!.rb)$/, '.rb')
15
+ Pathname.glob(name.to_s).sort.each {|rb| require rb}
16
+ end
17
+ end
18
+ end # module Swing
19
+
20
+ # Require all ruby source files located under directory lib/swing
21
+ # If you need files in specific order, you should specify it here before the glob
22
+ Swing.require_libs %W[**/*]
23
+
data/lib/version.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'pathname'
2
+
3
+ module Swing
4
+
5
+ VERSION_FILE = Pathname.new(__FILE__).dirname + '../VERSION' # :nodoc:
6
+ VERSION = VERSION_FILE.exist? ? VERSION_FILE.read.strip : nil
7
+
8
+ end
@@ -0,0 +1,21 @@
1
+ require 'swing'
2
+ require 'pathname'
3
+
4
+ require 'bundler'
5
+ Bundler.setup
6
+ Bundler.require :test
7
+
8
+ BASE_PATH = Pathname.new(__FILE__).dirname + '..'
9
+
10
+ RSpec.configure do |config|
11
+ # config.exclusion_filter = { :slow => true }
12
+ # config.filter = { :focus => true }
13
+ # config.include(UserExampleHelpers)
14
+ # config.mock_with :mocha
15
+ # config.mock_with :flexmock
16
+ # config.mock_with :rr
17
+ end
18
+
19
+ module SwingTest
20
+
21
+ end # module SwingTest
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ module SwingTest
4
+ describe Swing do
5
+ end
6
+ end # module SwingTest
7
+
data/tasks/common.rake ADDED
@@ -0,0 +1,18 @@
1
+ #task :default => 'test:run'
2
+ #task 'gem:release' => 'test:run'
3
+
4
+ task :notes do
5
+ puts 'Output annotations (TBD)'
6
+ end
7
+
8
+ #Bundler not ready for prime time just yet
9
+ #desc 'Bundle dependencies'
10
+ #task :bundle do
11
+ # output = `bundle check 2>&1`
12
+ #
13
+ # unless $?.to_i == 0
14
+ # puts output
15
+ # system "bundle install"
16
+ # puts
17
+ # end
18
+ #end
data/tasks/doc.rake ADDED
@@ -0,0 +1,14 @@
1
+ desc 'Alias to doc:rdoc'
2
+ task :doc => 'doc:rdoc'
3
+
4
+ namespace :doc do
5
+ require 'rake/rdoctask'
6
+ Rake::RDocTask.new do |rdoc|
7
+ # Rake::RDocTask.new(:rdoc => "rdoc", :clobber_rdoc => "clobber", :rerdoc => "rerdoc") do |rdoc|
8
+ rdoc.rdoc_dir = DOC_PATH.basename.to_s
9
+ rdoc.title = "#{NAME} #{CLASS_NAME::VERSION} Documentation"
10
+ rdoc.main = "README.doc"
11
+ rdoc.rdoc_files.include('README*')
12
+ rdoc.rdoc_files.include('lib/**/*.rb')
13
+ end
14
+ end
data/tasks/gem.rake ADDED
@@ -0,0 +1,40 @@
1
+ desc "Alias to gem:release"
2
+ task :release => 'gem:release'
3
+
4
+ desc "Alias to gem:install"
5
+ task :install => 'gem:install'
6
+
7
+ desc "Alias to gem:build"
8
+ task :gem => 'gem:build'
9
+
10
+ namespace :gem do
11
+ gem_file = "#{NAME}-#{CLASS_NAME::VERSION}.gem"
12
+
13
+ desc "(Re-)Build gem"
14
+ task :build do
15
+ puts "Remove existing gem package"
16
+ rm_rf PKG_PATH
17
+ puts "Build new gem package"
18
+ system "gem build #{NAME}.gemspec"
19
+ puts "Move built gem to package dir"
20
+ mkdir_p PKG_PATH
21
+ mv gem_file, PKG_PATH
22
+ end
23
+
24
+ desc "Cleanup already installed gem(s)"
25
+ task :cleanup do
26
+ puts "Cleaning up installed gem(s)"
27
+ system "gem cleanup #{NAME}"
28
+ end
29
+
30
+ desc "Build and install gem"
31
+ task :install => :build do
32
+ system "gem install #{PKG_PATH}/#{gem_file}"
33
+ end
34
+
35
+ desc "Build and push gem to Gemcutter"
36
+ task :release => [:build, 'git:tag'] do
37
+ puts "Pushing gem to Gemcutter"
38
+ system "gem push #{PKG_PATH}/#{gem_file}"
39
+ end
40
+ end
data/tasks/git.rake ADDED
@@ -0,0 +1,34 @@
1
+ desc "Alias to git:commit"
2
+ task :git => 'git:commit'
3
+
4
+ namespace :git do
5
+
6
+ desc "Stage and commit your work [with message]"
7
+ task :commit, [:message] do |t, args|
8
+ puts "Staging new (unversioned) files"
9
+ system "git add --all"
10
+ if args.message
11
+ puts "Committing with message: #{args.message}"
12
+ system %Q[git commit -a -m "#{args.message}" --author arvicco]
13
+ else
14
+ puts "Committing"
15
+ system %Q[git commit -a -m "No message" --author arvicco]
16
+ end
17
+ end
18
+
19
+ desc "Push local changes to Github"
20
+ task :push => :commit do
21
+ puts "Pushing local changes to remote"
22
+ system "git push"
23
+ end
24
+
25
+ desc "Create (release) tag on Github"
26
+ task :tag => :push do
27
+ tag = CLASS_NAME::VERSION
28
+ puts "Creating git tag: #{tag}"
29
+ system %Q{git tag -a -m "Release tag #{tag}" #{tag}}
30
+ puts "Pushing #{tag} to remote"
31
+ system "git push origin #{tag}"
32
+ end
33
+
34
+ end
data/tasks/spec.rake ADDED
@@ -0,0 +1,16 @@
1
+ desc 'Alias to spec:spec'
2
+ task :spec => 'spec:spec'
3
+
4
+ namespace :spec do
5
+ # require 'spec/rake/spectask'
6
+ require 'rspec/core/rake_task'
7
+
8
+ desc "Run all specs"
9
+ RSpec::Core::RakeTask.new(:spec){|task|}
10
+
11
+ desc "Run specs with RCov"
12
+ RSpec::Core::RakeTask.new(:rcov) do |task|
13
+ task.rcov = true
14
+ task.rcov_opts = ['--exclude', 'spec']
15
+ end
16
+ end
@@ -0,0 +1,71 @@
1
+ class Version
2
+ attr_accessor :major, :minor, :patch, :build
3
+
4
+ def initialize(version_string)
5
+ raise "Invalid version #{version_string}" unless version_string =~ /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/
6
+ @major = $1.to_i
7
+ @minor = $2.to_i
8
+ @patch = $3.to_i
9
+ @build = $4
10
+ end
11
+
12
+ def bump_major(x)
13
+ @major += x.to_i
14
+ @minor = 0
15
+ @patch = 0
16
+ @build = nil
17
+ end
18
+
19
+ def bump_minor(x)
20
+ @minor += x.to_i
21
+ @patch = 0
22
+ @build = nil
23
+ end
24
+
25
+ def bump_patch(x)
26
+ @patch += x.to_i
27
+ @build = nil
28
+ end
29
+
30
+ def update(major, minor, patch, build=nil)
31
+ @major = major
32
+ @minor = minor
33
+ @patch = patch
34
+ @build = build
35
+ end
36
+
37
+ def write(desc = nil)
38
+ CLASS_NAME::VERSION_FILE.open('w') {|file| file.puts to_s }
39
+ (BASE_PATH + 'HISTORY').open('a') do |file|
40
+ file.puts "\n== #{to_s} / #{Time.now.strftime '%Y-%m-%d'}\n"
41
+ file.puts "\n* #{desc}\n" if desc
42
+ end
43
+ end
44
+
45
+ def to_s
46
+ [major, minor, patch, build].compact.join('.')
47
+ end
48
+ end
49
+
50
+ desc 'Set version: [x.y.z] - explicitly, [1/10/100] - bump major/minor/patch, [.build] - build'
51
+ task :version, [:command, :desc] do |t, args|
52
+ version = Version.new(CLASS_NAME::VERSION)
53
+ case args.command
54
+ when /^(\d+)\.(\d+)\.(\d+)(?:\.(.*?))?$/ # Set version explicitly
55
+ version.update($1, $2, $3, $4)
56
+ when /^\.(.*?)$/ # Set build
57
+ version.build = $1
58
+ when /^(\d{1})$/ # Bump patch
59
+ version.bump_patch $1
60
+ when /^(\d{1})0$/ # Bump minor
61
+ version.bump_minor $1
62
+ when /^(\d{1})00$/ # Bump major
63
+ version.bump_major $1
64
+ else # Unknown command, just display VERSION
65
+ puts "#{NAME} #{version}"
66
+ next
67
+ end
68
+
69
+ puts "Writing version #{version} to VERSION file"
70
+ version.write args.desc
71
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: swing
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - arvicco
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-21 00:00:00 +04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 2.0.0
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 1.0.0
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ description: |-
39
+ Straightforward wrappers for javax.swing Components that simplify Swing code in
40
+ JRuby-based GUI applications
41
+ email: arvitallian@gmail.com
42
+ executables:
43
+ - swing
44
+ extensions: []
45
+
46
+ extra_rdoc_files:
47
+ - LICENSE
48
+ - HISTORY
49
+ - README.rdoc
50
+ files:
51
+ - bin/swing
52
+ - lib/swing.rb
53
+ - lib/version.rb
54
+ - lib/swing/action_listener.rb
55
+ - lib/swing/attr_setter.rb
56
+ - lib/swing/controls.rb
57
+ - lib/swing/frame.rb
58
+ - lib/swing/list.rb
59
+ - lib/swing/menus.rb
60
+ - lib/swing/panel.rb
61
+ - lib/swing/scroll_pane.rb
62
+ - lib/swing/split_pane.rb
63
+ - lib/swing/table.rb
64
+ - spec/spec_helper.rb
65
+ - spec/swing_spec.rb
66
+ - features/swing.feature
67
+ - features/step_definitions/swing_steps.rb
68
+ - features/support/env.rb
69
+ - features/support/world.rb
70
+ - tasks/common.rake
71
+ - tasks/doc.rake
72
+ - tasks/gem.rake
73
+ - tasks/git.rake
74
+ - tasks/spec.rake
75
+ - tasks/version.rake
76
+ - Rakefile
77
+ - README.rdoc
78
+ - LICENSE
79
+ - VERSION
80
+ - HISTORY
81
+ - .gitignore
82
+ has_rdoc: true
83
+ homepage: http://github.com/arvicco/swing
84
+ licenses: []
85
+
86
+ post_install_message:
87
+ rdoc_options:
88
+ - --charset
89
+ - UTF-8
90
+ - --main
91
+ - README.rdoc
92
+ - --title
93
+ - swing
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "0"
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: "0"
108
+ requirements: []
109
+
110
+ rubyforge_project:
111
+ rubygems_version: 1.5.1
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: Straightforward wrappers for javax.swing Components
115
+ test_files:
116
+ - spec/spec_helper.rb
117
+ - spec/swing_spec.rb